001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.gml2;
017:
018: import org.picocontainer.MutablePicoContainer;
019: import com.vividsolutions.jts.geom.CoordinateSequenceFactory;
020: import com.vividsolutions.jts.geom.GeometryFactory;
021: import com.vividsolutions.jts.geom.impl.CoordinateArraySequenceFactory;
022: import org.geotools.feature.DefaultFeatureCollections;
023: import org.geotools.gml2.bindings.GML;
024: import org.geotools.gml2.bindings.GMLBindingConfiguration;
025: import org.geotools.xlink.XLINKConfiguration;
026: import org.geotools.xml.BindingConfiguration;
027: import org.geotools.xml.Configuration;
028: import org.geotools.xml.Parser;
029:
030: /**
031: * Configuration used by gml2 parsers.
032: *
033: * @author Justin Deoliveira, The Open Planning Project
034: *
035: */
036: public class GMLConfiguration extends Configuration {
037: /**
038: * Creates the new gml configuration, with a depenendency
039: * on {@link XLINKConfiguration}
040: */
041: public GMLConfiguration() {
042: super ();
043:
044: //add xlink cdependency
045: addDependency(new XLINKConfiguration());
046:
047: //add the parse unknown attributes property, this is mostly for
048: // the "fid" attribute
049: getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);
050: getProperties().add(Parser.Properties.PARSE_UNKNOWN_ATTRIBUTES);
051: }
052:
053: /**
054: * @return A new instanceof {@link GMLBindingConfiguration}
055: */
056: public BindingConfiguration getBindingConfiguration() {
057: return new GMLBindingConfiguration();
058: }
059:
060: /**
061: * @return {@link GML#NAMESPACE}
062: */
063: public String getNamespaceURI() {
064: return GML.NAMESPACE;
065: }
066:
067: /**
068: * @return URL to the gml2 feauture.xsd file.
069: */
070: public String getSchemaFileURL() {
071: return getSchemaLocationResolver().resolveSchemaLocation(null,
072: getNamespaceURI(), "feature.xsd");
073: }
074:
075: /**
076: * Configures the gml2 context.
077: * <p>
078: * The following classes are registered:
079: * <ul>
080: * <li>{@link CoordinateArraySequenceFactory} under {@link CoordinateSequenceFactory}
081: * <li>{@link GeometryFactory}
082: * <li>{@link FeatureTypeCache}
083: * <li>{@link DefaultFeatureCollections}
084: * </ul>
085: * </p>
086: */
087: public void configureContext(MutablePicoContainer container) {
088: super .configureContext(container);
089:
090: container.registerComponentInstance(new FeatureTypeCache());
091:
092: container.registerComponentInstance(
093: CoordinateSequenceFactory.class,
094: CoordinateArraySequenceFactory.instance());
095: container
096: .registerComponentImplementation(GeometryFactory.class);
097: container
098: .registerComponentImplementation(DefaultFeatureCollections.class);
099: }
100: }
|