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.gml3;
017:
018: import org.eclipse.xsd.util.XSDSchemaLocationResolver;
019: import org.picocontainer.MutablePicoContainer;
020: import com.vividsolutions.jts.geom.CoordinateSequenceFactory;
021: import com.vividsolutions.jts.geom.GeometryFactory;
022: import com.vividsolutions.jts.geom.impl.CoordinateArraySequenceFactory;
023: import org.geotools.gml2.FeaturePropertyExtractor;
024: import org.geotools.gml2.FeatureTypeCache;
025: import org.geotools.gml3.bindings.GML;
026: import org.geotools.gml3.bindings.GMLBindingConfiguration;
027: import org.geotools.gml3.bindings.GMLSchemaLocationResolver;
028: import org.geotools.gml3.smil.SMIL20Configuration;
029: import org.geotools.gml3.smil.SMIL20LANGConfiguration;
030: import org.geotools.xlink.XLINKConfiguration;
031: import org.geotools.xml.BindingConfiguration;
032: import org.geotools.xml.Configuration;
033: import org.geotools.xml.Parser;
034:
035: /**
036: * Parser configuration for the gml3 schema.
037: *
038: * @author Justin Deoliveira, The Open Planning Project
039: *
040: */
041: public class GMLConfiguration extends Configuration {
042: public GMLConfiguration() {
043: super ();
044:
045: //add xlink cdependency
046: addDependency(new XLINKConfiguration());
047:
048: //add smil depenedncy
049: addDependency(new SMIL20Configuration());
050: addDependency(new SMIL20LANGConfiguration());
051:
052: //add parser properties
053: getProperties().add(Parser.Properties.PARSE_UNKNOWN_ELEMENTS);
054: getProperties().add(Parser.Properties.PARSE_UNKNOWN_ATTRIBUTES);
055: }
056:
057: /**
058: * @return {@link GML#NAMESPACE}
059: */
060: public String getNamespaceURI() {
061: return GML.NAMESPACE;
062: }
063:
064: /**
065: * @return A new instance of {@link org.geotools.gml3.bindings.GMLBindingConfiguration}
066: */
067: public BindingConfiguration getBindingConfiguration() {
068: return new GMLBindingConfiguration();
069: }
070:
071: /**
072: * @return A new instance of {@link org.geotools.gml3.bindings.GMLSchemaLocationResolver}
073: */
074: public XSDSchemaLocationResolver getSchemaLocationResolver() {
075: return new GMLSchemaLocationResolver();
076: }
077:
078: /**
079: * @return Url to the gml.xsd file of the gml3 schema.
080: */
081: public String getSchemaFileURL() {
082: return getSchemaLocationResolver().resolveSchemaLocation(null,
083: getNamespaceURI(), "gml.xsd");
084: }
085:
086: /**
087: * Configures the gml3 context.
088: * <p>
089: * The following factories are registered:
090: * <ul>
091: * <li>{@link CoordinateArraySequenceFactory} under {@link CoordinateSequenceFactory}
092: * <li>{@link GeometryFactory}
093: * </ul>
094: * </p>
095: */
096: public void configureContext(MutablePicoContainer container) {
097: super .configureContext(container);
098:
099: container.registerComponentInstance(new FeatureTypeCache());
100: container
101: .registerComponentImplementation(FeaturePropertyExtractor.class);
102:
103: //factories
104: container.registerComponentInstance(
105: CoordinateSequenceFactory.class,
106: CoordinateArraySequenceFactory.instance());
107: container
108: .registerComponentImplementation(GeometryFactory.class);
109: }
110: }
|