Source Code Cross Referenced for SimpleFeatureImpl.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.Iterator;
004:        import java.util.List;
005:
006:        import org.geotools.feature.iso.FeatureImpl;
007:        import org.opengis.feature.Attribute;
008:        import org.opengis.feature.GeometryAttribute;
009:        import org.opengis.feature.simple.SimpleFeature;
010:        import org.opengis.feature.simple.SimpleFeatureType;
011:        import org.opengis.feature.type.AttributeDescriptor;
012:        import org.opengis.feature.type.AttributeType;
013:
014:        /**
015:         * An implementation of the SimpleFeature convience methods ontop of
016:         * FeatureImpl.
017:         * 
018:         * @author Justin
019:         */
020:        public class SimpleFeatureImpl extends FeatureImpl implements 
021:                SimpleFeature {
022:
023:            public SimpleFeatureImpl(List values, AttributeDescriptor desc,
024:                    String id) {
025:                super (values, desc, id);
026:            }
027:
028:            public SimpleFeatureImpl(List values, SimpleFeatureType type,
029:                    String id) {
030:                super (values, type, id);
031:            }
032:
033:            /**
034:             * Create a Feature with the following content.
035:             * 
036:             * @param values
037:             *            Values in agreement with provided type
038:             * @param type
039:             *            Type of feature to be created
040:             * @param id
041:             *            Feature ID
042:             */
043:            public SimpleFeatureImpl(SimpleFeatureType type, String id,
044:                    Object[] values) {
045:                this (SimpleFeatureFactoryImpl.attributes(type, values), type,
046:                        id);
047:            }
048:
049:            /**
050:             * Retrive value by attribute name.
051:             * 
052:             * @param name
053:             * @return Attribute Value associated with name
054:             */
055:            public Object getValue(String name) {
056:                for (Iterator itr = super .properties.iterator(); itr.hasNext();) {
057:                    Attribute att = (Attribute) itr.next();
058:                    AttributeType type = att.getType();
059:                    String attName = type.getName().getLocalPart();
060:                    if (attName.equals(name)) {
061:                        return att.getValue();
062:                    }
063:                }
064:                return null;
065:            }
066:
067:            public Object getValue(AttributeType type) {
068:                if (!super .types().contains(type)) {
069:                    throw new IllegalArgumentException(
070:                            "this feature content model has no type " + type);
071:                }
072:                for (Iterator itr = super .properties.iterator(); itr.hasNext();) {
073:                    Attribute att = (Attribute) itr.next();
074:                    if (att.getType().equals(type)) {
075:                        return att.getValue();
076:                    }
077:                }
078:                throw new Error();
079:            }
080:
081:            /**
082:             * Access attribute by "index" indicated by SimpleFeatureType.
083:             * 
084:             * @param index
085:             * @return
086:             */
087:            public Object getValue(int index) {
088:                Attribute att = (Attribute) super .properties.get(index);
089:                return att == null ? null : att.getValue();
090:                // return values().get(index);
091:            }
092:
093:            /**
094:             * Modify attribute with "name" indicated by SimpleFeatureType.
095:             * 
096:             * @param name
097:             * @param value
098:             */
099:            public void setValue(String name, Object value) {
100:                AttributeType type = ((SimpleFeatureType) getType())
101:                        .getType(name);
102:                List/* <AttributeType> */types = ((SimpleFeatureType) getType())
103:                        .getTypes();
104:                int idx = types.indexOf(type);
105:                if (idx == -1) {
106:                    throw new IllegalArgumentException(name
107:                            + " is not a feature attribute");
108:                }
109:                setValue(idx, value);
110:            }
111:
112:            /**
113:             * Modify attribute at the "index" indicated by SimpleFeatureType.
114:             * 
115:             * @param index
116:             * @param value
117:             */
118:            public void setValue(int index, Object value) {
119:                List/* <Attribute> */contents = (List) super .getValue();
120:                Attribute attribute = (Attribute) contents.get(index);
121:                attribute.setValue(value);
122:                this .setValue(contents);
123:            }
124:
125:            public List getAttributes() {
126:                return (List) getValue();
127:            }
128:
129:            public int getNumberOfAttributes() {
130:                return types().size();
131:            }
132:
133:            public List getTypes() {
134:                return super .types();
135:            }
136:
137:            public Object getDefaultGeometryValue() {
138:                return getDefaultGeometry() != null ? getDefaultGeometry()
139:                        .getValue() : null;
140:            }
141:
142:            public void defaultGeometry(Object geometry) {
143:                if (getDefaultGeometry() != null) {
144:                    getDefaultGeometry().setValue(geometry);
145:                }
146:            }
147:
148:            public Object operation(String arg0, Object arg1) {
149:                throw new UnsupportedOperationException(
150:                        "operation not supported yet");
151:            }
152:
153:            public void setDefaultGeometryValue(Object geometry) {
154:                GeometryAttribute defaultGeometry = getDefaultGeometry();
155:                defaultGeometry.setValue(geometry);
156:            }
157:
158:            public void setValue(List /* <Attribute> */values) {
159:                super .setValue(values);
160:            }
161:
162:            public void setValues(List values) {
163:                super .setValue(values);
164:            }
165:
166:            public void setValues(Object[] values) {
167:                if (values == null) {
168:                    super .setValue(null);
169:                    return;
170:                }
171:                List properties = super .properties;
172:                for (int i = 0; i < values.length; i++) {
173:                    Attribute att = (Attribute) properties.get(i);
174:                    att.setValue(values[i]);
175:                }
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.