001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.geoserver.wfs.xml;
006:
007: import org.eclipse.xsd.XSDSchema;
008: import org.geoserver.platform.GeoServerResourceLoader;
009: import org.geoserver.wfs.WFS;
010: import org.vfny.geoserver.global.Data;
011: import org.vfny.geoserver.global.FeatureTypeInfo;
012: import java.io.IOException;
013:
014: /**
015: * An xml schema describing a wfs feature type.
016: *
017: * @author Justin Deoliveira, The Open Planning Project
018: *
019: */
020: public abstract class FeatureTypeSchema {
021: /**
022: * The feature type metadata object.
023: */
024: protected FeatureTypeInfo featureType;
025:
026: /**
027: * The xsd schema builder.
028: */
029: protected FeatureTypeSchemaBuilder builder;
030:
031: /**
032: * The catalog
033: */
034: protected Data catalog;
035:
036: /**
037: * WFS configuration
038: */
039: protected WFS wfs;
040:
041: /**
042: * resource loader
043: */
044: protected GeoServerResourceLoader loader;
045:
046: protected FeatureTypeSchema(FeatureTypeInfo featureType, WFS wfs,
047: Data catalog, GeoServerResourceLoader loader) {
048: this .featureType = featureType;
049: this .catalog = catalog;
050: this .wfs = wfs;
051: this .loader = loader;
052: }
053:
054: /**
055: * @return The feautre type info.
056: */
057: FeatureTypeInfo getFeatureType() {
058: return featureType;
059: }
060:
061: /**
062: * @return The {@link XSDSchema} representation of the schema.
063: */
064: public XSDSchema schema(String baseUrl) throws IOException {
065: return builder.build(new FeatureTypeInfo[] { featureType },
066: baseUrl);
067: }
068:
069: /**
070: * Converts the schema to a gml2 schema.
071: * @param baseUrl is the prefix-base to use for self-referencing urls.
072: */
073: public FeatureTypeSchema toGML2() {
074: if (this instanceof GML2) {
075: return this ;
076: }
077:
078: return new GML2(featureType, wfs, catalog, loader);
079: }
080:
081: /**
082: * Converts the schema to a gml3 schema.
083: */
084: public FeatureTypeSchema toGML3() {
085: if (this instanceof GML3) {
086: return this ;
087: }
088:
089: return new GML3(featureType, wfs, catalog, loader);
090: }
091:
092: /**
093: * GML2 based wfs feature type schema.
094: *
095: * @author Justin Deoliveira, The Open Planning Project
096: */
097: public static final class GML2 extends FeatureTypeSchema {
098: public GML2(FeatureTypeInfo featureType, WFS wfs, Data catalog,
099: GeoServerResourceLoader loader) {
100: super (featureType, wfs, catalog, loader);
101: builder = new FeatureTypeSchemaBuilder.GML2(wfs, catalog,
102: loader);
103: }
104: }
105:
106: /**
107: * GML3 based wfs feature type schema.
108: *
109: * @author Justin Deoliveira, The Open Planning Project
110: */
111: public static final class GML3 extends FeatureTypeSchema {
112: protected GML3(FeatureTypeInfo featureType, WFS wfs,
113: Data catalog, GeoServerResourceLoader loader) {
114: super (featureType, wfs, catalog, loader);
115: builder = new FeatureTypeSchemaBuilder.GML3(wfs, catalog,
116: loader);
117: }
118: }
119: }
|