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.gml;
17:
18: import java.util.logging.Logger;
19:
20: /**
21: * Creates the appropriate SubHandler element for a given OGC simple geometry
22: * type.
23: *
24: * @author Rob Hranac, Vision for New York
25: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/gml/SubHandlerFactory.java $
26: * @version $Id: SubHandlerFactory.java 27862 2007-11-12 19:51:19Z desruisseaux $
27: */
28: public class SubHandlerFactory {
29: /** The logger for the GML module */
30: private static final Logger LOGGER = org.geotools.util.logging.Logging
31: .getLogger("org.geotools.gml");
32:
33: /** List of all valid OGC multi geometry types. */
34: private static final java.util.Collection BASE_GEOMETRY_TYPES = new java.util.Vector(
35: java.util.Arrays.asList(new String[] { "MultiPoint",
36: "MultiLineString", "MultiPolygon" }));
37:
38: /**
39: * Empty constructor.
40: */
41: public SubHandlerFactory() {
42: LOGGER.entering("SubHandlerFactory", "new");
43: LOGGER.exiting("SubHandlerFactory", "new");
44: }
45:
46: /**
47: * Creates a new SubHandler, based on the appropriate OGC simple geometry
48: * type. Note that some types are aggregated into a generic 'multi' type.
49: *
50: * @param type Type of SubHandler to return.
51: *
52: * @return DOCUMENT ME!
53: *
54: * @task TODO: throw an exception, not return a null
55: */
56: public SubHandler create(String type) {
57: LOGGER.entering("SubHandlerFactory", "create", type);
58:
59: SubHandler returnValue = null;
60:
61: if (type.equals("Point")) {
62: returnValue = new SubHandlerPoint();
63: } else if (type.equals("LineString")) {
64: returnValue = new SubHandlerLineString();
65: } else if (type.equals("LinearRing")) {
66: returnValue = new SubHandlerLinearRing();
67: } else if (type.equals("Polygon")) {
68: returnValue = new SubHandlerPolygon();
69: } else if (type.equals("Box")) {
70: returnValue = new SubHandlerBox();
71: } else if (BASE_GEOMETRY_TYPES.contains(type)) {
72: returnValue = new SubHandlerMulti();
73: } else {
74: returnValue = null; // should be throwing an exception here!
75: }
76:
77: LOGGER.exiting("SubHandlerFactory", "create", returnValue);
78:
79: return returnValue;
80: }
81: }
|