Source Code Cross Referenced for SimpleFeatureFactoryImpl.java in  » GIS » GeoTools-2.4.1 » org » geotools » feature » iso » simple » 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.feature.iso.simple 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.geotools.feature.iso.simple;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.Date;
006:        import java.util.Iterator;
007:        import java.util.List;
008:
009:        import org.geotools.feature.iso.AttributeFactoryImpl;
010:        import org.geotools.feature.iso.AttributeImpl;
011:        import org.geotools.feature.iso.Types;
012:        import org.geotools.feature.iso.attribute.GeometricAttribute;
013:        import org.geotools.feature.iso.attribute.TextualAttribute;
014:        import org.geotools.feature.iso.type.AttributeDescriptorImpl;
015:        import org.opengis.feature.Attribute;
016:        import org.opengis.feature.Feature;
017:        import org.opengis.feature.simple.BooleanAttribute;
018:        import org.opengis.feature.simple.NumericAttribute;
019:        import org.opengis.feature.simple.SimpleFeature;
020:        import org.opengis.feature.simple.SimpleFeatureCollection;
021:        import org.opengis.feature.simple.SimpleFeatureCollectionType;
022:        import org.opengis.feature.simple.SimpleFeatureFactory;
023:        import org.opengis.feature.simple.SimpleFeatureType;
024:        import org.opengis.feature.simple.TemporalAttribute;
025:        import org.opengis.feature.simple.TextAttribute;
026:        import org.opengis.feature.type.AttributeDescriptor;
027:        import org.opengis.feature.type.AttributeType;
028:        import org.opengis.feature.type.Name;
029:
030:        import com.vividsolutions.jts.geom.Geometry;
031:
032:        /**
033:         * Construct specific types for SimpleFeatures.
034:         * <p>
035:         * Please note that this factory is <b>direct</b> and will implement what
036:         * you ask for - if you need asistence use a builder.
037:         * </p>
038:         * @author Jody Garnett
039:         */
040:        public class SimpleFeatureFactoryImpl extends AttributeFactoryImpl
041:                implements  SimpleFeatureFactory {
042:
043:            /**
044:             * Create a list of properties from provided type + values.
045:             * <p>
046:             * Package visible for use by SimpleFeatureImpl constructors.
047:             * </p>
048:             * @return List<Attribute> based on provided values
049:             */
050:            public static List attributes(SimpleFeatureType type,
051:                    Object values[]) {
052:                if (values == null) {
053:                    values = new Object[type.getTypes().size()];
054:                }
055:                List attributes = new ArrayList(values.length);
056:                int index = 0;
057:                for (Iterator i = type.getProperties().iterator(); i.hasNext(); index++) {
058:                    AttributeDescriptor descriptor = (AttributeDescriptor) i
059:                            .next();
060:                    Class binding = ((AttributeType) descriptor.type())
061:                            .getBinding();
062:                    Object value = index < values.length ? values[index] : null;
063:                    Attribute attribute;
064:                    if (Geometry.class.isAssignableFrom(binding)) {
065:                        attribute = new GeometricAttribute(value, descriptor,
066:                                null, null);
067:                    } else {
068:                        attribute = new AttributeImpl(value, descriptor, null);
069:                    }
070:                    attributes.add(attribute);
071:                }
072:                return attributes;
073:            }
074:
075:            public BooleanAttribute createBooleanAttribute(Boolean value,
076:                    AttributeDescriptor descriptor) {
077:                return new org.geotools.feature.iso.attribute.BooleanAttribute(
078:                        value, descriptor);
079:            }
080:
081:            public NumericAttribute createNumericAttribute(Number value,
082:                    AttributeDescriptor descriptor) {
083:                return new org.geotools.feature.iso.attribute.NumericAttribute(
084:                        value, descriptor);
085:            }
086:
087:            public TemporalAttribute createTemporalAttribute(Date value,
088:                    AttributeDescriptor descriptor) {
089:                return new org.geotools.feature.iso.attribute.TemporalAttribute(
090:                        value, descriptor);
091:            }
092:
093:            public TextAttribute createTextAttribute(CharSequence value,
094:                    AttributeDescriptor descriptor) {
095:                return new TextualAttribute(value, descriptor);
096:            }
097:
098:            public Feature createFeature(Collection value,
099:                    AttributeDescriptor desc, String id) {
100:                throw new UnsupportedOperationException(
101:                        "SimpleFeature cannot be nested");
102:            }
103:
104:            public SimpleFeature createSimpleFeature(SimpleFeatureType type,
105:                    String id, Object[] values) {
106:                return new SimpleFeatureImpl(type, id, values);
107:            }
108:
109:            public SimpleFeature createSimpleFeature(List attributes,
110:                    SimpleFeatureType type, String id) {
111:                return new SimpleFeatureImpl(attributes, type, id);
112:            }
113:
114:            public SimpleFeatureCollection createSimpleFeatureCollection(
115:                    SimpleFeatureCollectionType type, String id) {
116:                return new SimpleFeatureCollectionImpl(type, id);
117:            }
118:
119:            final static AttributeDescriptor find(List descriptors, Name name) {
120:                if (name == null)
121:                    return null;
122:                for (Iterator i = descriptors.iterator(); i.hasNext();) {
123:                    AttributeDescriptor attributeType = (AttributeDescriptor) i
124:                            .next();
125:                    if (name.equals(attributeType.type().getName())) {
126:                        return attributeType;
127:                    }
128:                }
129:                return null; // no default geometry here?
130:            }
131:
132:            /** Create AttributeDescriptorImpl for this simple type */
133:            final static List descriptors(List typeList) {
134:                List descriptors = new ArrayList(typeList.size());
135:                for (Iterator i = typeList.iterator(); i.hasNext();) {
136:                    AttributeType attributeType = (AttributeType) i.next();
137:                    Name typeName = attributeType.getName();
138:                    Name descriptorName = Types.typeName(typeName);
139:                    AttributeDescriptor attribute = new AttributeDescriptorImpl(
140:                            attributeType, descriptorName, 1, 1, true, null);
141:                    descriptors.add(attribute);
142:                }
143:                return descriptors;
144:            }
145:
146:            final static Name geometryName(AttributeType geom) {
147:                if (geom == null)
148:                    return null;
149:                return geom.getName();
150:
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.