01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-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: * Created on 31-dic-2004
17: */
18: package org.geotools.geometry.jts.coordinatesequence;
19:
20: /**
21: * A factory to obtain a builder for JTS CoordinateSequence objects.
22: *
23: * @author wolf
24: *
25: * TODO To change the template for this generated type comment go to
26: * Window - Preferences - Java - Code Style - Code Templates
27: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CSBuilderFactory.java $
28: */
29: public class CSBuilderFactory {
30: private static Class defaultBuilderClass;
31:
32: public static CSBuilder getDefaultBuilder() {
33: try {
34: return (CSBuilder) getDefaultBuilderClass().newInstance();
35: } catch (Exception e) {
36: // TODO: should we throw a better exception here? It's a fatal error anyway...
37: throw new RuntimeException(
38: "Could not create a coordinate sequence builder", e);
39: }
40: }
41:
42: private static Class getDefaultBuilderClass() {
43: if (defaultBuilderClass == null) {
44: defaultBuilderClass = DefaultCSBuilder.class;
45: }
46: return defaultBuilderClass;
47: }
48:
49: /**
50: * @param builderClass
51: */
52: public static void setDefaultBuilderClass(Class builderClass) {
53: if (!CSBuilder.class.isAssignableFrom(builderClass))
54: throw new RuntimeException(builderClass.getName()
55: + " does not implement the CSBuilder interface");
56: defaultBuilderClass = builderClass;
57:
58: }
59:
60: }
|