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


001:        /*
002:         *    Geotools2 - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2005-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:         */
017:        package org.geotools.data.complex;
018:
019:        import java.io.IOException;
020:        import java.util.Collection;
021:        import java.util.Collections;
022:        import java.util.Iterator;
023:        import java.util.Set;
024:
025:        import org.geotools.catalog.GeoResourceInfo;
026:        import org.geotools.data.DataStore;
027:        import org.geotools.data.DefaultQuery;
028:        import org.geotools.data.FeatureListener;
029:        import org.geotools.data.Query;
030:        import org.geotools.data.Transaction;
031:        import org.geotools.data.feature.FeatureSource2;
032:        import org.geotools.data.feature.adapter.GTFeatureTypeAdapter;
033:        import org.geotools.feature.FeatureCollection;
034:        import org.geotools.feature.iso.collection.AbstractFeatureCollection;
035:        import org.opengis.feature.type.FeatureCollectionType;
036:        import org.opengis.feature.type.FeatureType;
037:        import org.opengis.feature.type.Name;
038:        import org.opengis.filter.Filter;
039:        import org.opengis.filter.capability.FilterCapabilities;
040:
041:        import com.vividsolutions.jts.geom.Envelope;
042:
043:        /**
044:         * A FeatureSource2 that uses a
045:         * {@linkplain org.geotools.data.complex.FeatureTypeMapping} to perform Feature
046:         * fetching.
047:         * 
048:         * <p>
049:         * Note that the number of Features available from a MappingFeatureReader may
050:         * not match the number of features that resulted of executing the incoming
051:         * query over the surrogate FeatureSource. This will be the case when grouping
052:         * attributes has configured on the FeatureTypeMapping this reader is based on.
053:         * </p>
054:         * <p>
055:         * When a MappingFeatureReader is created, a delegated FeatureIterator will be
056:         * created based on the information provided by the FeatureTypeMapping object.
057:         * That delegate reader will be specialized in applying the appropiate mapping
058:         * stratagy based on wether grouping has to be performed or not.
059:         * </p>
060:         * 
061:         * @author Gabriel Roldan, Axios Engineering
062:         * @version $Id: MappingFeatureSource.java 28577 2008-01-03 15:44:29Z groldan $
063:         * @source $URL:
064:         *         http://svn.geotools.org/geotools/branches/2.4.x/modules/unsupported/community-schemas/community-schema-ds/src/main/java/org/geotools/data/complex/MappingFeatureSource.java $
065:         * @since 2.4
066:         * @see org.geotools.data.complex.DefaultMappingFeatureIterator
067:         * @see org.geotools.data.complex.GroupingFeatureIterator
068:         */
069:        class MappingFeatureSource implements  FeatureSource2 {
070:
071:            private ComplexDataStore store;
072:
073:            private FeatureTypeMapping mappings;
074:
075:            private org.geotools.feature.FeatureType gtType;
076:
077:            public MappingFeatureSource(ComplexDataStore store,
078:                    FeatureTypeMapping mapping) {
079:                this .store = store;
080:                this .mappings = mapping;
081:                FeatureType type = (FeatureType) mapping.getTargetFeature()
082:                        .type();
083:                gtType = new GTFeatureTypeAdapter(type);
084:            }
085:
086:            public void addFeatureListener(FeatureListener listener) {
087:                throw new UnsupportedOperationException();
088:            }
089:
090:            public Envelope getBounds() throws IOException {
091:                Envelope bounds = store.getBounds(namedQuery(Filter.INCLUDE,
092:                        Integer.MAX_VALUE));
093:                return bounds;
094:            }
095:
096:            private DefaultQuery namedQuery(Filter filter, int countLimit) {
097:                DefaultQuery query = new DefaultQuery();
098:                query.setTypeName(getName().getLocalPart());
099:                query.setFilter(filter);
100:                query.setMaxFeatures(countLimit);
101:                return query;
102:            }
103:
104:            private DefaultQuery namedQuery(Query query) {
105:                DefaultQuery namedQuery = namedQuery(query.getFilter(), query
106:                        .getMaxFeatures());
107:                namedQuery.setPropertyNames(query.getPropertyNames());
108:                namedQuery.setCoordinateSystem(query.getCoordinateSystem());
109:                namedQuery.setHandle(query.getHandle());
110:                namedQuery.setMaxFeatures(query.getMaxFeatures());
111:                namedQuery.setSortBy(query.getSortBy());
112:                return namedQuery;
113:            }
114:
115:            public Envelope getBounds(Query query) throws IOException {
116:                DefaultQuery namedQuery = namedQuery(query);
117:                Envelope bounds = store.getBounds(namedQuery);
118:                return bounds;
119:            }
120:
121:            public int getCount(Query query) throws IOException {
122:                DefaultQuery namedQuery = namedQuery(query);
123:                int count = store.getCount(namedQuery);
124:                return count;
125:            }
126:
127:            public DataStore getDataStore() {
128:                return store;
129:            }
130:
131:            public org.geotools.feature.FeatureType getSchema() {
132:                return gtType;
133:            }
134:
135:            public FeatureCollection getFeatures(Query query)
136:                    throws IOException {
137:                throw new UnsupportedOperationException();
138:            }
139:
140:            public FeatureCollection getFeatures(Filter filter)
141:                    throws IOException {
142:                throw new UnsupportedOperationException();
143:            }
144:
145:            public FeatureCollection getFeatures() throws IOException {
146:                throw new UnsupportedOperationException();
147:            }
148:
149:            public void removeFeatureListener(FeatureListener listener) {
150:                throw new UnsupportedOperationException(
151:                        "this is a read only feature source");
152:            }
153:
154:            public Collection content() {
155:                return content(Filter.INCLUDE);
156:            }
157:
158:            public Collection content(String query, String queryLanguage) {
159:                throw new UnsupportedOperationException();
160:            }
161:
162:            public Collection content(final Filter filter) {
163:                return content(filter, Integer.MAX_VALUE);
164:            }
165:
166:            /**
167:             * @return {@link org.opengis.feature.FeatureCollection}
168:             */
169:            public Collection content(final Filter filter, final int countLimit) {
170:                Collection collection = new AbstractFeatureCollection(null,
171:                        (FeatureCollectionType) null, null) {
172:                    public int size() {
173:                        int count;
174:                        try {
175:                            count = store.getCount(namedQuery(filter,
176:                                    countLimit));
177:                        } catch (IOException e) {
178:                            e.printStackTrace();
179:                            count = -1;
180:                        }
181:                        return count;
182:                    }
183:
184:                    /**
185:                     * @param close
186:                     *            AbstractMappingFeatureIterator as returned by
187:                     *            openIterator()
188:                     */
189:                    protected void closeIterator(Iterator close)
190:                            throws IOException {
191:                        AbstractMappingFeatureIterator iterator = (AbstractMappingFeatureIterator) close;
192:                        iterator.close();
193:                    }
194:
195:                    /**
196:                     * @return an AbstractMappingFeatureIterator
197:                     */
198:                    protected Iterator openIterator() throws IOException {
199:                        AbstractMappingFeatureIterator iterator;
200:                        Query query = namedQuery(filter, countLimit);
201:                        try {
202:                            if (0 == mappings.getGroupByAttNames().size()) {
203:                                iterator = new DefaultMappingFeatureIterator(
204:                                        store, mappings, query);
205:                            } else {
206:                                iterator = new GroupingFeatureIterator3(store,
207:                                        mappings, query);
208:                            }
209:                        } catch (IOException e) {
210:                            throw (RuntimeException) new RuntimeException()
211:                                    .initCause(e);
212:                        }
213:                        return iterator;
214:                    }
215:                };
216:                return collection;
217:            }
218:
219:            public Object describe() {
220:                return mappings.getTargetFeature();
221:            }
222:
223:            public void dispose() {
224:                // TODO Auto-generated method stub
225:
226:            }
227:
228:            public FilterCapabilities getFilterCapabilities() {
229:                throw new UnsupportedOperationException();
230:            }
231:
232:            public GeoResourceInfo getInfo() {
233:                throw new UnsupportedOperationException();
234:            }
235:
236:            public Name getName() {
237:                Name name = mappings.getTargetFeature().getName();
238:                return name;
239:            }
240:
241:            public void setTransaction(Transaction t) {
242:                throw new UnsupportedOperationException();
243:            }
244:
245:            public Set getSupportedHints() {
246:                return Collections.EMPTY_SET;
247:            }
248:
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.