01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.feature;
17:
18: import java.util.Collections;
19: import java.util.Map;
20:
21: import org.geotools.factory.CommonFactoryFinder;
22: import org.geotools.factory.Factory;
23: import org.geotools.factory.GeoTools;
24:
25: /**
26: * A utility class for working with FeatureCollections.
27: * Provides a mechanism for obtaining a FeatureCollection instance.
28: * @author Ian Schneider
29: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/feature/FeatureCollections.java $
30: */
31: public abstract class FeatureCollections implements Factory {
32:
33: private static FeatureCollections instance() {
34: // depend on CommonFactoryFinder's FactoryRegistry to hold singleton
35: return CommonFactoryFinder.getFeatureCollections(GeoTools
36: .getDefaultHints());
37: }
38:
39: /**
40: * create a new FeatureCollection using the current default factory.
41: * @return A FeatureCollection instance.
42: */
43: public static FeatureCollection newCollection() {
44: return instance().createCollection();
45: }
46:
47: /**
48: * Creates a new FeatureCollection with a particular id using the current
49: * default factory.
50: *
51: * @param id The id of the feature collection.
52: *
53: * @return A new FeatureCollection intsance with the specified id.
54: *
55: * @since 2.4
56: */
57: public static FeatureCollection newCollection(String id) {
58: return instance().createCollection(id);
59: }
60:
61: /**
62: * Subclasses must implement this to return a new FeatureCollection object.
63: * @return A new FeatureCollection
64: */
65: protected abstract FeatureCollection createCollection();
66:
67: /**
68: * Subclasses must implement this to return a new FeatureCollection object
69: * with a particular id.
70: *
71: * @param id The identification of the feature collection.
72: *
73: * @return A new FeatureCollection with the specified id.
74: */
75: protected abstract FeatureCollection createCollection(String id);
76:
77: /**
78: * Returns the implementation hints. The default implementation returns en empty map.
79: */
80: public Map getImplementationHints() {
81: return Collections.EMPTY_MAP;
82: }
83: }
|