01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.core;
16:
17: import java.util.Collection;
18: import java.util.Iterator;
19:
20: import org.geotools.feature.Feature;
21: import org.geotools.feature.FeatureType;
22: import org.geotools.feature.collection.AbstractFeatureCollection;
23:
24: /**
25: * Converts a java.util.Collection to a FeatureCollection
26: * @author Jesse
27: * @since 1.1.0
28: */
29: public class StaticFeatureCollection extends AbstractFeatureCollection {
30:
31: private Collection<Feature> features;
32:
33: public StaticFeatureCollection(Collection<Feature> features,
34: FeatureType featureType) {
35: super (featureType);
36: this .features = features;
37: }
38:
39: @Override
40: protected void closeIterator(Iterator close) {
41: //nothing to do
42: }
43:
44: @Override
45: protected Iterator openIterator() {
46: return features.iterator();
47: }
48:
49: @Override
50: public int size() {
51: return features.size();
52: }
53:
54: }
|