Source Code Cross Referenced for FeatureFactory.java in  » GIS » deegree » org » deegree » model » feature » 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 » deegree » org.deegree.model.feature 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/model/feature/FeatureFactory.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:        
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:        
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:        
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:        
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:        
025:         Contact:
026:        
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53115 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:        
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:        
042:        
043:         ---------------------------------------------------------------------------*/
044:        package org.deegree.model.feature;
045:
046:        import java.net.URI;
047:        import java.util.List;
048:
049:        import org.deegree.datatypes.QualifiedName;
050:        import org.deegree.datatypes.Types;
051:        import org.deegree.datatypes.UnknownTypeException;
052:        import org.deegree.framework.log.ILogger;
053:        import org.deegree.framework.log.LoggerFactory;
054:        import org.deegree.model.feature.schema.DefaultFeatureType;
055:        import org.deegree.model.feature.schema.FeaturePropertyType;
056:        import org.deegree.model.feature.schema.FeatureType;
057:        import org.deegree.model.feature.schema.GeometryPropertyType;
058:        import org.deegree.model.feature.schema.MultiGeometryPropertyType;
059:        import org.deegree.model.feature.schema.PropertyType;
060:        import org.deegree.model.feature.schema.SimplePropertyType;
061:        import org.deegree.ogcbase.CommonNamespaces;
062:
063:        /**
064:         * This factory offers methods for creating Features, FeatureCollection and all direct related
065:         * classes/interfaces that are part of the org.deegree.model.feature package.
066:         * 
067:         * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
068:         * @author last edited by: $Author: rbezema $
069:         * 
070:         * @version $Revision: 10397 $, $Date: 2008-03-04 08:18:07 -0800 (Tue, 04 Mar 2008) $
071:         */
072:        public class FeatureFactory {
073:
074:            private final static ILogger LOG = LoggerFactory
075:                    .getLogger(FeatureFactory.class);
076:
077:            private static URI GMLNS = CommonNamespaces.GMLNS;
078:
079:            /**
080:             * Creates an instance of a <code>PropertyType</code> from the given parameters.
081:             * <p>
082:             * Determines the right type from the given type name.
083:             * 
084:             * @param name
085:             *            name of the property type
086:             * @param typeName
087:             *            type name of the property type
088:             * @param nullable
089:             *            set to true, if property type may be omitted
090:             * @return corresponding PropertyType instance
091:             * @throws UnknownTypeException
092:             */
093:            public static PropertyType createPropertyType(QualifiedName name,
094:                    QualifiedName typeName, boolean nullable)
095:                    throws UnknownTypeException {
096:                return createPropertyType(name, typeName, nullable ? 0 : 1, 1);
097:            }
098:
099:            /**
100:             * Creates an instance of a <code>PropertyType</code> from the given parameters.
101:             * <p>
102:             * Determines the right type from the given type name.
103:             * 
104:             * @param name
105:             *            name of the property type
106:             * @param typeName
107:             *            type name of the property type
108:             * @param minOccurs
109:             * @param maxOccurs
110:             * @return corresponding PropertyType instance
111:             * @throws UnknownTypeException
112:             */
113:            public static PropertyType createPropertyType(QualifiedName name,
114:                    QualifiedName typeName, int minOccurs, int maxOccurs)
115:                    throws UnknownTypeException {
116:
117:                PropertyType type = null;
118:
119:                int typeCode = determinePropertyType(typeName);
120:                switch (typeCode) {
121:                case Types.FEATURE: {
122:                    type = new FeaturePropertyType(name, typeName, typeCode,
123:                            minOccurs, maxOccurs);
124:                    break;
125:                }
126:                case Types.GEOMETRY: {
127:                    type = new GeometryPropertyType(name, typeName, typeCode,
128:                            minOccurs, maxOccurs);
129:                    break;
130:                }
131:                case Types.MULTIGEOMETRY: {
132:                    type = new MultiGeometryPropertyType(name, typeName,
133:                            typeCode, minOccurs, maxOccurs);
134:                    break;
135:                }
136:                default: {
137:                    type = new SimplePropertyType(name, typeCode, minOccurs,
138:                            maxOccurs);
139:                }
140:                }
141:                return type;
142:            }
143:
144:            /**
145:             * Creates an instance of a <code>SimplePropertyType</code> from the given parameters.
146:             * 
147:             * @param name
148:             *            name of the property type
149:             * @param typeCode
150:             *            type code of the property type
151:             * @param nullable
152:             *            set to true, if property type may be omitted
153:             * @return generated SimplePropertyType instance
154:             * @see Types
155:             */
156:            public static PropertyType createSimplePropertyType(
157:                    QualifiedName name, int typeCode, boolean nullable) {
158:                return createSimplePropertyType(name, typeCode, nullable ? 0
159:                        : 1, 1);
160:            }
161:
162:            /**
163:             * Creates an instance of a <code>SimplePropertyType</code> from the given parameters.
164:             * 
165:             * @param name
166:             *            name of the property type
167:             * @param typeCode
168:             *            type code of the property type
169:             * @param minOccurs
170:             * @param maxOccurs
171:             * @return generated SimplePropertyType instance
172:             * @see Types
173:             */
174:            public static SimplePropertyType createSimplePropertyType(
175:                    QualifiedName name, int typeCode, int minOccurs,
176:                    int maxOccurs) {
177:                return new SimplePropertyType(name, typeCode, minOccurs,
178:                        maxOccurs);
179:            }
180:
181:            /**
182:             * Creates an instance of a <code>GeometryPropertyType</code> from the given parameters.
183:             * 
184:             * @param name
185:             *            name of the property type
186:             * @param typeName
187:             *            typeName of the property type
188:             * @param minOccurs
189:             * @param maxOccurs
190:             * @return generated GeometryPropertyType instance
191:             * @see Types
192:             */
193:            public static GeometryPropertyType createGeometryPropertyType(
194:                    QualifiedName name, QualifiedName typeName, int minOccurs,
195:                    int maxOccurs) {
196:                return new GeometryPropertyType(name, typeName, Types.GEOMETRY,
197:                        minOccurs, maxOccurs);
198:            }
199:
200:            /**
201:             * Creates an instance of a <code>FeaturePropertyType</code> from the given parameters.
202:             * 
203:             * @param name
204:             *            name of the property type
205:             * @param typeName
206:             *            of the property type
207:             * @param minOccurs
208:             * @param maxOccurs
209:             * @return generated FeaturePropertyType instance
210:             * @see Types
211:             */
212:            public static FeaturePropertyType createFeaturePropertyType(
213:                    QualifiedName name, int minOccurs, int maxOccurs) {
214:                return new FeaturePropertyType(name,
215:                        Types.FEATURE_PROPERTY_NAME, Types.FEATURE, minOccurs,
216:                        maxOccurs);
217:            }
218:
219:            /**
220:             * Determines the type code for the given type name.
221:             * 
222:             * @param typeName
223:             *            name to determine
224:             * @return type code for the given type name
225:             * @throws UnknownTypeException
226:             *             if the type name cannot be determined
227:             * @see Types
228:             */
229:            public static int determinePropertyType(QualifiedName typeName)
230:                    throws UnknownTypeException {
231:                LOG
232:                        .logDebug("Determining property type code for property type='"
233:                                + typeName + "'...");
234:                int type = Types.FEATURE;
235:                if (typeName.isInNamespace(CommonNamespaces.XSNS)) {
236:                    LOG.logDebug("Must be a basic XSD type.");
237:                    try {
238:                        type = Types.getJavaTypeForXSDType(typeName
239:                                .getLocalName());
240:                    } catch (UnknownTypeException e) {
241:                        throw new UnknownTypeException(e);
242:                    }
243:                } else if (typeName.isInNamespace(GMLNS)) {
244:                    LOG.logDebug("Maybe a geometry property type?");
245:                    try {
246:                        type = Types.getJavaTypeForGMLType(typeName
247:                                .getLocalName());
248:                        LOG.logDebug("Yes.");
249:                    } catch (UnknownTypeException e) {
250:                        LOG
251:                                .logDebug("No. Should be a generic GML feature of some kind.");
252:                        // TODO check all possible GML types here, feature array property type
253:                    }
254:                } else {
255:                    throw new UnknownTypeException(
256:                            "Cannot determine property type for type '"
257:                                    + typeName + "'.");
258:                }
259:                return type;
260:            }
261:
262:            /**
263:             * creates an instance of a FeatureType from an array of FeatureTypeProperties, and its name but
264:             * without parents and childs
265:             * 
266:             * @param name
267:             *            name of the <code>FeatureType</code>
268:             * @param isAbstract
269:             *            <code>true</code> if the feature type to create is abstract, <code>false</code>
270:             *            otherwise
271:             * @param properties
272:             *            properties containing the <code>FeatureType</code>s content
273:             * @return instance of a <code>FeatureType</code>
274:             */
275:            public static FeatureType createFeatureType(QualifiedName name,
276:                    boolean isAbstract, PropertyType[] properties) {
277:                return new DefaultFeatureType(name, isAbstract, properties);
278:            }
279:
280:            /**
281:             * creates an instance of a FeatureType from an array of FeatureTypeProperties, and its name but
282:             * without parents and childs
283:             * 
284:             * @param name
285:             *            name of the <code>FeatureType</code>
286:             * @param isAbstract
287:             *            <code>true</code> if the feature type to create is abstract, <code>false</code>
288:             *            otherwise
289:             * @param properties
290:             *            properties containing the <code>FeatureType</code>s content
291:             * @return instance of a <code>FeatureType</code>
292:             */
293:            public static FeatureType createFeatureType(String name,
294:                    boolean isAbstract, PropertyType[] properties) {
295:                return new DefaultFeatureType(new QualifiedName(name),
296:                        isAbstract, properties);
297:            }
298:
299:            /**
300:             * creates an instance of a FeatureType from an array of FeatureTypeProperties, and its name but
301:             * without parents and childs
302:             * 
303:             * @param name
304:             *            name of the <code>FeatureType</code>
305:             * @param isAbstract
306:             *            <code>true</code> if the feature type to create is abstract, <code>false</code>
307:             *            otherwise
308:             * @param schemaLocation
309:             * @param properties
310:             *            properties containing the <code>FeatureType</code>s content
311:             * @return instance of a <code>FeatureType</code>
312:             */
313:            public static FeatureType createFeatureType(QualifiedName name,
314:                    boolean isAbstract, URI schemaLocation,
315:                    PropertyType[] properties) {
316:                return new DefaultFeatureType(name, isAbstract, schemaLocation,
317:                        properties);
318:            }
319:
320:            /**
321:             * creates an instance of a FeatureType from an array of FeatureTypeProperties, and its name but
322:             * without parents and childs
323:             * 
324:             * @param name
325:             *            name of the <code>FeatureType</code>
326:             * @param isAbstract
327:             *            <code>true</code> if the feature type to create is abstract, <code>false</code>
328:             *            otherwise
329:             * @param schemaLocation
330:             * @param properties
331:             *            properties containing the <code>FeatureType</code>s content
332:             * @return instance of a <code>FeatureType</code>
333:             */
334:            public static FeatureType createFeatureType(String name,
335:                    boolean isAbstract, URI schemaLocation,
336:                    PropertyType[] properties) {
337:                QualifiedName gName = new QualifiedName(name);
338:                return new DefaultFeatureType(gName, isAbstract,
339:                        schemaLocation, properties);
340:            }
341:
342:            /**
343:             * creates an instance of a FeatureProperty from its name and the data (value) it contains
344:             * 
345:             * @param name
346:             *            name of the <code>FeatureProperty</code>
347:             * @return an instance of a <code>FeatureProperty</code>
348:             * @param value
349:             *            value of the <code>FeatureProperty</code>
350:             */
351:            public static FeatureProperty createFeatureProperty(
352:                    QualifiedName name, Object value) {
353:                return new DefaultFeatureProperty(name, value);
354:            }
355:
356:            /**
357:             * creates an instance of a FeatureProperty from its name and the data (value) it contains
358:             * 
359:             * @param name
360:             *            name of the <code>FeatureProperty</code>
361:             * @return an instance of a <code>FeatureProperty</code>
362:             * @param value
363:             *            value of the <code>FeatureProperty</code>
364:             * @deprecated use {@link #createFeatureProperty (QualifiedName, Object)} instead
365:             */
366:            @Deprecated
367:            public static FeatureProperty createFeatureProperty(String name,
368:                    Object value) {
369:                QualifiedName qn = new QualifiedName(name);
370:                return new DefaultFeatureProperty(qn, value);
371:            }
372:
373:            /**
374:             * creates an instance of a Feature from its FeatureType and an array of Objects that represents
375:             * it properties. It is assumed that the order of the properties is identical to the order of
376:             * the FeatureTypeProperties of the the FeatureType.
377:             * 
378:             * @param id
379:             *            unique id of the <code>Feature</code>
380:             * @param featureType
381:             *            <code>FeatureType</code> of the <code>Feature</code>
382:             * @param properties
383:             *            properties (content) of the <code>Feature</code>
384:             * @return instance of a <code>Feature</code>
385:             */
386:            public static Feature createFeature(String id,
387:                    FeatureType featureType, FeatureProperty[] properties) {
388:                return new DefaultFeature(id, featureType, properties);
389:            }
390:
391:            /**
392:             * creates an instance of a Feature from its FeatureType and an array of Objects that represents
393:             * it properties. It is assumed that the order of the properties is identical to the order of
394:             * the FeatureTypeProperties of the the FeatureType.
395:             * 
396:             * @param id
397:             *            unique id of the <code>Feature</code>
398:             * @param featureType
399:             *            <code>FeatureType</code> of the <code>Feature</code>
400:             * @param properties
401:             *            properties (content) of the <code>Feature</code>
402:             * @return instance of a <code>Feature</code>
403:             */
404:            public static Feature createFeature(String id,
405:                    FeatureType featureType, List<FeatureProperty> properties) {
406:                FeatureProperty[] fps = properties
407:                        .toArray(new FeatureProperty[properties.size()]);
408:                return new DefaultFeature(id, featureType, fps);
409:            }
410:
411:            /**
412:             * creates an instance of a FeatureCollection with an initial capacity. The returned
413:             * FeatureCollection doesn't have a FeatureType nor properties. It is just a collection of
414:             * Features.
415:             * 
416:             * @param id
417:             *            unique id of the <code>FeatureCollection</code>
418:             * @param initialCapacity
419:             *            initial capacity of the <code>FeatureCollection</code>
420:             * @return instance of an empty <code>FeatureCollection</code>
421:             */
422:            public static FeatureCollection createFeatureCollection(String id,
423:                    int initialCapacity) {
424:                return new DefaultFeatureCollection(id, initialCapacity);
425:            }
426:
427:            /**
428:             * creates an instance of a FeatureCollection from an array of Features. The returned
429:             * FeatureCollection doesn't have a FeatureType nor properties. It is just a collection of
430:             * Features.
431:             * 
432:             * @param id
433:             *            unique id of the <code>FeatureCollection</code> instance
434:             * @param features
435:             *            <code>Feature</code>s to fill in into the <code>FeatureCollection</code>
436:             * @return instance of a <code>FeatureCollection</code> containing the submitted features
437:             */
438:            public static FeatureCollection createFeatureCollection(String id,
439:                    Feature[] features) {
440:                return new DefaultFeatureCollection(id, features);
441:            }
442:
443:            /**
444:             * creates an instance of a FeatureCollection from an array of Features. The returned
445:             * FeatureCollection doesn't have a FeatureType nor properties. It is just a collection of
446:             * Features. With it's name set to the given qualifiedName
447:             * 
448:             * @param id
449:             *            unique id of the <code>FeatureCollection</code> instance
450:             * @param features
451:             *            <code>Feature</code>s to fill in into the <code>FeatureCollection</code>
452:             * @param qName name of the featureCollection
453:             * @return instance of a <code>FeatureCollection</code> containing the submitted features
454:             */
455:            public static FeatureCollection createFeatureCollection(String id,
456:                    Feature[] features, QualifiedName qName) {
457:                return new DefaultFeatureCollection(id, features, qName);
458:            }
459:
460:            /**
461:             * Creates a {@link FeatureTupleCollection} for the given feature tuples.
462:             * 
463:             * @param id
464:             *            id for the <code>FeatureCollection</code> instance
465:             * @param featureTuples
466:             *            list of feature tuples (array length must match tupleLength parameter)
467:             * @param tupleLength
468:             *            number of features per tuple
469:             * @return <code>FeatureTupleCollection</code> containing the given feature tuples
470:             */
471:            public static FeatureTupleCollection createFeatureCollection(
472:                    String id, List<Feature[]> featureTuples, int tupleLength) {
473:                return new FeatureTupleCollection(id, featureTuples,
474:                        tupleLength);
475:            }
476:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.