Source Code Cross Referenced for BasicFactories.java in  » GIS » GeoTools-2.4.1 » org » geotools » factory » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.factory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2006, GeoTools Project Managment Committee (PMC)
005:         *    
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.factory;
017:
018:        // J2SE dependencies
019:        import java.util.Map;
020:
021:        // OpenGIS dependencies
022:        import org.opengis.feature.type.TypeFactory;
023:        import org.opengis.feature.display.FeatureDisplayFactory;
024:        import org.opengis.filter.FilterFactory;
025:        import org.opengis.go.CommonCapabilities;
026:        import org.opengis.go.CommonFactory;
027:        import org.opengis.go.display.DisplayFactory;
028:        import org.opengis.metadata.citation.CitationFactory;
029:        import org.opengis.referencing.crs.CRSAuthorityFactory;
030:        import org.opengis.referencing.crs.CRSFactory;
031:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
032:        import org.opengis.referencing.cs.CSAuthorityFactory;
033:        import org.opengis.referencing.cs.CSFactory;
034:        import org.opengis.referencing.datum.DatumAuthorityFactory;
035:        import org.opengis.referencing.datum.DatumFactory;
036:        import org.opengis.referencing.operation.CoordinateOperationAuthorityFactory;
037:        import org.opengis.referencing.operation.CoordinateOperationFactory;
038:        import org.opengis.sld.FeatureStyleFactory;
039:        import org.opengis.geometry.coordinate.GeometryFactory;
040:        import org.opengis.geometry.primitive.PrimitiveFactory;
041:        import org.opengis.util.NameFactory;
042:
043:        // Geotools dependencies
044:        import org.geotools.resources.i18n.Errors;
045:        import org.geotools.resources.i18n.ErrorKeys;
046:        import org.geotools.resources.Utilities;
047:        import org.geotools.referencing.ReferencingFactoryFinder;
048:
049:        /**
050:         * Defines a common abstraction for getting the different factories. This default implementation
051:         * provides support for only the most basic factories ({@linkplain ReferencingFactoryFinder referencing},
052:         * <cite>etc.</cite>). Many methods thrown an {@link FactoryNotFoundException} in all cases, for
053:         * example all methods related to GO-1 canvas objects. Those methods will be implemented later
054:         * in a subclass.
055:         *
056:         * @since 2.3
057:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/factory/BasicFactories.java $
058:         * @version $Id: BasicFactories.java 25050 2007-04-06 00:41:49Z jgarnett $
059:         * @author Martin Desruisseaux
060:         */
061:        public class BasicFactories implements  CommonFactory {
062:
063:            /**
064:             * The default authority name for authority factories.
065:             */
066:            private static final String DEFAULT_AUTHORITY = "EPSG";
067:
068:            /**
069:             * The default instance. Will be created only when first needed.
070:             *
071:             * @see #getDefault
072:             */
073:            private static CommonFactory DEFAULT;
074:
075:            /**
076:             * The hints to be used for all factory creation.
077:             */
078:            protected final Hints hints;
079:
080:            /**
081:             * Creates a new instance of {@code BasicFactories} with the specified set of hints. The
082:             * {@code hints} map should contains only the minimum set of hints, since this constructor
083:             * will keep a reference to all objects found in this map.
084:             * 
085:             * @param hints The hints to be used for all factory creation, or {@code null} if none.
086:             */
087:            public BasicFactories(final Map hints) {
088:                this .hints = (hints != null) ? new Hints(hints) : null;
089:            }
090:
091:            /**
092:             * Returns a default common factory instance.
093:             */
094:            public static synchronized CommonFactory getDefault() {
095:                if (DEFAULT == null) {
096:                    DEFAULT = new BasicFactories(new Hints(
097:                            Hints.LENIENT_DATUM_SHIFT, Boolean.TRUE));
098:                }
099:                return DEFAULT;
100:            }
101:
102:            /**
103:             * Format an error message saying that the specified factory is not yet supported.
104:             * The error message will be given to a {@link FactoryNotFoundException}.
105:             *
106:             * @param type The factory type requested by the users.
107:             */
108:            private static String unsupportedFactory(final Class type) {
109:                return Errors.format(ErrorKeys.FACTORY_NOT_FOUND_$1, Utilities
110:                        .getShortName(type));
111:            }
112:
113:            /**
114:             * Returns an object that represents the capabilities of this common factory and its
115:             * associated canvas.
116:             * <p>
117:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
118:             * The default implementation thrown an exception in all case.
119:             */
120:            public CommonCapabilities getCapabilities() {
121:                throw new FactoryRegistryException(
122:                        unsupportedFactory(CommonCapabilities.class));
123:            }
124:
125:            /**
126:             * Returns the {@linkplain FeatureDisplayFactory feature display factory} singleton.
127:             * <p>
128:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
129:             * The default implementation thrown an exception in all case.
130:             *
131:             * @throws FactoryNotFoundException if no factory was found for the requested type.
132:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
133:             */
134:            public FeatureDisplayFactory getFeatureDisplayFactory()
135:                    throws FactoryRegistryException {
136:                throw new FactoryNotFoundException(
137:                        unsupportedFactory(FeatureDisplayFactory.class));
138:            }
139:
140:            /**
141:             * Returns the {@linkplain FeatureTypeFactory feature type factory} singleton.
142:             * <p>
143:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
144:             * The default implementation thrown an exception in all case.
145:             *
146:             * @throws FactoryNotFoundException if no factory was found for the requested type.
147:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
148:             */
149:            public TypeFactory getTypeFactory() throws FactoryRegistryException {
150:                throw new FactoryNotFoundException(
151:                        unsupportedFactory(TypeFactory.class));
152:            }
153:
154:            /**
155:             * Returns the {@linkplain FilterFactory filter factory} singleton.
156:             * <p>
157:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
158:             * The default implementation thrown an exception in all case.
159:             *
160:             * @throws FactoryNotFoundException if no factory was found for the requested type.
161:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
162:             */
163:            public FilterFactory getFilterFactory()
164:                    throws FactoryRegistryException {
165:                throw new FactoryNotFoundException(
166:                        unsupportedFactory(FilterFactory.class));
167:            }
168:
169:            /**
170:             * Returns the {@linkplain DisplayFactory display factory} singleton.
171:             * <p>
172:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
173:             * The default implementation thrown an exception in all case.
174:             *
175:             * @throws FactoryNotFoundException if no factory was found for the requested type.
176:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
177:             */
178:            public DisplayFactory getDisplayFactory()
179:                    throws FactoryRegistryException {
180:                throw new FactoryNotFoundException(
181:                        unsupportedFactory(DisplayFactory.class));
182:            }
183:
184:            /**
185:             * Returns the {@linkplain NameFactory name factory} singleton.
186:             * <p>
187:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
188:             * The default implementation thrown an exception in all case.
189:             *
190:             * @throws FactoryNotFoundException if no factory was found for the requested type.
191:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
192:             */
193:            public NameFactory getNameFactory() throws FactoryRegistryException {
194:                throw new FactoryNotFoundException(
195:                        unsupportedFactory(NameFactory.class));
196:            }
197:
198:            /**
199:             * Returns the {@linkplain CitationFactory citation factory} singleton.
200:             * <p>
201:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
202:             * The default implementation thrown an exception in all case.
203:             *
204:             * @throws FactoryNotFoundException if no factory was found for the requested type.
205:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
206:             */
207:            public CitationFactory getCitationFactory()
208:                    throws FactoryRegistryException {
209:                throw new FactoryNotFoundException(
210:                        unsupportedFactory(CitationFactory.class));
211:            }
212:
213:            /**
214:             * Returns the {@linkplain CRSAuthorityFactory CRS authority factory} singleton.
215:             *
216:             * @throws FactoryNotFoundException if no factory was found for the requested type.
217:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
218:             */
219:            public CRSAuthorityFactory getCRSAuthorityFactory()
220:                    throws FactoryRegistryException {
221:                return ReferencingFactoryFinder.getCRSAuthorityFactory(
222:                        DEFAULT_AUTHORITY, hints);
223:            }
224:
225:            /**
226:             * Returns the {@linkplain CRSFactory CRS factory} singleton.
227:             *
228:             * @throws FactoryNotFoundException if no factory was found for the requested type.
229:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
230:             */
231:            public CRSFactory getCRSFactory() throws FactoryRegistryException {
232:                return ReferencingFactoryFinder.getCRSFactory(hints);
233:            }
234:
235:            /**
236:             * Returns the {@linkplain CSAuthorityFactory CS authority factory} singleton.
237:             *
238:             * @throws FactoryNotFoundException if no factory was found for the requested type.
239:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
240:             */
241:            public CSAuthorityFactory getCSAuthorityFactory()
242:                    throws FactoryRegistryException {
243:                return ReferencingFactoryFinder.getCSAuthorityFactory(
244:                        DEFAULT_AUTHORITY, hints);
245:            }
246:
247:            /**
248:             * Returns the {@linkplain CSFactory CS factory} singleton.
249:             *
250:             * @throws FactoryNotFoundException if no factory was found for the requested type.
251:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
252:             */
253:            public CSFactory getCSFactory() throws FactoryRegistryException {
254:                return ReferencingFactoryFinder.getCSFactory(hints);
255:            }
256:
257:            /**
258:             * Returns the {@linkplain DatumAuthorityFactory datum authority factory} singleton.
259:             *
260:             * @throws FactoryNotFoundException if no factory was found for the requested type.
261:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
262:             */
263:            public DatumAuthorityFactory getDatumAuthorityFactory()
264:                    throws FactoryRegistryException {
265:                return ReferencingFactoryFinder.getDatumAuthorityFactory(
266:                        DEFAULT_AUTHORITY, hints);
267:            }
268:
269:            /**
270:             * Returns the {@linkplain DatumFactory datum factory} singleton.
271:             *
272:             * @throws FactoryNotFoundException if no factory was found for the requested type.
273:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
274:             */
275:            public DatumFactory getDatumFactory()
276:                    throws FactoryRegistryException {
277:                return ReferencingFactoryFinder.getDatumFactory(hints);
278:            }
279:
280:            /**
281:             * Returns the {@linkplain CoordinateOperationAuthorityFactory coordinate operation authority
282:             * factory} singleton.
283:             *
284:             * @throws FactoryNotFoundException if no factory was found for the requested type.
285:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
286:             */
287:            public CoordinateOperationAuthorityFactory getCoordinateOperationAuthorityFactory()
288:                    throws FactoryRegistryException {
289:                return ReferencingFactoryFinder
290:                        .getCoordinateOperationAuthorityFactory(
291:                                DEFAULT_AUTHORITY, hints);
292:            }
293:
294:            /**
295:             * Returns the {@linkplain CoordinateOperationFactory coordinate operation factory} singleton.
296:             *
297:             * @throws FactoryNotFoundException if no factory was found for the requested type.
298:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
299:             */
300:            public CoordinateOperationFactory getCoordinateOperationFactory()
301:                    throws FactoryRegistryException {
302:                return ReferencingFactoryFinder
303:                        .getCoordinateOperationFactory(hints);
304:            }
305:
306:            /**
307:             * Returns the {@linkplain FeatureStyleFactory feature style factory} singleton.
308:             * <p>
309:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
310:             * The default implementation thrown an exception in all case.
311:             *
312:             * @throws FactoryNotFoundException if no factory was found for the requested type.
313:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
314:             */
315:            public FeatureStyleFactory getFeatureStyleFactory()
316:                    throws FactoryRegistryException {
317:                throw new FactoryNotFoundException(
318:                        unsupportedFactory(FeatureStyleFactory.class));
319:            }
320:
321:            /**
322:             * Returns the {@linkplain GeometryFactory geometry factory} equiped to build geometries
323:             * using the given {@linkplain CoordinateReferenceSystem coordinate reference system}.
324:             * <p>
325:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
326:             * The default implementation thrown an exception in all case.
327:             *
328:             * @param crs the {@linkplain CoordinateReferenceSystem coordinate reference system} the
329:             *        {@linkplain GeometryFactory geometry factory} should use.
330:             * @return the requested {@linkplain GeometryFactory geometry factory} or {@code null} if the 
331:             *         {@linkplain CoordinateReferenceSystem coordinate reference system} is not supported.
332:             *
333:             * @throws FactoryNotFoundException if no factory was found for the requested type.
334:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
335:             */
336:            public GeometryFactory getGeometryFactory(
337:                    final CoordinateReferenceSystem crs)
338:                    throws FactoryRegistryException {
339:                throw new FactoryNotFoundException(
340:                        unsupportedFactory(GeometryFactory.class));
341:            }
342:
343:            /**
344:             * Returns the {@linkplain PrimitiveFactory primitive factory} equiped to build primitives
345:             * using the given {@linkplain CoordinateReferenceSystem coordinate reference system}.
346:             * <p>
347:             * <strong>NOTE:</strong> This method is not yet supported in Geotools.
348:             * The default implementation thrown an exception in all case.
349:             *
350:             * @param crs the {@linkplain CoordinateReferenceSystem coordinate reference system} the
351:             *        {@linkplain PrimitiveFactory primitive factory} should use.
352:             * @return the requested {@linkplain PrimitiveFactory primitive factory} or {@code null} if the 
353:             *         {@linkplain CoordinateReferenceSystem coordinate reference system} is not supported.
354:             *
355:             * @throws FactoryNotFoundException if no factory was found for the requested type.
356:             * @throws FactoryRegistryException if the factory can't be obtained for an other reason.
357:             */
358:            public PrimitiveFactory getPrimitiveFactory(
359:                    final CoordinateReferenceSystem crs)
360:                    throws FactoryRegistryException {
361:                throw new FactoryNotFoundException(
362:                        unsupportedFactory(PrimitiveFactory.class));
363:            }
364:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.