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


001:        package org.geotools.data.store;
002:
003:        import java.io.IOException;
004:        import java.util.ArrayList;
005:        import java.util.Collection;
006:        import java.util.Iterator;
007:        import java.util.List;
008:
009:        import org.geotools.data.DataUtilities;
010:        import org.geotools.data.FeatureReader;
011:        import org.geotools.data.collection.DelegateFeatureReader;
012:        import org.geotools.feature.CollectionListener;
013:        import org.geotools.feature.Feature;
014:        import org.geotools.feature.FeatureCollection;
015:        import org.geotools.feature.FeatureCollections;
016:        import org.geotools.feature.FeatureIterator;
017:        import org.geotools.feature.FeatureList;
018:        import org.geotools.feature.FeatureType;
019:        import org.geotools.feature.IllegalAttributeException;
020:        import org.geotools.feature.collection.DelegateFeatureIterator;
021:        import org.geotools.feature.visitor.FeatureVisitor;
022:        import org.geotools.geometry.jts.ReferencedEnvelope;
023:        import org.geotools.util.ProgressListener;
024:        import org.opengis.filter.Filter;
025:        import org.opengis.filter.sort.SortBy;
026:
027:        import com.vividsolutions.jts.geom.Envelope;
028:        import com.vividsolutions.jts.geom.Geometry;
029:
030:        /**
031:         * Decorates a feature collection with one that filters content.
032:         * 
033:         * @author Justin Deoliveira, The Open Planning Project
034:         *
035:         */
036:        public class FilteringFeatureCollection implements  FeatureCollection {
037:
038:            /**
039:             * The original feature collection.
040:             */
041:            FeatureCollection delegate;
042:            /**
043:             * the filter
044:             */
045:            Filter filter;
046:
047:            public FilteringFeatureCollection(FeatureCollection delegate,
048:                    Filter filter) {
049:                this .delegate = delegate;
050:                this .filter = filter;
051:            }
052:
053:            public FeatureIterator features() {
054:                return new DelegateFeatureIterator(this , iterator());
055:            }
056:
057:            public void close(FeatureIterator close) {
058:                close.close();
059:            }
060:
061:            public Iterator iterator() {
062:                return new FilteringIterator(delegate.iterator(), filter);
063:            }
064:
065:            public void close(Iterator close) {
066:                FilteringIterator filtering = (FilteringIterator) close;
067:                delegate.close(filtering.getDelegate());
068:            }
069:
070:            public void addListener(CollectionListener listener)
071:                    throws NullPointerException {
072:                delegate.addListener(listener);
073:            }
074:
075:            public void removeListener(CollectionListener listener)
076:                    throws NullPointerException {
077:                delegate.removeListener(listener);
078:            }
079:
080:            public FeatureType getFeatureType() {
081:                return delegate.getFeatureType();
082:            }
083:
084:            public FeatureType getSchema() {
085:                return delegate.getSchema();
086:            }
087:
088:            public void accepts(FeatureVisitor visitor,
089:                    ProgressListener progress) throws IOException {
090:                delegate.accepts(visitor, progress);
091:            }
092:
093:            public FeatureCollection subCollection(Filter filter) {
094:                throw new UnsupportedOperationException();
095:            }
096:
097:            public FeatureList sort(SortBy order) {
098:                throw new UnsupportedOperationException();
099:            }
100:
101:            public void purge() {
102:                delegate.purge();
103:            }
104:
105:            public int size() {
106:                int count = 0;
107:                Iterator i = iterator();
108:                try {
109:                    while (i.hasNext()) {
110:                        count++;
111:                        i.next();
112:                    }
113:
114:                    return count;
115:                } finally {
116:                    close(i);
117:                }
118:            }
119:
120:            public void clear() {
121:                delegate.clear();
122:            }
123:
124:            public boolean isEmpty() {
125:                return size() == 0;
126:            }
127:
128:            public Object[] toArray() {
129:                return toArray(new Object[size()]);
130:            }
131:
132:            public Object[] toArray(Object[] a) {
133:                List list = new ArrayList();
134:                Iterator i = iterator();
135:                try {
136:                    while (i.hasNext()) {
137:                        list.add(i.next());
138:                    }
139:
140:                    return list.toArray(a);
141:                } finally {
142:                    close(i);
143:                }
144:            }
145:
146:            public boolean add(Object o) {
147:                if (!filter.evaluate(o)) {
148:                    return false;
149:                }
150:
151:                return delegate.add(o);
152:            }
153:
154:            public boolean contains(Object o) {
155:                return delegate.contains(o) && filter.evaluate(o);
156:            }
157:
158:            public boolean remove(Object o) {
159:                return delegate.remove(o);
160:            }
161:
162:            public boolean addAll(Collection c) {
163:                boolean changed = false;
164:
165:                for (Iterator i = c.iterator(); i.hasNext();) {
166:                    changed = changed | add(i.next());
167:                }
168:
169:                return changed;
170:            }
171:
172:            public boolean containsAll(Collection c) {
173:                for (Iterator i = c.iterator(); i.hasNext();) {
174:                    if (!contains(i.next())) {
175:                        return false;
176:                    }
177:                }
178:
179:                return true;
180:            }
181:
182:            public boolean removeAll(Collection c) {
183:                return delegate.removeAll(c);
184:            }
185:
186:            public boolean retainAll(Collection c) {
187:                return delegate.retainAll(c);
188:            }
189:
190:            public FeatureReader reader() throws IOException {
191:                return new DelegateFeatureReader(getSchema(), features());
192:            }
193:
194:            public String getID() {
195:                return delegate.getID();
196:            }
197:
198:            public Object[] getAttributes(Object[] attributes) {
199:                return delegate.getAttributes(attributes);
200:            }
201:
202:            public Object getAttribute(String xPath) {
203:                return delegate.getAttribute(xPath);
204:            }
205:
206:            public Object getAttribute(int index) {
207:                return delegate.getAttribute(index);
208:            }
209:
210:            public void setAttribute(int position, Object val)
211:                    throws IllegalAttributeException,
212:                    ArrayIndexOutOfBoundsException {
213:                delegate.setAttribute(position, val);
214:            }
215:
216:            public int getNumberOfAttributes() {
217:                return delegate.getNumberOfAttributes();
218:            }
219:
220:            public void setAttribute(String xPath, Object attribute)
221:                    throws IllegalAttributeException {
222:                delegate.setAttribute(xPath, attribute);
223:            }
224:
225:            public Geometry getDefaultGeometry() {
226:                return delegate.getDefaultGeometry();
227:            }
228:
229:            public void setDefaultGeometry(Geometry geometry)
230:                    throws IllegalAttributeException {
231:                delegate.setDefaultGeometry(geometry);
232:            }
233:
234:            public ReferencedEnvelope getBounds() {
235:                //calculate manually
236:                return ReferencedEnvelope.reference(DataUtilities.bounds(this));
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.