Source Code Cross Referenced for SimpleFeatures.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.Arrays;
004:        import java.util.Collections;
005:        import java.util.List;
006:
007:        import org.geotools.feature.iso.Types;
008:        import org.geotools.util.GTContainer;
009:        import org.opengis.feature.simple.SimpleFeature;
010:        import org.opengis.feature.simple.SimpleFeatureCollectionType;
011:        import org.opengis.feature.simple.SimpleFeatureFactory;
012:        import org.opengis.feature.simple.SimpleFeatureType;
013:        import org.opengis.feature.simple.SimpleTypeFactory;
014:        import org.picocontainer.defaults.DefaultPicoContainer;
015:
016:        /**
017:         * Convenience class for working with or implementing with simple features.
018:         * <p>
019:         * Method that involve creation must be called in a non-static context
020:         * and only after the class has been injected with a 
021:         * {@link org.geotools.feature.simple.SimpleFeatureBuilder}
022:         * </p>
023:         * FIXME Inject with factory not builder!
024:         * 
025:         * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
026:         *
027:         */
028:        public class SimpleFeatures {
029:
030:            //
031:            // FIXME This code moved from FeatureTypes shares flaw of GTContainer use
032:            // 
033:            final private static SimpleFeatureType emptySimpleFeatureType;
034:            final private static SimpleFeatureCollectionType emptySimpleFeatureCollectionType;
035:            static {
036:                DefaultPicoContainer container = GTContainer.simple();
037:                SimpleTypeFactory factory = (SimpleTypeFactory) container
038:                        .getComponentInstanceOfType(SimpleTypeFactory.class);
039:
040:                emptySimpleFeatureType = factory.createSimpleFeatureType(Types
041:                        .typeName("EmptySimpleFeatureType"),
042:                        Collections.EMPTY_LIST, null, null,
043:                        Collections.EMPTY_SET, null);
044:                emptySimpleFeatureCollectionType = factory
045:                        .createSimpleFeatureCollectionType(Types
046:                                .typeName("EmptySimpleFeatureCollectionType"),
047:                                emptySimpleFeatureType, null);
048:            }
049:            /**
050:             * Injected factory
051:             */
052:            SimpleFeatureFactory factory;
053:
054:            /**
055:             * Builder used to create simple features.
056:             */
057:            SimpleFeatureBuilder builder;
058:
059:            /**
060:             * Creates a new instance satisfying the factory dependency.
061:             * 
062:             * @param builder
063:             */
064:            public SimpleFeatures(SimpleFeatureFactory factory) {
065:                this .factory = factory;
066:                builder = new SimpleFeatureBuilder(factory);
067:            }
068:
069:            public void setSimpleFeatureFactory(SimpleFeatureFactory factory) {
070:                this .factory = factory;
071:                builder.setSimpleFeatureFactory(factory);
072:            }
073:
074:            /**
075:             * Creates a new simple feature from a type and array of values.
076:             * <p>
077:             * The order of items in <code>values</code> must correspond to the 
078:             * order of attributes defined in <code>type</code>
079:             * </p>
080:             * @param type The simple feature type.
081:             * @param values The values of the created feature.
082:             * @param fid The feature id, may be null.
083:             * 
084:             * @return The created feature.
085:             */
086:            public SimpleFeature create(SimpleFeatureType type,
087:                    Object[] values, String fid) {
088:                return create(type, Arrays.asList(values), fid);
089:            }
090:
091:            /**
092:             * Creates a new simple feature from a type and list of values.
093:             * <p>
094:             * The order of items in <code>values</code> must correspond to the 
095:             * order of attributes defined in <code>type</code>
096:             * </p>
097:             * @param type The simple feature type.
098:             * @param values The values of the created feature.
099:             * @param fid The feature id, may be null.
100:             * 
101:             * @return The created feature.
102:             */
103:            public SimpleFeature create(SimpleFeatureType type, List values,
104:                    String fid) {
105:                builder.init();
106:                builder.setType(type);
107:
108:                for (int i = 0; i < values.size(); i++) {
109:                    builder.add(values.get(i));
110:                }
111:                return builder.feature(fid);
112:            }
113:
114:            /**
115:             * Copies the values from one feature to another.
116:             * 
117:             * @param source The feature being copied from. 
118:             * @param target The feature being copied to.
119:              
120:             */
121:            public static void copy(SimpleFeature source, SimpleFeature target) {
122:                target.setValue(source.getValue());
123:                target.setDefaultGeometry(source.getDefaultGeometry());
124:                target.setCRS(source.getCRS());
125:            }
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.