0001: /*
0002: * GeoTools - OpenSource mapping toolkit
0003: * http://geotools.org
0004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
0005: *
0006: * This library is free software; you can redistribute it and/or
0007: * modify it under the terms of the GNU Lesser General Public
0008: * License as published by the Free Software Foundation; either
0009: * version 2.1 of the License, or (at your option) any later version.
0010: *
0011: * This library is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014: * Lesser General Public License for more details.
0015: */
0016: package org.geotools.xml.wfs;
0017:
0018: import java.net.MalformedURLException;
0019: import java.net.URI;
0020: import java.net.URL;
0021: import java.util.Arrays;
0022: import java.util.LinkedList;
0023: import java.util.List;
0024: import java.util.Map;
0025:
0026: import javax.naming.OperationNotSupportedException;
0027:
0028: import org.geotools.data.ows.FeatureSetDescription;
0029: import org.geotools.data.ows.OperationType;
0030: import org.geotools.data.ows.Service;
0031: import org.geotools.data.ows.WFSCapabilities;
0032: import org.geotools.filter.FilterCapabilities;
0033: import org.geotools.xml.DocumentFactory;
0034: import org.geotools.xml.PrintHandler;
0035: import org.geotools.xml.filter.FilterSchema;
0036: import org.geotools.xml.filter.FilterComplexTypes.Filter_CapabilitiesType;
0037: import org.geotools.xml.schema.Attribute;
0038: import org.geotools.xml.schema.ComplexType;
0039: import org.geotools.xml.schema.Element;
0040: import org.geotools.xml.schema.ElementGrouping;
0041: import org.geotools.xml.schema.ElementValue;
0042: import org.geotools.xml.schema.Facet;
0043: import org.geotools.xml.schema.SimpleType;
0044: import org.geotools.xml.schema.impl.ChoiceGT;
0045: import org.geotools.xml.schema.impl.FacetGT;
0046: import org.geotools.xml.schema.impl.SequenceGT;
0047: import org.geotools.xml.schema.impl.SimpleTypeGT;
0048: import org.geotools.xml.wfs.WFSSchema.WFSAttribute;
0049: import org.geotools.xml.wfs.WFSSchema.WFSComplexType;
0050: import org.geotools.xml.wfs.WFSSchema.WFSElement;
0051: import org.geotools.xml.xsi.XSISimpleTypes;
0052: import org.xml.sax.Attributes;
0053: import org.xml.sax.SAXException;
0054: import org.xml.sax.SAXNotSupportedException;
0055:
0056: import com.vividsolutions.jts.geom.Envelope;
0057:
0058: /**
0059: * <p>
0060: * DOCUMENT ME!
0061: * </p>
0062: *
0063: * @author Norman Barker www.comsine.com
0064: * @author dzwiers
0065: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wfs/src/main/java/org/geotools/xml/wfs/WFSCapabilitiesComplexTypes.java $
0066: */
0067: public class WFSCapabilitiesComplexTypes {
0068: /**
0069: * <p>
0070: * This class represents an SchemaDescriptionLanguageType within the WFS
0071: * Schema. This includes both the data and parsing functionality
0072: * associated with a SchemaDescriptionLanguageType.
0073: * </p>
0074: *
0075: * @see WFSComplexType
0076: */
0077: static class SchemaDescriptionLanguageType extends WFSComplexType {
0078: // singleton instance
0079: private static final WFSComplexType instance = new SchemaDescriptionLanguageType();
0080:
0081: // static element list
0082: private static final Element[] elements = { new WFSElement(
0083: "XMLSCHEMA", EmptyType.getInstance(), 1,
0084: Integer.MAX_VALUE, false, null) };
0085:
0086: // static sequence
0087: private static final SequenceGT seq = new SequenceGT(elements) {
0088: /**
0089: * @see schema.Choice#getMaxOccurs()
0090: */
0091: public int getMaxOccurs() {
0092: return Integer.MAX_VALUE;
0093: }
0094: };
0095:
0096: public static WFSComplexType getInstance() {
0097: return instance;
0098: }
0099:
0100: /**
0101: * @see org.geotools.xml.schema.ComplexType#getAnyAttributeNameSpace()
0102: */
0103: public String getAnyAttributeNameSpace() {
0104: return null;
0105: }
0106:
0107: /**
0108: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0109: */
0110: public Attribute[] getAttributes() {
0111: return null;
0112: }
0113:
0114: /**
0115: * @see org.geotools.xml.schema.ComplexType#getChild()
0116: */
0117: public ElementGrouping getChild() {
0118: return seq;
0119: }
0120:
0121: /**
0122: * @see org.geotools.xml.schema.Type#getInstanceType()
0123: */
0124: public Class getInstanceType() {
0125: //
0126: return null;
0127: }
0128:
0129: /**
0130: * @see org.geotools.xml.schema.Type#getName()
0131: */
0132: public String getName() {
0133: return "SchemaDescriptionLanguageType";
0134: }
0135:
0136: /**
0137: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0138: */
0139: public Element[] getChildElements() {
0140: return elements;
0141: }
0142:
0143: /**
0144: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0145: * org.geotools.xml.schema.ElementValue[],
0146: * org.xml.sax.Attributes, java.util.Map)
0147: */
0148: public Object getValue(Element element, ElementValue[] value,
0149: Attributes attrs, Map hints) throws SAXException,
0150: SAXNotSupportedException {
0151: if ((element == null) || (value == null)) {
0152: throw new SAXException(
0153: "SchemaDescriptionLanguage had an erro while parsing -- missing input");
0154: }
0155:
0156: if (value.length < 1) {
0157: throw new SAXException(
0158: "too few child elements for SchemaDescriptionLanguage");
0159: }
0160:
0161: boolean found = false;
0162: List results = new LinkedList();
0163:
0164: for (int i = 0; i < value.length; i++) {
0165: if (value[i].getElement() != null) {
0166: if ("XMLSCHEMA".equals(value[i].getElement()
0167: .getName())) {
0168: found = true;
0169: }
0170:
0171: if ((value[i].getElement().getName()) != null) {
0172: results.add(value[i].getElement().getName());
0173: }
0174: }
0175: }
0176:
0177: if (!found) {
0178: throw new SAXException(
0179: "XMLSCHEMA is a required child element, which was not found");
0180: }
0181:
0182: return (results.size() == 0) ? null : results;
0183: }
0184:
0185: /**
0186: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0187: * java.lang.Object, java.util.Map)
0188: */
0189: public boolean canEncode(Element element, Object value,
0190: Map hints) {
0191: //
0192: return false;
0193: }
0194:
0195: /**
0196: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0197: * java.lang.Object, org.geotools.xml.PrintHandler,
0198: * java.util.Map)
0199: */
0200: public void encode(Element element, Object value,
0201: PrintHandler output, Map hints)
0202: throws OperationNotSupportedException {
0203: //
0204: throw new OperationNotSupportedException(
0205: "Method not completed yet.");
0206: }
0207: }
0208:
0209: /**
0210: * <p>
0211: * This class represents an EmptyType within the WFS Schema. This includes
0212: * both the data and parsing functionality associated with a EmptyType.
0213: * </p>
0214: *
0215: * @see WFSComplexType
0216: */
0217: static class EmptyType extends WFSComplexType {
0218: // singleton instance
0219: private static final WFSComplexType instance = new EmptyType();
0220:
0221: public static WFSComplexType getInstance() {
0222: return instance;
0223: }
0224:
0225: /**
0226: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0227: * org.geotools.xml.schema.ElementValue[],
0228: * org.xml.sax.Attributes, java.util.Map)
0229: */
0230: public Object getValue(Element element, ElementValue[] value,
0231: Attributes attrs, Map hints) {
0232: return null;
0233: }
0234:
0235: /**
0236: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0237: * java.lang.Object, java.util.Map)
0238: */
0239: public boolean canEncode(Element element, Object value,
0240: Map hints) {
0241: //
0242: return false;
0243: }
0244:
0245: /**
0246: * @see org.geotools.xml.schema.Type#getInstanceType()
0247: */
0248: public Class getInstanceType() {
0249: return null;
0250: }
0251:
0252: /**
0253: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0254: * java.lang.Object, org.geotools.xml.PrintHandler,
0255: * java.util.Map)
0256: */
0257: public void encode(Element element, Object value,
0258: PrintHandler output, Map hints)
0259: throws OperationNotSupportedException {
0260: //
0261: throw new OperationNotSupportedException(
0262: "Method not completed yet.");
0263: }
0264:
0265: /**
0266: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0267: */
0268: public Attribute[] getAttributes() {
0269: return null;
0270: }
0271:
0272: /**
0273: * @see org.geotools.xml.schema.ComplexType#getChild()
0274: */
0275: public ElementGrouping getChild() {
0276: return null;
0277: }
0278:
0279: /**
0280: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0281: */
0282: public Element[] getChildElements() {
0283: return null;
0284: }
0285:
0286: /**
0287: * @see org.geotools.xml.schema.Type#getName()
0288: */
0289: public String getName() {
0290: return "EmptyType";
0291: }
0292: }
0293:
0294: /**
0295: * <p>
0296: * This class represents an ResultFormatType within the WFS Schema. This
0297: * includes both the data and parsing functionality associated with a
0298: * ResultFormatType.
0299: * </p>
0300: *
0301: * @see WFSComplexType
0302: */
0303: static class ResultFormatType extends WFSComplexType {
0304: // singleton instance
0305: private static final WFSComplexType instance = new ResultFormatType();
0306:
0307: // static element list
0308: private static final Element[] elements = {
0309: new WFSElement("GML2", EmptyType.getInstance(), 1, 1,
0310: false, null),
0311: new WFSElement("GML2-GZIP", EmptyType.getInstance(), 0,
0312: 1, false, null),
0313: new WFSElement("GML2-ZIP", EmptyType.getInstance(), 0,
0314: 1, false, null) };
0315:
0316: // static sequence
0317: private static final SequenceGT seq = new SequenceGT(elements) {
0318: /**
0319: * @see schema.Sequence#getMaxOccurs()
0320: */
0321: public int getMaxOccurs() {
0322: return Integer.MAX_VALUE;
0323: }
0324: };
0325:
0326: public static WFSComplexType getInstance() {
0327: return instance;
0328: }
0329:
0330: /**
0331: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0332: * org.geotools.xml.schema.ElementValue[],
0333: * org.xml.sax.Attributes, java.util.Map)
0334: */
0335: public Object getValue(Element element, ElementValue[] value,
0336: Attributes attrs, Map hints) throws SAXException,
0337: SAXNotSupportedException {
0338: if ((element == null) || (value == null)) {
0339: throw new SAXException(
0340: "Invalid inputs for parsing a GetCapabilitiesType");
0341: }
0342:
0343: boolean validation = true;
0344: if (hints != null
0345: && hints
0346: .containsKey(DocumentFactory.VALIDATION_HINT)) {
0347: Boolean t = (Boolean) hints
0348: .get(DocumentFactory.VALIDATION_HINT);
0349: if (t != null)
0350: validation = t.booleanValue();
0351: }
0352:
0353: if (validation && value.length < 1) {
0354: throw new SAXException(
0355: "Invalid number of inputs for parsing a GetCapabilitiesType");
0356: }
0357:
0358: List l = new LinkedList();
0359:
0360: for (int i = 0; i < value.length; i++) {
0361: if (value[i].getElement().getName() != null) {
0362: l.add(value[i].getElement().getName());
0363: }
0364: }
0365:
0366: return l;
0367: }
0368:
0369: /**
0370: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0371: * java.lang.Object, java.util.Map)
0372: */
0373: public boolean canEncode(Element element, Object value,
0374: Map hints) {
0375: //
0376: return false;
0377: }
0378:
0379: /**
0380: * @see org.geotools.xml.schema.Type#getInstanceType()
0381: */
0382: public Class getInstanceType() {
0383: return List.class;
0384: }
0385:
0386: /**
0387: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0388: * java.lang.Object, org.geotools.xml.PrintHandler,
0389: * java.util.Map)
0390: */
0391: public void encode(Element element, Object value,
0392: PrintHandler output, Map hints)
0393: throws OperationNotSupportedException {
0394: //
0395: throw new OperationNotSupportedException(
0396: "Method not completed yet.");
0397: }
0398:
0399: /**
0400: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0401: */
0402: public Attribute[] getAttributes() {
0403: return null;
0404: }
0405:
0406: /**
0407: * @see org.geotools.xml.schema.ComplexType#getChild()
0408: */
0409: public ElementGrouping getChild() {
0410: return seq;
0411: }
0412:
0413: /**
0414: * @see org.geotools.xml.schema.Type#getName()
0415: */
0416: public String getName() {
0417: return "ResultFormatType";
0418: }
0419:
0420: /**
0421: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0422: */
0423: public Element[] getChildElements() {
0424: return elements;
0425: }
0426: }
0427:
0428: /**
0429: * <p>
0430: * This class represents an OperationsType within the WFS Schema. This
0431: * includes both the data and parsing functionality associated with a
0432: * OperationsType.
0433: * </p>
0434: *
0435: * @see WFSComplexType
0436: */
0437: static class OperationsType extends WFSComplexType {
0438: // singleton instance
0439: private static final WFSComplexType instance = new OperationsType();
0440:
0441: // static element list
0442: private static final Element[] elements = {
0443: new WFSElement("Insert", EmptyType.getInstance(), 1, 1,
0444: false, null),
0445: new WFSElement("Update", EmptyType.getInstance(), 1, 1,
0446: false, null),
0447: new WFSElement("Delete", EmptyType.getInstance(), 1, 1,
0448: false, null),
0449: new WFSElement("Query", EmptyType.getInstance(), 1, 1,
0450: false, null),
0451: new WFSElement("Lock", EmptyType.getInstance(), 1, 1,
0452: false, null), };
0453:
0454: // static sequence
0455: private static final ChoiceGT seq = new ChoiceGT(elements) {
0456: /**
0457: * @see schema.Choice#getMaxOccurs()
0458: */
0459: public int getMaxOccurs() {
0460: return Integer.MAX_VALUE;
0461: }
0462: };
0463:
0464: public static WFSComplexType getInstance() {
0465: return instance;
0466: }
0467:
0468: /**
0469: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0470: * org.geotools.xml.schema.ElementValue[],
0471: * org.xml.sax.Attributes, java.util.Map)
0472: */
0473: public Object getValue(Element element, ElementValue[] value,
0474: Attributes attrs, Map hints) throws SAXException,
0475: SAXNotSupportedException {
0476: if ((element == null) || (value == null)) {
0477: throw new SAXException("missing inputs");
0478: }
0479:
0480: if (value.length < 1) {
0481: throw new SAXException("Too few children");
0482: }
0483:
0484: int t = 0;
0485:
0486: for (int i = 0; i < value.length; i++) {
0487: t = t
0488: | FeatureSetDescription.findOperation(value[i]
0489: .getElement().getName());
0490: }
0491:
0492: return new Integer(t);
0493: }
0494:
0495: /**
0496: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0497: * java.lang.Object, java.util.Map)
0498: */
0499: public boolean canEncode(Element element, Object value,
0500: Map hints) {
0501: //
0502: return false;
0503: }
0504:
0505: /**
0506: * @see org.geotools.xml.schema.Type#getInstanceType()
0507: */
0508: public Class getInstanceType() {
0509: return null;
0510: }
0511:
0512: /**
0513: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0514: * java.lang.Object, org.geotools.xml.PrintHandler,
0515: * java.util.Map)
0516: */
0517: public void encode(Element element, Object value,
0518: PrintHandler output, Map hints)
0519: throws OperationNotSupportedException {
0520: //
0521: throw new OperationNotSupportedException(
0522: "Method not completed yet.");
0523: }
0524:
0525: /**
0526: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0527: */
0528: public Attribute[] getAttributes() {
0529: return null;
0530: }
0531:
0532: /**
0533: * @see org.geotools.xml.schema.ComplexType#getChild()
0534: */
0535: public ElementGrouping getChild() {
0536: return seq;
0537: }
0538:
0539: /**
0540: * @see org.geotools.xml.schema.Type#getName()
0541: */
0542: public String getName() {
0543: return "OperationsType";
0544: }
0545:
0546: /**
0547: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0548: */
0549: public Element[] getChildElements() {
0550: return elements;
0551: }
0552: }
0553:
0554: /**
0555: * <p>
0556: * This class represents an MetadataURLType within the WFS Schema. This
0557: * includes both the data and parsing functionality associated with a
0558: * MetadataURLType.
0559: * </p>
0560: *
0561: * @see WFSComplexType
0562: */
0563: static class MetadataURLType extends WFSComplexType {
0564: // singleton instance
0565: private static final WFSComplexType instance = new MetadataURLType();
0566: private static Attribute[] attributes = {
0567: new WFSAttribute(
0568: "type",
0569: new SimpleTypeGT(
0570: null,
0571: null,
0572: WFSSchema.NAMESPACE,
0573: SimpleType.RESTRICTION,
0574: new SimpleType[] { XSISimpleTypes.NMTOKEN
0575: .getInstance() }, new Facet[] {
0576: new FacetGT(Facet.ENUMERATION,
0577: "TC211"),
0578: new FacetGT(Facet.ENUMERATION,
0579: "FGDC") },
0580: SimpleType.NONE), Attribute.REQUIRED),
0581: new WFSAttribute(
0582: "format",
0583: new SimpleTypeGT(
0584: null,
0585: null,
0586: WFSSchema.NAMESPACE,
0587: SimpleType.RESTRICTION,
0588: new SimpleType[] { XSISimpleTypes.NMTOKEN
0589: .getInstance() }, new Facet[] {
0590: new FacetGT(Facet.ENUMERATION,
0591: "XML"),
0592: new FacetGT(Facet.ENUMERATION,
0593: "SGML"),
0594: new FacetGT(Facet.ENUMERATION,
0595: "TXT") },
0596: SimpleType.NONE), Attribute.REQUIRED) };
0597:
0598: public static WFSComplexType getInstance() {
0599: return instance;
0600: }
0601:
0602: /**
0603: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0604: */
0605: public Attribute[] getAttributes() {
0606: return attributes;
0607: }
0608:
0609: /**
0610: * @see org.geotools.xml.schema.ComplexType#getChild()
0611: */
0612: public ElementGrouping getChild() {
0613: // SimpleContent
0614: return null;
0615: }
0616:
0617: /**
0618: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0619: */
0620: public Element[] getChildElements() {
0621: return null;
0622: }
0623:
0624: /**
0625: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0626: * org.geotools.xml.schema.ElementValue[],
0627: * org.xml.sax.Attributes, java.util.Map)
0628: */
0629: public Object getValue(Element element, ElementValue[] value,
0630: Attributes attrs, Map hints) throws SAXException,
0631: SAXNotSupportedException {
0632: if ((element == null) || (value == null)) {
0633: throw new SAXException(
0634: "Invalid parameters passed into MetadataURL");
0635: }
0636:
0637: if (value.length != 1) {
0638: throw new SAXException(
0639: "Should only have one child value -- the String value of inline text");
0640: }
0641:
0642: // MetadataURL mdurl = new MetadataURL();
0643: // String t = "";
0644: //
0645: // t = attrs.getValue("", "type");
0646: //
0647: // if ((t == null) || "".equals(t)) {
0648: // t = attrs.getValue(WFSSchema.NAMESPACE, "type");
0649: // }
0650: //
0651: // mdurl.setType(MetadataURL.parseType(t));
0652: // t = attrs.getValue("", "format");
0653: //
0654: // if ((t == null) || "".equals(t)) {
0655: // t = attrs.getValue(WFSSchema.NAMESPACE, "format");
0656: // }
0657: //
0658: // mdurl.setFormat(t);
0659: //
0660: // t = (String) value[0].getValue();
0661: //
0662: // URL url = null;
0663: //
0664: // try {
0665: // url = new URL(t);
0666: // } catch (MalformedURLException e) {
0667: // throw new SAXException(e);
0668: // }
0669: //
0670: // mdurl.setOnlineResource(url);
0671: // return mdurl;
0672: return null;
0673: }
0674:
0675: /**
0676: * @see org.geotools.xml.schema.Type#getName()
0677: */
0678: public String getName() {
0679: return "MetadataURLType";
0680: }
0681:
0682: /**
0683: * @see org.geotools.xml.schema.Type#getInstanceType()
0684: */
0685: public Class getInstanceType() {
0686: // return MetadataURL.class;
0687: return null;
0688: }
0689:
0690: /**
0691: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0692: * java.lang.Object, java.util.Map)
0693: */
0694: public boolean canEncode(Element element, Object value,
0695: Map hints) {
0696: //
0697: return false;
0698: }
0699:
0700: /**
0701: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0702: * java.lang.Object, org.geotools.xml.PrintHandler,
0703: * java.util.Map)
0704: */
0705: public void encode(Element element, Object value,
0706: PrintHandler output, Map hints)
0707: throws OperationNotSupportedException {
0708: //
0709: throw new OperationNotSupportedException();
0710: }
0711:
0712: /**
0713: * @see org.geotools.xml.schema.ComplexType#isMixed()
0714: */
0715: public boolean isMixed() {
0716: return true;
0717: }
0718: }
0719:
0720: /**
0721: * <p>
0722: * This class represents an LatLonBoundingBoxType within the WFS Schema.
0723: * This includes both the data and parsing functionality associated with a
0724: * LatLonBoundingBoxType.
0725: * </p>
0726: *
0727: * @see WFSComplexType
0728: */
0729: static class LatLongBoundingBoxType extends WFSComplexType {
0730: // singleton instance
0731: private static final WFSComplexType instance = new LatLongBoundingBoxType();
0732:
0733: // static element list
0734: private static Attribute[] attributes = {
0735: new WFSAttribute("minx", XSISimpleTypes.String
0736: .getInstance(), Attribute.REQUIRED),
0737: new WFSAttribute("miny", XSISimpleTypes.String
0738: .getInstance(), Attribute.REQUIRED),
0739: new WFSAttribute("maxx", XSISimpleTypes.String
0740: .getInstance(), Attribute.REQUIRED),
0741: new WFSAttribute("maxy", XSISimpleTypes.String
0742: .getInstance(), Attribute.REQUIRED) };
0743:
0744: public static WFSComplexType getInstance() {
0745: return instance;
0746: }
0747:
0748: /**
0749: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0750: */
0751: public Attribute[] getAttributes() {
0752: return attributes;
0753: }
0754:
0755: /**
0756: * @see org.geotools.xml.schema.ComplexType#getChild()
0757: */
0758: public ElementGrouping getChild() {
0759: return null;
0760: }
0761:
0762: /**
0763: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0764: */
0765: public Element[] getChildElements() {
0766: return null;
0767: }
0768:
0769: /**
0770: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0771: * org.geotools.xml.schema.ElementValue[],
0772: * org.xml.sax.Attributes, java.util.Map)
0773: */
0774: public Object getValue(Element element, ElementValue[] value,
0775: Attributes attrs, Map hints) throws SAXException,
0776: SAXNotSupportedException {
0777: double minx;
0778: double miny;
0779: double maxx;
0780: double maxy;
0781: minx = miny = maxx = maxy = 0;
0782:
0783: if ((element == null) || (attrs == null)) {
0784: throw new SAXException(
0785: "Invalid parameters for LatLongBoundingBoxType");
0786: }
0787:
0788: String t = "";
0789:
0790: t = attrs.getValue("", "minx");
0791:
0792: if ((t == null) || "".equals(t)) {
0793: t = attrs.getValue(WFSSchema.NAMESPACE.toString(),
0794: "minx");
0795: }
0796:
0797: minx = Double.parseDouble(t);
0798:
0799: t = attrs.getValue("", "maxx");
0800:
0801: if ((t == null) || "".equals(t)) {
0802: t = attrs.getValue(WFSSchema.NAMESPACE.toString(),
0803: "maxx");
0804: }
0805:
0806: maxx = Double.parseDouble(t);
0807:
0808: t = attrs.getValue("", "miny");
0809:
0810: if ((t == null) || "".equals(t)) {
0811: t = attrs.getValue(WFSSchema.NAMESPACE.toString(),
0812: "miny");
0813: }
0814:
0815: miny = Double.parseDouble(t);
0816:
0817: t = attrs.getValue("", "maxy");
0818:
0819: if ((t == null) || "".equals(t)) {
0820: t = attrs.getValue(WFSSchema.NAMESPACE.toString(),
0821: "maxy");
0822: }
0823:
0824: maxy = Double.parseDouble(t);
0825:
0826: return new Envelope(minx, maxx, miny, maxy);
0827: }
0828:
0829: /**
0830: * @see org.geotools.xml.schema.Type#getName()
0831: */
0832: public String getName() {
0833: return "LatLonBoundingBoxType";
0834: }
0835:
0836: /**
0837: * @see org.geotools.xml.schema.Type#getInstanceType()
0838: */
0839: public Class getInstanceType() {
0840: return Envelope.class;
0841: }
0842:
0843: /**
0844: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0845: * java.lang.Object, java.util.Map)
0846: */
0847: public boolean canEncode(Element element, Object value,
0848: Map hints) {
0849: //
0850: return false;
0851: }
0852:
0853: /**
0854: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0855: * java.lang.Object, org.geotools.xml.PrintHandler,
0856: * java.util.Map)
0857: */
0858: public void encode(Element element, Object value,
0859: PrintHandler output, Map hints)
0860: throws OperationNotSupportedException {
0861: //
0862: throw new OperationNotSupportedException();
0863: }
0864: }
0865:
0866: /**
0867: * <p>
0868: * This class represents an PostType within the WFS Schema. This includes
0869: * both the data and parsing functionality associated with a PostType.
0870: * </p>
0871: *
0872: * @see WFSComplexType
0873: */
0874: static class PostType extends WFSComplexType {
0875: // singleton instance
0876: private static final WFSComplexType instance = new PostType();
0877:
0878: /**
0879: * @see org.geotools.xml.schema.ComplexType#findChildElement(java.lang.String)
0880: */
0881:
0882: // static list of attributes
0883: private static Attribute[] attributes = { new WFSAttribute(
0884: "onlineResource", XSISimpleTypes.String.getInstance(),
0885: Attribute.REQUIRED) };
0886:
0887: public static WFSComplexType getInstance() {
0888: return instance;
0889: }
0890:
0891: /**
0892: * @see org.geotools.xml.schema.ComplexType#getAttributes()
0893: */
0894: public Attribute[] getAttributes() {
0895: return attributes;
0896: }
0897:
0898: /**
0899: * @see org.geotools.xml.schema.ComplexType#getChild()
0900: */
0901: public ElementGrouping getChild() {
0902: return null;
0903: }
0904:
0905: /**
0906: * @see org.geotools.xml.schema.ComplexType#getChildElements()
0907: */
0908: public Element[] getChildElements() {
0909: return null;
0910: }
0911:
0912: /**
0913: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
0914: * org.geotools.xml.schema.ElementValue[],
0915: * org.xml.sax.Attributes, java.util.Map)
0916: */
0917: public Object getValue(Element element, ElementValue[] value,
0918: Attributes attrs, Map hints) {
0919: String s = attrs.getValue("", "onlineResource");
0920:
0921: if ((s == null) || "".equals(s)) {
0922: s = attrs.getValue(WFSSchema.NAMESPACE.toString(),
0923: "onlineResource");
0924: }
0925:
0926: try {
0927: return new URL(s);
0928: } catch (MalformedURLException e) {
0929: return null;
0930: }
0931: }
0932:
0933: /**
0934: * @see org.geotools.xml.schema.Type#getName()
0935: */
0936: public String getName() {
0937: return "PostType";
0938: }
0939:
0940: /**
0941: * @see org.geotools.xml.schema.Type#getInstanceType()
0942: */
0943: public Class getInstanceType() {
0944: return URL.class;
0945: }
0946:
0947: /**
0948: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0949: * java.lang.Object, java.util.Map)
0950: */
0951: public boolean canEncode(Element element, Object value,
0952: Map hints) {
0953: //
0954: return false;
0955: }
0956:
0957: /**
0958: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0959: * java.lang.Object, org.geotools.xml.PrintHandler,
0960: * java.util.Map)
0961: */
0962: public void encode(Element element, Object value,
0963: PrintHandler output, Map hints)
0964: throws OperationNotSupportedException {
0965: //
0966: throw new OperationNotSupportedException();
0967: }
0968: }
0969:
0970: /**
0971: * <p>
0972: * This class represents an HTTPType within the WFS Schema. This includes
0973: * both the data and parsing functionality associated with a HTTPType.
0974: * </p>
0975: *
0976: * @see WFSComplexType
0977: */
0978: static class HTTPType extends WFSComplexType {
0979: // singleton instance
0980: private static final WFSComplexType instance = new HTTPType();
0981:
0982: // static element list
0983: private static final Element[] elements = {
0984: new WFSElement("Get", GetType.getInstance(), 0,
0985: Integer.MAX_VALUE, false, null),
0986: new WFSElement("Post", PostType.getInstance(), 0,
0987: Integer.MAX_VALUE, false, null) };
0988:
0989: // static sequence
0990: private static final ChoiceGT seq = new ChoiceGT(elements) {
0991: /**
0992: * @see schema.Choice#getMaxOccurs()
0993: */
0994: public int getMaxOccurs() {
0995: return Integer.MAX_VALUE;
0996: }
0997: };
0998:
0999: /**
1000: * @see org.geotools.xml.schema.Type#getName()
1001: */
1002: public String getName() {
1003: return "HTTPType";
1004: }
1005:
1006: public static WFSComplexType getInstance() {
1007: return instance;
1008: }
1009:
1010: /**
1011: * @see org.geotools.xml.schema.ComplexType#getAttributes()
1012: */
1013: public Attribute[] getAttributes() {
1014: return null;
1015: }
1016:
1017: /**
1018: * @see org.geotools.xml.schema.ComplexType#getChild()
1019: */
1020: public ElementGrouping getChild() {
1021: return seq;
1022: }
1023:
1024: /**
1025: * @see org.geotools.xml.schema.ComplexType#getChildElements()
1026: */
1027: public Element[] getChildElements() {
1028: return elements;
1029: }
1030:
1031: /**
1032: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1033: * org.geotools.xml.schema.ElementValue[],
1034: * org.xml.sax.Attributes, java.util.Map)
1035: */
1036: public Object getValue(Element element, ElementValue[] value,
1037: Attributes attrs, Map hints) throws SAXException,
1038: SAXNotSupportedException {
1039: if ((element == null) || (value == null)) {
1040: throw new SAXException(
1041: "Error occured in HTTPType: both an element and value param is required");
1042: }
1043:
1044: if (value.length < 1) {
1045: throw new SAXException(
1046: "Must have atleast one http type defined.");
1047: }
1048:
1049: OperationType c = new OperationType();
1050:
1051: for (int i = 0; i < value.length; i++) {
1052: if ((value[i].getElement() != null)
1053: && value[i].getElement().getName().equals(
1054: elements[0].getName())) {
1055: // get
1056: c.setGet((URL) value[i].getValue());
1057: }
1058:
1059: if ((value[i].getElement() != null)
1060: && value[i].getElement().getName().equals(
1061: elements[1].getName())) {
1062: // post
1063: c.setPost((URL) value[i].getValue());
1064: }
1065: }
1066:
1067: return c;
1068: }
1069:
1070: /**
1071: * @see org.geotools.xml.schema.Type#getInstanceType()
1072: */
1073: public Class getInstanceType() {
1074: return OperationType.class;
1075: }
1076:
1077: /**
1078: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1079: * java.lang.Object, java.util.Map)
1080: */
1081: public boolean canEncode(Element element, Object value,
1082: Map hints) {
1083: //
1084: return false;
1085: }
1086:
1087: /**
1088: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1089: * java.lang.Object, org.geotools.xml.PrintHandler,
1090: * java.util.Map)
1091: */
1092: public void encode(Element element, Object value,
1093: PrintHandler output, Map hints)
1094: throws OperationNotSupportedException {
1095: //
1096: throw new OperationNotSupportedException();
1097: }
1098: }
1099:
1100: /**
1101: * <p>
1102: * This class represents an GetType within the WFS Schema. This includes
1103: * both the data and parsing functionality associated with a GetType.
1104: * </p>
1105: *
1106: * @see WFSComplexType
1107: */
1108: static class GetType extends WFSComplexType {
1109: // singleton instance
1110: private static final WFSComplexType instance = new GetType();
1111:
1112: // static list of attributes
1113: private static Attribute[] attributes = { new WFSAttribute(
1114: "onlineResource", XSISimpleTypes.String.getInstance(),
1115: Attribute.REQUIRED) };
1116:
1117: public static WFSComplexType getInstance() {
1118: return instance;
1119: }
1120:
1121: /**
1122: * @see org.geotools.xml.schema.ComplexType#getAttributes()
1123: */
1124: public Attribute[] getAttributes() {
1125: return attributes;
1126: }
1127:
1128: /**
1129: * @see org.geotools.xml.schema.ComplexType#getChild()
1130: */
1131: public ElementGrouping getChild() {
1132: return null;
1133: }
1134:
1135: /**
1136: * @see org.geotools.xml.schema.ComplexType#getChildElements()
1137: */
1138: public Element[] getChildElements() {
1139: return null;
1140: }
1141:
1142: /**
1143: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1144: * org.geotools.xml.schema.ElementValue[],
1145: * org.xml.sax.Attributes, java.util.Map)
1146: */
1147: public Object getValue(Element element, ElementValue[] value,
1148: Attributes attrs, Map hints) {
1149: String s = attrs.getValue("", "onlineResource");
1150:
1151: if ((s == null) || "".equals(s)) {
1152: s = attrs.getValue(WFSSchema.NAMESPACE.toString(),
1153: "onlineResource");
1154: }
1155:
1156: try {
1157: return new URL(s);
1158: } catch (MalformedURLException e) {
1159: return null;
1160: }
1161: }
1162:
1163: /**
1164: * @see org.geotools.xml.schema.Type#getName()
1165: */
1166: public String getName() {
1167: return "GetType";
1168: }
1169:
1170: /**
1171: * @see org.geotools.xml.schema.Type#getInstanceType()
1172: */
1173: public Class getInstanceType() {
1174: return URL.class;
1175: }
1176:
1177: /**
1178: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1179: * java.lang.Object, java.util.Map)
1180: */
1181: public boolean canEncode(Element element, Object value,
1182: Map hints) {
1183: //
1184: return false;
1185: }
1186:
1187: /**
1188: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1189: * java.lang.Object, org.geotools.xml.PrintHandler,
1190: * java.util.Map)
1191: */
1192: public void encode(Element element, Object value,
1193: PrintHandler output, Map hints)
1194: throws OperationNotSupportedException {
1195: //
1196: throw new OperationNotSupportedException();
1197: }
1198: }
1199:
1200: /**
1201: * <p>
1202: * This class represents an FeatureTypeType within the WFS Schema. This
1203: * includes both the data and parsing functionality associated with a
1204: * FeatureTypeType.
1205: * </p>
1206: *
1207: * @see WFSComplexType
1208: */
1209: static class FeatureTypeType extends WFSComplexType {
1210: // singleton instance
1211: private static final WFSComplexType instance = new FeatureTypeType();
1212:
1213: // static element list
1214: private static final Element[] elements = {
1215: new WFSElement("Name", XSISimpleTypes.QName
1216: .getInstance(), 1, 1, false, null),
1217: new WFSElement("Title", XSISimpleTypes.String
1218: .getInstance(), 0, 1, false, null),
1219: new WFSElement("Abstract", XSISimpleTypes.String
1220: .getInstance(), 0, 1, false, null),
1221: new WFSElement("Keywords", XSISimpleTypes.String
1222: .getInstance(), 0, 1, false, null),
1223: new WFSElement("SRS", XSISimpleTypes.String
1224: .getInstance(), 1, 1, false, null),
1225: new WFSElement("Operations", OperationsType
1226: .getInstance(), 0, 1, false, null),
1227: new WFSElement("LatLongBoundingBox",
1228: LatLongBoundingBoxType.getInstance(), 0,
1229: Integer.MAX_VALUE, false, null),
1230: new WFSElement("MetadataURL", MetadataURLType
1231: .getInstance(), 0, Integer.MAX_VALUE, false,
1232: null) };
1233:
1234: // static sequence
1235: private static final SequenceGT seq = new SequenceGT(elements);
1236:
1237: /**
1238: * @see org.geotools.xml.schema.Type#getName()
1239: */
1240: public String getName() {
1241: return "FeatureTypeType";
1242: }
1243:
1244: public static WFSComplexType getInstance() {
1245: return instance;
1246: }
1247:
1248: /**
1249: * @see org.geotools.xml.schema.ComplexType#getAttributes()
1250: */
1251: public Attribute[] getAttributes() {
1252: return null;
1253: }
1254:
1255: /**
1256: * @see org.geotools.xml.schema.ComplexType#getChild()
1257: */
1258: public ElementGrouping getChild() {
1259: return seq;
1260: }
1261:
1262: /**
1263: * @see org.geotools.xml.schema.ComplexType#getChildElements()
1264: */
1265: public Element[] getChildElements() {
1266: return elements;
1267: }
1268:
1269: /**
1270: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1271: * org.geotools.xml.schema.ElementValue[],
1272: * org.xml.sax.Attributes, java.util.Map)
1273: */
1274: public Object getValue(Element element, ElementValue[] value,
1275: Attributes attrs, Map hints) throws SAXException,
1276: SAXNotSupportedException {
1277: if ((element == null) || (value == null)) {
1278: throw new SAXException(
1279: "Missing params for FeatureTypeType");
1280: }
1281:
1282: boolean validation = true;
1283: if (hints != null
1284: && hints
1285: .containsKey(DocumentFactory.VALIDATION_HINT)) {
1286: Boolean t = (Boolean) hints
1287: .get(DocumentFactory.VALIDATION_HINT);
1288: if (t != null)
1289: validation = t.booleanValue();
1290: }
1291:
1292: if (validation && value.length < 2) {
1293: throw new SAXException(
1294: "Missing child element for FeatureTypeType");
1295: }
1296:
1297: FeatureSetDescription fsd = new FeatureSetDescription();
1298: List llbb = new LinkedList();
1299:
1300: for (int i = 0; i < value.length; i++) {
1301: if (value[i].getElement() == null) {
1302: throw new SAXException(
1303: "Internal error -- a value object representing a child element was missing an element declaration");
1304: }
1305:
1306: if (elements[0].getName().equals(
1307: value[i].getElement().getName())) {
1308: // Name
1309: fsd.setName((String) value[i].getValue());
1310: if (fsd.getName() != null) {
1311: int j = fsd.getName().indexOf(":");
1312: if (j > 0) {
1313: // we have a ns prefix
1314: String prefix = fsd.getName().substring(0,
1315: j);
1316: }
1317: }
1318: } else {
1319: if (elements[1].getName().equals(
1320: value[i].getElement().getName())) {
1321: // Title
1322: fsd.setTitle((String) value[i].getValue());
1323: } else {
1324: if (elements[2].getName().equals(
1325: value[i].getElement().getName())) {
1326: // Abstract
1327: String t = (String) value[i].getValue();
1328: t = "NONE".equals(t) ? "" : t;
1329: fsd.setAbstract(t);
1330: } else {
1331: if (elements[3].getName().equals(
1332: value[i].getElement().getName())) {
1333: // Keywords
1334: String t = (String) value[i].getValue();
1335: t = (t == null) ? "" : t;
1336: fsd.setKeywords(Arrays.asList(t
1337: .split(" ")));
1338: } else {
1339: if (elements[4].getName()
1340: .equals(
1341: value[i].getElement()
1342: .getName())) {
1343: // SRS
1344: fsd.setSRS((String) value[i]
1345: .getValue());
1346: } else {
1347: if (elements[5].getName().equals(
1348: value[i].getElement()
1349: .getName())) {
1350: // Operations
1351: fsd
1352: .setOperations(((Integer) value[i]
1353: .getValue())
1354: .intValue());
1355: } else {
1356: if (elements[6]
1357: .getName()
1358: .equals(
1359: value[i]
1360: .getElement()
1361: .getName())) {
1362: // LatLongBoundingBox
1363: llbb.add(value[i]
1364: .getValue());
1365: } else {
1366: if (elements[7]
1367: .getName()
1368: .equals(
1369: value[i]
1370: .getElement()
1371: .getName())) {
1372: // MetadataURL
1373: // mdurl.add((MetadataURL) value[i]
1374: // .getValue());
1375: } else {
1376: // error
1377: throw new SAXException(
1378: "Unknown child element within a FeatureTypeType: "
1379: + ((value[i]
1380: .getElement()
1381: .getName() == null) ? "null"
1382: : value[i]
1383: .getElement()
1384: .getName()));
1385: }
1386: }
1387: }
1388: }
1389: }
1390: }
1391: }
1392: }
1393: }
1394:
1395: if (llbb.size() > 0) {
1396: Envelope e = (Envelope) llbb.get(0);
1397:
1398: for (int i = 1; i < llbb.size(); i++)
1399: e.expandToInclude((Envelope) llbb.get(i));
1400:
1401: fsd.setLatLongBoundingBox(e);
1402: }
1403: if ((fsd.getName() == null) || (fsd.getSRS() == null)) {
1404: throw new SAXException(
1405: "Missing child element for FeatureTypeType");
1406: }
1407:
1408: return fsd;
1409: }
1410:
1411: /**
1412: * @see org.geotools.xml.schema.Type#getInstanceType()
1413: */
1414: public Class getInstanceType() {
1415: return FeatureSetDescription.class;
1416: }
1417:
1418: /**
1419: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1420: * java.lang.Object, java.util.Map)
1421: */
1422: public boolean canEncode(Element element, Object value,
1423: Map hints) {
1424: //
1425: return false;
1426: }
1427:
1428: /**
1429: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1430: * java.lang.Object, org.geotools.xml.PrintHandler,
1431: * java.util.Map)
1432: */
1433: public void encode(Element element, Object value,
1434: PrintHandler output, Map hints)
1435: throws OperationNotSupportedException {
1436: //
1437: throw new OperationNotSupportedException();
1438: }
1439: }
1440:
1441: /**
1442: * <p>
1443: * This class represents an DCPTypeType within the WFS Schema. This
1444: * includes both the data and parsing functionality associated with a
1445: * DCPTypeType.
1446: * </p>
1447: *
1448: * @see WFSComplexType
1449: */
1450: static class DCPTypeType extends WFSComplexType {
1451: // singleton instance
1452: private static final WFSComplexType instance = new DCPTypeType();
1453:
1454: // static element list
1455: private static final Element[] elements = { new WFSElement(
1456: "HTTP", HTTPType.getInstance(), 1, 1, false, null) };
1457:
1458: // static sequence
1459: private static final SequenceGT seq = new SequenceGT(elements);
1460:
1461: public static WFSComplexType getInstance() {
1462: return instance;
1463: }
1464:
1465: /**
1466: * @see org.geotools.xml.schema.Type#getName()
1467: */
1468: public String getName() {
1469: return "DCPTypeType";
1470: }
1471:
1472: /**
1473: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1474: * org.geotools.xml.schema.ElementValue[],
1475: * org.xml.sax.Attributes)
1476: */
1477: public Object getValue(Element element, ElementValue[] value,
1478: Attributes attrs, Map hints) throws SAXException,
1479: SAXNotSupportedException {
1480: Element e = value[0].getElement();
1481:
1482: if ((e == null) || (value == null)) {
1483: throw new SAXException(
1484: "Internal error, ElementValues require an associated Element.");
1485: }
1486:
1487: if (value.length != 1) {
1488: throw new SAXException(
1489: "Wrong number of elements for DCPType");
1490: }
1491:
1492: return (OperationType) value[0].getValue();
1493: }
1494:
1495: /**
1496: * @see org.geotools.xml.schema.ComplexType#getAttributes()
1497: */
1498: public Attribute[] getAttributes() {
1499: return null;
1500: }
1501:
1502: /**
1503: * @see org.geotools.xml.schema.ComplexType#getChild()
1504: */
1505: public ElementGrouping getChild() {
1506: return seq;
1507: }
1508:
1509: /**
1510: * @see org.geotools.xml.schema.ComplexType#getChildElements()
1511: */
1512: public Element[] getChildElements() {
1513: return elements;
1514: }
1515:
1516: /**
1517: * @see org.geotools.xml.schema.Type#getInstanceType()
1518: */
1519: public Class getInstanceType() {
1520: return OperationType.class;
1521: }
1522:
1523: /**
1524: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1525: * java.lang.Object, java.util.Map)
1526: */
1527: public boolean canEncode(Element element, Object value,
1528: Map hints) {
1529: //
1530: return false;
1531: }
1532:
1533: /**
1534: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1535: * java.lang.Object, org.geotools.xml.PrintHandler,
1536: * java.util.Map)
1537: */
1538: public void encode(Element element, Object value,
1539: PrintHandler output, Map hints)
1540: throws OperationNotSupportedException {
1541: //
1542: throw new OperationNotSupportedException();
1543: }
1544: }
1545:
1546: /**
1547: * <p>
1548: * This class represents an LockFeatureTypeType within the WFS Schema. This
1549: * includes both the data and parsing functionality associated with a
1550: * LockFeatureTypeType.
1551: * </p>
1552: *
1553: * @see WFSComplexType
1554: */
1555: static class LockFeatureTypeType extends WFSComplexType {
1556: // singleton instance
1557: private static final WFSComplexType instance = new LockFeatureTypeType();
1558:
1559: // static element list
1560: private static final Element[] elements = { new WFSElement(
1561: "DCPType", DCPTypeType.getInstance(), 1,
1562: Integer.MAX_VALUE, false, null) };
1563:
1564: // static sequence
1565: private static final SequenceGT seq = new SequenceGT(elements);
1566:
1567: public static WFSComplexType getInstance() {
1568: return instance;
1569: }
1570:
1571: /**
1572: * @see org.geotools.xml.schema.ComplexType#getChild()
1573: */
1574: public ElementGrouping getChild() {
1575: return seq;
1576: }
1577:
1578: /**
1579: * @see org.geotools.xml.schema.ComplexType#getAttributes()
1580: */
1581: public Attribute[] getAttributes() {
1582: return null;
1583: }
1584:
1585: /**
1586: * @see org.geotools.xml.schema.ComplexType#getChildElements()
1587: */
1588: public Element[] getChildElements() {
1589: return elements;
1590: }
1591:
1592: /**
1593: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1594: * org.geotools.xml.schema.ElementValue[],
1595: * org.xml.sax.Attributes, java.util.Map)
1596: */
1597: public Object getValue(Element element, ElementValue[] value,
1598: Attributes attrs, Map hints) throws SAXException,
1599: SAXNotSupportedException {
1600: if ((element == null) || (value == null)) {
1601: throw new SAXException(
1602: "Invalid inputs for parsing a GetCapabilitiesType");
1603: }
1604:
1605: if (value.length < 1) {
1606: throw new SAXException(
1607: "Invalid number of inputs for parsing a GetCapabilitiesType");
1608: }
1609:
1610: OperationType[] c = new OperationType[value.length];
1611:
1612: for (int i = 0; i < value.length; i++) {
1613: c[i] = (OperationType) value[i].getValue();
1614:
1615: // c[i].setType(OperationType.LOCK_FEATURE);
1616: }
1617:
1618: return c;
1619: }
1620:
1621: /**
1622: * @see org.geotools.xml.schema.Type#getName()
1623: */
1624: public String getName() {
1625: return "LockFeatureTypeType";
1626: }
1627:
1628: /**
1629: * @see org.geotools.xml.schema.Type#getInstanceType()
1630: */
1631: public Class getInstanceType() {
1632: return OperationType[].class;
1633: }
1634:
1635: /**
1636: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1637: * java.lang.Object, java.util.Map)
1638: */
1639: public boolean canEncode(Element element, Object value,
1640: Map hints) {
1641: //
1642: return false;
1643: }
1644:
1645: /**
1646: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1647: * java.lang.Object, org.geotools.xml.PrintHandler,
1648: * java.util.Map)
1649: */
1650: public void encode(Element element, Object value,
1651: PrintHandler output, Map hints)
1652: throws OperationNotSupportedException {
1653: //
1654: throw new OperationNotSupportedException();
1655: }
1656: }
1657:
1658: /**
1659: * <p>
1660: * This class represents an RequestType within the WFS Schema. This
1661: * includes both the data and parsing functionality associated with a
1662: * RequestType.
1663: * </p>
1664: *
1665: * @see WFSComplexType
1666: */
1667: static class RequestType extends WFSComplexType {
1668: // singleton instance
1669: private static final WFSComplexType instance = new RequestType();
1670:
1671: // static element list
1672: private static final Element[] elements = {
1673: new WFSElement("GetCapabilities", GetCapabilitiesType
1674: .getInstance(), 1, 1, false, null),
1675: new WFSElement("DescribeFeatureType",
1676: DescribeFeatureTypeType.getInstance(), 1, 1,
1677: false, null),
1678: new WFSElement("Transaction", TransactionType
1679: .getInstance(), 1, Integer.MAX_VALUE, false,
1680: null),
1681: new WFSElement("GetFeature", GetFeatureTypeType
1682: .getInstance(), 1, 1, false, null),
1683: new WFSElement("GetFeatureWithLock", GetFeatureTypeType
1684: .getInstance(), 1, 1, false, null),
1685: new WFSElement("LockFeature", LockFeatureTypeType
1686: .getInstance(), 1, 1, false, null) };
1687:
1688: // static sequence
1689: private static final ChoiceGT seq = new ChoiceGT(elements) {
1690: /**
1691: * @see schema.Choice#getMaxOccurs()
1692: */
1693: public int getMaxOccurs() {
1694: return Integer.MAX_VALUE;
1695: }
1696: };
1697:
1698: public static WFSComplexType getInstance() {
1699: return instance;
1700: }
1701:
1702: /**
1703: * @see org.geotools.xml.schema.ComplexType#getChild()
1704: */
1705: public ElementGrouping getChild() {
1706: return seq;
1707: }
1708:
1709: /**
1710: * @see org.geotools.xml.schema.ComplexType#getAttributes()
1711: */
1712: public Attribute[] getAttributes() {
1713: return null;
1714: }
1715:
1716: /**
1717: * @see org.geotools.xml.schema.ComplexType#getChildElements()
1718: */
1719: public Element[] getChildElements() {
1720: return elements;
1721: }
1722:
1723: /**
1724: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
1725: * org.geotools.xml.schema.ElementValue[],
1726: * org.xml.sax.Attributes, java.util.Map)
1727: */
1728: public Object getValue(Element element, ElementValue[] value,
1729: Attributes attrs, Map hints) throws SAXException,
1730: SAXNotSupportedException {
1731: if (element == null) {
1732: throw new SAXException(
1733: "Element cannot be null -- we should know what we are parsing");
1734: }
1735:
1736: if ((value == null) || (value.length == 0)) {
1737: throw new SAXException(
1738: "We need atleast one value to parse a wfs:RequestType");
1739: }
1740:
1741: OperationType[] result = new OperationType[6];
1742:
1743: for (int i = 0; i < value.length; i++) {
1744: OperationType[] t = (OperationType[]) value[i]
1745: .getValue();
1746:
1747: if (t != null) {
1748: if (elements[0].getName().equals(
1749: value[i].getElement().getName())) {
1750: if (result[0] == null) {
1751: result[0] = new OperationType();
1752: }
1753:
1754: // merge them
1755: for (int j = 0; j < t.length; j++) {
1756: if ((result[0].getGet() == null)
1757: && (t[j].getGet() != null)) {
1758: result[0].setGet(t[j].getGet());
1759: }
1760:
1761: if ((result[0].getPost() == null)
1762: && (t[j].getPost() != null)) {
1763: result[0].setPost(t[j].getPost());
1764: }
1765: }
1766: } else {
1767: if (elements[1].getName().equals(
1768: value[i].getElement().getName())) {
1769: if (result[1] == null) {
1770: result[1] = new OperationType();
1771: }
1772:
1773: // merge them
1774: for (int j = 0; j < t.length; j++) {
1775: if ((result[1].getGet() == null)
1776: && (t[j].getGet() != null)) {
1777: result[1].setGet(t[j].getGet());
1778: }
1779:
1780: if ((result[1].getPost() == null)
1781: && (t[j].getPost() != null)) {
1782: result[1].setPost(t[j].getPost());
1783: }
1784:
1785: if (t[j].getFormats() != null) {
1786: if (result[1].getFormats() == null) {
1787: result[1].setFormats(t[j]
1788: .getFormats());
1789: } else {
1790: List st = result[0]
1791: .getFormats();
1792:
1793: if (t[j].getFormats() == null) {
1794: t[j].setFormats(st);
1795: } else if (st != null) {
1796: t[j].getFormats()
1797: .addAll(st);
1798: }
1799: }
1800: }
1801: }
1802: } else {
1803: if (elements[2].getName().equals(
1804: value[i].getElement().getName())) {
1805: if (result[2] == null) {
1806: result[2] = new OperationType();
1807: }
1808:
1809: // merge them
1810: for (int j = 0; j < t.length; j++) {
1811: if ((result[2].getGet() == null)
1812: && (t[j].getGet() != null)) {
1813: result[2].setGet(t[j].getGet());
1814: }
1815:
1816: if ((result[2].getPost() == null)
1817: && (t[j].getPost() != null)) {
1818: result[2].setPost(t[j]
1819: .getPost());
1820: }
1821: }
1822: } else {
1823: if (elements[3].getName()
1824: .equals(
1825: value[i].getElement()
1826: .getName())) {
1827: if (result[3] == null) {
1828: result[3] = new OperationType();
1829: }
1830:
1831: // merge them
1832: for (int j = 0; j < t.length; j++) {
1833: if ((result[3].getGet() == null)
1834: && (t[j].getGet() != null)) {
1835: result[3].setGet(t[j]
1836: .getGet());
1837: }
1838:
1839: if ((result[3].getPost() == null)
1840: && (t[j].getPost() != null)) {
1841: result[3].setPost(t[j]
1842: .getPost());
1843: }
1844:
1845: if (t[j].getFormats() != null) {
1846: if (result[3].getFormats() == null) {
1847: result[3]
1848: .setFormats(t[j]
1849: .getFormats());
1850: } else {
1851: List st = (List) result[0]
1852: .getFormats();
1853:
1854: if (t[j].getFormats() == null) {
1855: t[j].setFormats(st);
1856: } else if (st != null) {
1857: ((List) t[j]
1858: .getFormats())
1859: .addAll(st);
1860: }
1861: }
1862: }
1863: }
1864: } else {
1865: if (elements[4].getName().equals(
1866: value[i].getElement()
1867: .getName())) {
1868: if (result[4] == null) {
1869: result[4] = new OperationType();
1870: }
1871:
1872: // merge them
1873: for (int j = 0; j < t.length; j++) {
1874: if ((result[4].getGet() == null)
1875: && (t[j].getGet() != null)) {
1876: result[4].setGet(t[j]
1877: .getGet());
1878: }
1879:
1880: if ((result[4].getPost() == null)
1881: && (t[j].getPost() != null)) {
1882: result[4].setPost(t[j]
1883: .getPost());
1884: }
1885:
1886: if (t[j].getFormats() != null) {
1887: if (result[4]
1888: .getFormats() == null) {
1889: result[4]
1890: .setFormats(t[j]
1891: .getFormats());
1892: } else {
1893: List st = (List) result[0]
1894: .getFormats();
1895:
1896: if (t[j]
1897: .getFormats() == null) {
1898: t[j]
1899: .setFormats(st);
1900: } else if (st != null) {
1901: ((List) t[j]
1902: .getFormats())
1903: .addAll(st);
1904: }
1905: }
1906: }
1907: }
1908: } else {
1909: if (elements[5]
1910: .getName()
1911: .equals(
1912: value[i]
1913: .getElement()
1914: .getName())) {
1915: if (result[5] == null) {
1916: result[5] = new OperationType();
1917: }
1918:
1919: // merge them
1920: for (int j = 0; j < t.length; j++) {
1921: if ((result[5].getGet() == null)
1922: && (t[j]
1923: .getGet() != null)) {
1924: result[5]
1925: .setGet(t[j]
1926: .getGet());
1927: }
1928:
1929: if ((result[5]
1930: .getPost() == null)
1931: && (t[j]
1932: .getPost() != null)) {
1933: result[5]
1934: .setPost(t[j]
1935: .getPost());
1936: }
1937: }
1938: } else {
1939: // error
1940: throw new SAXException(
1941: "Unknown child element "
1942: + value[i]
1943: .getElement()
1944: .getName()
1945: + " found in RequestType");
1946: }
1947: }
1948: }
1949: }
1950: }
1951: }
1952: }
1953: }
1954:
1955: return result;
1956: }
1957:
1958: /**
1959: * @see org.geotools.xml.schema.Type#getName()
1960: */
1961: public String getName() {
1962: return "RequestType";
1963: }
1964:
1965: /**
1966: * @see org.geotools.xml.schema.Type#getInstanceType()
1967: */
1968: public Class getInstanceType() {
1969: return OperationType[].class;
1970: }
1971:
1972: /**
1973: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
1974: * java.lang.Object, java.util.Map)
1975: */
1976: public boolean canEncode(Element element, Object value,
1977: Map hints) {
1978: //
1979: return false;
1980: }
1981:
1982: /**
1983: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
1984: * java.lang.Object, org.geotools.xml.PrintHandler,
1985: * java.util.Map)
1986: */
1987: public void encode(Element element, Object value,
1988: PrintHandler output, Map hints)
1989: throws OperationNotSupportedException {
1990: //
1991: throw new OperationNotSupportedException();
1992: }
1993: }
1994:
1995: /**
1996: * <p>
1997: * This class represents an ServiceType within the WFS Schema. This
1998: * includes both the data and parsing functionality associated with a
1999: * ServiceType .
2000: * </p>
2001: *
2002: * @see WFSComplexType
2003: */
2004: static class ServiceType extends WFSComplexType {
2005: // singleton instance
2006: private static final WFSComplexType instance = new ServiceType();
2007:
2008: // static element list
2009: private static final Element[] elements = {
2010: new WFSElement("Name", XSISimpleTypes.String
2011: .getInstance(), 1, 1, false, null),
2012: new WFSElement("Title", XSISimpleTypes.String
2013: .getInstance(), 1, 1, false, null),
2014: new WFSElement("Abstract", XSISimpleTypes.String
2015: .getInstance(), 0, 1, false, null),
2016: new WFSElement("Keywords", XSISimpleTypes.String
2017: .getInstance(), 0, 1, false, null),
2018: new WFSElement("OnlineResource", XSISimpleTypes.AnyURI
2019: .getInstance(), 1, 1, false, null),
2020: new WFSElement("Fees", XSISimpleTypes.String
2021: .getInstance(), 0, 1, false, null),
2022: new WFSElement("AccessConstraints",
2023: XSISimpleTypes.String.getInstance(), 0, 1,
2024: false, null) };
2025:
2026: // static choice
2027: private static final SequenceGT seq = new SequenceGT(elements);
2028:
2029: public static WFSComplexType getInstance() {
2030: return instance;
2031: }
2032:
2033: /**
2034: * @see org.geotools.xml.schema.Type#getInstanceType()
2035: */
2036: public Class getInstanceType() {
2037: return Service.class;
2038: }
2039:
2040: /**
2041: * @see org.geotools.xml.schema.Type#getName()
2042: */
2043: public String getName() {
2044: return "ServiceType";
2045: }
2046:
2047: /**
2048: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2049: * org.geotools.xml.schema.ElementValue[],
2050: * org.xml.sax.Attributes)
2051: */
2052: public Object getValue(Element element, ElementValue[] value,
2053: Attributes attrs, Map hints) throws SAXException,
2054: SAXNotSupportedException {
2055: Element e = value[0].getElement();
2056:
2057: if (e == null) {
2058: throw new SAXException(
2059: "Internal error, ElementValues require an associated Element.");
2060: }
2061:
2062: Service service = new Service();
2063:
2064: for (int i = 0; i < value.length; i++) {
2065: if (elements[0].getName().equals(
2066: value[i].getElement().getName())) {
2067: service.setName((String) value[i].getValue());
2068: }
2069:
2070: if (elements[1].getName().equals(
2071: value[i].getElement().getName())) {
2072: service.setTitle((String) value[i].getValue());
2073: }
2074:
2075: if (elements[2].getName().equals(
2076: value[i].getElement().getName())) {
2077: service.set_abstract((String) value[i].getValue());
2078: }
2079:
2080: if (elements[3].getName().equals(
2081: value[i].getElement().getName())) {
2082: service.setKeywordList(((String) value[i]
2083: .getValue()).split(" "));
2084: }
2085:
2086: if (elements[4].getName().equals(
2087: value[i].getElement().getName())) {
2088: try {
2089: service.setOnlineResource(((URI) value[i]
2090: .getValue()).toURL());
2091: } catch (MalformedURLException e1) {
2092: throw new SAXException(e1);
2093: }
2094: }
2095:
2096: // if (elements[5].getName().equals(value[i].getElement().getName())) {
2097: // service.setFees((String) value[i].getValue());
2098: // }
2099: // if (elements[6].getName().equals(value[i].getElement().getName())) {
2100: // service.setAccessConstraints((String) value[i].getValue());
2101: // }
2102: }
2103:
2104: // check the required elements
2105: if ((service.getName() == null)
2106: || (service.getTitle() == null)
2107: || ((service.getOnlineResource()) == null)) {
2108: throw new SAXException(
2109: "Required Service Elements are missing, check"
2110: + " for the existence of Name, Title , or OnlineResource elements.");
2111: }
2112:
2113: return service;
2114: }
2115:
2116: /**
2117: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2118: */
2119: public Attribute[] getAttributes() {
2120: return null;
2121: }
2122:
2123: /**
2124: * @see org.geotools.xml.schema.ComplexType#getChild()
2125: */
2126: public ElementGrouping getChild() {
2127: return seq;
2128: }
2129:
2130: /**
2131: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2132: */
2133: public Element[] getChildElements() {
2134: return elements;
2135: }
2136:
2137: /**
2138: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2139: * java.lang.Object, java.util.Map)
2140: */
2141: public boolean canEncode(Element element, Object value,
2142: Map hints) {
2143: //
2144: return false;
2145: }
2146:
2147: /**
2148: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2149: * java.lang.Object, org.geotools.xml.PrintHandler,
2150: * java.util.Map)
2151: */
2152: public void encode(Element element, Object value,
2153: PrintHandler output, Map hints)
2154: throws OperationNotSupportedException {
2155: //
2156: throw new OperationNotSupportedException();
2157: }
2158: }
2159:
2160: /**
2161: * <p>
2162: * This class represents an FeatureTypeListType within the WFS Schema. This
2163: * includes both the data and parsing functionality associated with a
2164: * FeatureTypeListType.
2165: * </p>
2166: *
2167: * @see WFSComplexType
2168: */
2169: static class FeatureTypeListType extends WFSComplexType {
2170: // singleton instance
2171: private static final WFSComplexType instance = new FeatureTypeListType();
2172:
2173: // static element list
2174: private static final Element[] elements = {
2175: new WFSElement("Operations", OperationsType
2176: .getInstance(), 0, 1, false, null),
2177: new WFSElement("FeatureType", FeatureTypeType
2178: .getInstance(), 1, Integer.MAX_VALUE, false,
2179: null) };
2180:
2181: // static sequence
2182: private static final SequenceGT seq = new SequenceGT(elements);
2183:
2184: public static WFSComplexType getInstance() {
2185: return instance;
2186: }
2187:
2188: /**
2189: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2190: */
2191: public Attribute[] getAttributes() {
2192: return null;
2193: }
2194:
2195: /**
2196: * @see org.geotools.xml.schema.ComplexType#getChild()
2197: */
2198: public ElementGrouping getChild() {
2199: return seq;
2200: }
2201:
2202: /**
2203: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2204: */
2205: public Element[] getChildElements() {
2206: return elements;
2207: }
2208:
2209: /**
2210: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2211: * org.geotools.xml.schema.ElementValue[],
2212: * org.xml.sax.Attributes, java.util.Map)
2213: */
2214: public Object getValue(Element element, ElementValue[] value,
2215: Attributes attrs, Map hints) throws SAXException,
2216: SAXNotSupportedException {
2217: if ((element == null) || (value == null)) {
2218: throw new SAXException(
2219: "A parameter for FeatureTypeList is missing");
2220: }
2221:
2222: if (value.length < 1) {
2223: throw new SAXException("Missing a child element");
2224: }
2225:
2226: int operations = FeatureSetDescription.NO_OPERATION;
2227: List fts = new LinkedList();
2228:
2229: for (int i = 0; i < value.length; i++) {
2230: if (elements[0].getName().equals(
2231: value[i].getElement().getName())) {
2232: // operation
2233: operations = operations
2234: | ((Integer) value[i].getValue())
2235: .intValue();
2236: } else {
2237: if (elements[1].getName().equals(
2238: value[i].getElement().getName())) {
2239: // featureType
2240: fts.add(value[i].getValue());
2241: } else {
2242: // error
2243: throw new SAXException("An error occured here");
2244: }
2245: }
2246: }
2247:
2248: // FeatureSetDescription[] fsd = new FeatureSetDescription[fts.size()];
2249: //
2250: // for (int i = 0; i < fsd.length; i++) {
2251: // fsd[i] = (FeatureSetDescription) fts.get(i);
2252: //
2253: // if (fsd[i].getOperations() == FeatureSetDescription.NO_OPERATION) {
2254: // fsd[i].setOperations(operations);
2255: // }
2256: // }
2257: return fts;
2258: }
2259:
2260: /**
2261: * @see org.geotools.xml.schema.Type#getName()
2262: */
2263: public String getName() {
2264: return "FeatureTypeListType";
2265: }
2266:
2267: /**
2268: * @see org.geotools.xml.schema.Type#getInstanceType()
2269: */
2270: public Class getInstanceType() {
2271: return FeatureSetDescription[].class;
2272: }
2273:
2274: /**
2275: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2276: * java.lang.Object, java.util.Map)
2277: */
2278: public boolean canEncode(Element element, Object value,
2279: Map hints) {
2280: //
2281: return false;
2282: }
2283:
2284: /**
2285: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2286: * java.lang.Object, org.geotools.xml.PrintHandler,
2287: * java.util.Map)
2288: */
2289: public void encode(Element element, Object value,
2290: PrintHandler output, Map hints)
2291: throws OperationNotSupportedException {
2292: //
2293: throw new OperationNotSupportedException();
2294: }
2295: }
2296:
2297: /**
2298: * <p>
2299: * This class represents an CapabilityType within the WFS Schema. This
2300: * includes both the data and parsing functionality associated with a
2301: * CapabilityType.
2302: * </p>
2303: *
2304: * @see WFSComplexType
2305: */
2306: static class CapabilityType extends WFSComplexType {
2307: // singleton instance
2308: private static final WFSComplexType instance = new CapabilityType();
2309:
2310: // static element list
2311: private static final Element[] elements = {
2312: new WFSElement("Request", RequestType.getInstance(), 1,
2313: 1, false, null),
2314: new WFSElement("VendorSpecificCapabilities",
2315: XSISimpleTypes.String.getInstance(), 0, 1,
2316: false, null) };
2317:
2318: // static sequence
2319: private static final SequenceGT seq = new SequenceGT(elements);
2320:
2321: public static WFSComplexType getInstance() {
2322: return instance;
2323: }
2324:
2325: public Element findChildElement(String name) {
2326: if (name == null) {
2327: return null;
2328: }
2329: return seq.findChildElement(name);
2330: }
2331:
2332: /**
2333: * @see org.geotools.xml.schema.ComplexType#getChild()
2334: */
2335: public ElementGrouping getChild() {
2336: return seq;
2337: }
2338:
2339: /**
2340: * @see org.geotools.xml.schema.Type#getInstanceType()
2341: */
2342: public Class getInstanceType() {
2343: return Object[].class;
2344: }
2345:
2346: /**
2347: * @see org.geotools.xml.schema.Type#getName()
2348: */
2349: public String getName() {
2350: return "CapabilityType";
2351: }
2352:
2353: /**
2354: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2355: * org.geotools.xml.schema.ElementValue[],
2356: * org.xml.sax.Attributes)
2357: */
2358: public Object getValue(Element element, ElementValue[] value,
2359: Attributes attrs, Map hints) throws SAXException,
2360: SAXNotSupportedException {
2361: Element e = value[0].getElement();
2362:
2363: if (e == null) {
2364: throw new SAXException(
2365: "Internal error, ElementValues require an associated Element.");
2366: }
2367:
2368: Object[] capab = new Object[2];
2369:
2370: for (int i = 0; i < value.length; i++) {
2371: if (elements[0].getName().equals(
2372: value[i].getElement().getName())) {
2373: capab[1] = (OperationType[]) value[i].getValue();
2374: }
2375:
2376: if (elements[1].getName().equals(
2377: value[i].getElement().getName())) {
2378: capab[0] = (String) value[i].getValue();
2379: }
2380: }
2381:
2382: // check the required elements
2383: if (capab[1] == null) {
2384: throw new SAXException(
2385: "Required Capability Element is missing, check"
2386: + " for the existence of the Request Element.");
2387: }
2388:
2389: return capab;
2390: }
2391:
2392: /**
2393: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2394: */
2395: public Attribute[] getAttributes() {
2396: return null;
2397: }
2398:
2399: /**
2400: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2401: */
2402: public Element[] getChildElements() {
2403: return elements;
2404: }
2405:
2406: /**
2407: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2408: * java.lang.Object, java.util.Map)
2409: */
2410: public boolean canEncode(Element element, Object value,
2411: Map hints) {
2412: //
2413: return false;
2414: }
2415:
2416: /**
2417: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2418: * java.lang.Object, org.geotools.xml.PrintHandler,
2419: * java.util.Map)
2420: */
2421: public void encode(Element element, Object value,
2422: PrintHandler output, Map hints)
2423: throws OperationNotSupportedException {
2424: //
2425: throw new OperationNotSupportedException();
2426: }
2427: }
2428:
2429: /**
2430: * <p>
2431: * This class represents an WFS_CapabilitiesType within the WFS Schema.
2432: * This includes both the data and parsing functionality associated with
2433: * an WFS_CapabilitiesType .
2434: * </p>
2435: *
2436: * @see WFSComplexType
2437: */
2438: static class WFS_CapabilitiesType extends WFSComplexType {
2439: // singleton instance
2440: private static final WFSComplexType instance = new WFS_CapabilitiesType();
2441:
2442: // static element list
2443: private static final Element[] elements = {
2444: new WFSElement("Service", ServiceType.getInstance(), 1,
2445: 1, false, null),
2446: new WFSElement("Capability", CapabilityType
2447: .getInstance(), 1, 1, false, null),
2448: new WFSElement("FeatureTypeList", FeatureTypeListType
2449: .getInstance(), 1, 1, false, null),
2450:
2451: new WFSElement("Filter_Capabilities",
2452: Filter_CapabilitiesType.getInstance(), 1, 1,
2453: false, null) {
2454: /**
2455: * @see schema.Element#getNamespace()
2456: */
2457: public URI getNamespace() {
2458: return FilterSchema.NAMESPACE;
2459: }
2460: } };
2461: private static final Attribute[] attributes = {
2462: new WFSAttribute("version", XSISimpleTypes.String
2463: .getInstance(), Attribute.REQUIRED, "1.0.0"),
2464: new WFSAttribute(
2465: "updateSequence",
2466: XSISimpleTypes.NonNegativeInteger.getInstance(),
2467: Attribute.REQUIRED, "0") };
2468:
2469: // static sequence
2470: private static final SequenceGT seq = new SequenceGT(elements);
2471:
2472: public static WFSComplexType getInstance() {
2473: return instance;
2474: }
2475:
2476: /**
2477: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2478: */
2479: public Attribute[] getAttributes() {
2480: return attributes;
2481: }
2482:
2483: /**
2484: * @see org.geotools.xml.schema.ComplexType#getChild()
2485: */
2486: public ElementGrouping getChild() {
2487: return seq;
2488: }
2489:
2490: /**
2491: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2492: */
2493: public Element[] getChildElements() {
2494: return elements;
2495: }
2496:
2497: /**
2498: * @see org.geotools.xml.schema.Type#getName()
2499: */
2500: public String getName() {
2501: return "WFS_CapabilitiesType";
2502: }
2503:
2504: /**
2505: * @see org.geotools.xml.schema.Type#getInstanceType()
2506: */
2507: public Class getInstanceType() {
2508: return WFSCapabilities.class;
2509: }
2510:
2511: /**
2512: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2513: * java.lang.Object, java.util.Map)
2514: */
2515: public boolean canEncode(Element element, Object value,
2516: Map hints) {
2517: //
2518: return false;
2519: }
2520:
2521: /**
2522: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2523: * java.lang.Object, org.geotools.xml.PrintHandler,
2524: * java.util.Map)
2525: */
2526: public void encode(Element element, Object value,
2527: PrintHandler output, Map hints)
2528: throws OperationNotSupportedException {
2529: //
2530: throw new OperationNotSupportedException();
2531: }
2532:
2533: /**
2534: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2535: * org.geotools.xml.schema.ElementValue[],
2536: * org.xml.sax.Attributes, java.util.Map)
2537: */
2538: public Object getValue(Element element, ElementValue[] value,
2539: Attributes attrs, Map hints) throws SAXException,
2540: SAXNotSupportedException {
2541: if (element != null) {
2542: if (element.getType() != this ) {
2543: if (!(element.getType() instanceof ComplexType)) {
2544: ComplexType t = (ComplexType) element.getType();
2545:
2546: while ((t != null) && (t != this ))
2547: t = (t.getParent() instanceof ComplexType) ? (ComplexType) t
2548: .getParent()
2549: : null;
2550:
2551: if (t == null) {
2552: throw new SAXNotSupportedException(
2553: "The specified element was not a declared as a WFS_Capabilities element, or derived element");
2554: }
2555: } else {
2556: // error -- cannot encode
2557: throw new SAXNotSupportedException(
2558: "The specified element was not a declared as a WFS_Capabilities element, or derived element");
2559: }
2560: }
2561: }
2562:
2563: boolean validation = true;
2564: if (hints != null
2565: && hints
2566: .containsKey(DocumentFactory.VALIDATION_HINT)) {
2567: Boolean t = (Boolean) hints
2568: .get(DocumentFactory.VALIDATION_HINT);
2569: if (t != null)
2570: validation = t.booleanValue();
2571: }
2572:
2573: if (validation && ((value == null) || (value.length != 4))) {
2574: throw new SAXException(
2575: "The WFS Capabilites document has the wrong number of children");
2576: }
2577:
2578: WFSCapabilities result = new WFSCapabilities();
2579:
2580: for (int i = 0; i < 4 && i < value.length; i++) {
2581: if (elements[0].getName().equals(
2582: value[i].getElement().getName())) {
2583: // service
2584: result.setService((Service) value[i].getValue());
2585: } else {
2586: if (elements[1].getName().equals(
2587: value[i].getElement().getName())) {
2588: // capability
2589: Object[] temp = (Object[]) value[i].getValue();
2590:
2591: if (temp.length != 2) {
2592: throw new SAXException(
2593: "The WFS Capabilites document has an invalid capability child");
2594: }
2595:
2596: result
2597: .setVendorSpecificCapabilities((String) temp[0]);
2598:
2599: OperationType[] tmp = (OperationType[]) temp[1];
2600:
2601: if (tmp != null) {
2602: result.setGetCapabilities(tmp[0]);
2603: result.setDescribeFeatureType(tmp[1]);
2604: result.setTransaction(tmp[2]);
2605: result.setGetFeature(tmp[3]);
2606: result.setGetFeatureWithLock(tmp[4]);
2607: result.setLockFeature(tmp[5]);
2608: }
2609: } else {
2610: if (elements[2].getName().equals(
2611: value[i].getElement().getName())) {
2612: // FeatureTypeList
2613: result.setFeatureTypes((List) value[i]
2614: .getValue());
2615: } else {
2616: if (elements[3].getName().equals(
2617: value[i].getElement().getName())) {
2618: // Filter_Capabilities
2619: result
2620: .setFilterCapabilities((FilterCapabilities) value[i]
2621: .getValue());
2622: } else {
2623: if (validation) {
2624: // error
2625: throw new SAXException(
2626: "The element "
2627: + ((value[i]
2628: .getElement() == null) ? "null"
2629: : value[i]
2630: .getElement()
2631: .getName())
2632: + " was not found as a valid element ...");
2633: }
2634: }
2635: }
2636: }
2637: }
2638: }
2639:
2640: return result;
2641: }
2642: }
2643:
2644: /**
2645: * <p>
2646: * This class represents an GetCapabilitiesType within the WFS Schema. This
2647: * includes both the data and parsing functionality associated with a
2648: * GetCapabilitiesType.
2649: * </p>
2650: *
2651: * @see WFSComplexType
2652: */
2653: static class GetCapabilitiesType extends WFSComplexType {
2654: // singleton instance
2655: private static final WFSComplexType instance = new GetCapabilitiesType();
2656:
2657: // static element list
2658: private static final Element[] elements = { new WFSElement(
2659: "DCPType", DCPTypeType.getInstance(), 1,
2660: Integer.MAX_VALUE, false, null) };
2661:
2662: // static sequence
2663: private static final SequenceGT seq = new SequenceGT(elements);
2664:
2665: /*
2666: * part of the singleton pattern
2667: *
2668: * @see WFSComplexType#getInstance()
2669: */
2670: static WFSComplexType getInstance() {
2671: return instance;
2672: }
2673:
2674: /**
2675: * @see org.geotools.xml.schema.ComplexType#getChild()
2676: */
2677: public ElementGrouping getChild() {
2678: return seq;
2679: }
2680:
2681: /**
2682: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2683: */
2684: public Attribute[] getAttributes() {
2685: return null;
2686: }
2687:
2688: /**
2689: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2690: */
2691: public Element[] getChildElements() {
2692: return elements;
2693: }
2694:
2695: /**
2696: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2697: * org.geotools.xml.schema.ElementValue[],
2698: * org.xml.sax.Attributes, java.util.Map)
2699: */
2700: public Object getValue(Element element, ElementValue[] value,
2701: Attributes attrs, Map hints) throws SAXException,
2702: SAXNotSupportedException {
2703: if ((element == null) || (value == null)) {
2704: throw new SAXException(
2705: "Invalid inputs for parsing a GetCapabilitiesType");
2706: }
2707:
2708: if (value.length < 1) {
2709: throw new SAXException(
2710: "Invalid number of inputs for parsing a GetCapabilitiesType");
2711: }
2712:
2713: List l = new LinkedList();
2714:
2715: for (int i = 0; i < value.length; i++) {
2716: OperationType t = (OperationType) value[i].getValue();
2717: l.add(t);
2718: }
2719:
2720: return l.toArray(new OperationType[(l.size())]);
2721: }
2722:
2723: /**
2724: * @see org.geotools.xml.schema.Type#getName()
2725: */
2726: public String getName() {
2727: return "GetCapabilitiesType";
2728: }
2729:
2730: /**
2731: * @see org.geotools.xml.schema.Type#getInstanceType()
2732: */
2733: public Class getInstanceType() {
2734: return OperationType[].class;
2735: }
2736:
2737: /**
2738: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2739: * java.lang.Object, java.util.Map)
2740: */
2741: public boolean canEncode(Element element, Object value,
2742: Map hints) {
2743: //
2744: return false;
2745: }
2746:
2747: /**
2748: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2749: * java.lang.Object, org.geotools.xml.PrintHandler,
2750: * java.util.Map)
2751: */
2752: public void encode(Element element, Object value,
2753: PrintHandler output, Map hints)
2754: throws OperationNotSupportedException {
2755: //
2756: throw new OperationNotSupportedException();
2757: }
2758: }
2759:
2760: /**
2761: * <p>
2762: * This class represents an DescribeFeatureType within the WFS Schema. This
2763: * includes both the data and parsing functionality associated with a
2764: * DescribeFeatureType.
2765: * </p>
2766: *
2767: * @see WFSComplexType
2768: */
2769: static class DescribeFeatureTypeType extends WFSComplexType {
2770: // singleton instance
2771: private static final WFSComplexType instance = new DescribeFeatureTypeType();
2772:
2773: // static element list
2774: private static final Element[] elements = {
2775: new WFSElement("SchemaDescriptionLanguage",
2776: SchemaDescriptionLanguageType.getInstance(), 1,
2777: 1, false, null),
2778: new WFSElement("DCPType", DCPTypeType.getInstance(), 1,
2779: Integer.MAX_VALUE, false, null) };
2780:
2781: // static sequence
2782: private static final SequenceGT seq = new SequenceGT(elements);
2783:
2784: public static WFSComplexType getInstance() {
2785: return instance;
2786: }
2787:
2788: /**
2789: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2790: */
2791: public Attribute[] getAttributes() {
2792: return null;
2793: }
2794:
2795: /**
2796: * @see org.geotools.xml.schema.ComplexType#getChild()
2797: */
2798: public ElementGrouping getChild() {
2799: return seq;
2800: }
2801:
2802: /**
2803: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2804: */
2805: public Element[] getChildElements() {
2806: return elements;
2807: }
2808:
2809: /**
2810: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2811: * org.geotools.xml.schema.ElementValue[],
2812: * org.xml.sax.Attributes, java.util.Map)
2813: */
2814: public Object getValue(Element element, ElementValue[] value,
2815: Attributes attrs, Map hints) throws SAXException,
2816: SAXNotSupportedException {
2817: if ((element == null) || (value == null)) {
2818: throw new SAXException(
2819: "Invalid inputs for parsing a GetCapabilitiesType");
2820: }
2821:
2822: if (value.length < 2) {
2823: throw new SAXException(
2824: "Invalid number of inputs for parsing a GetCapabilitiesType");
2825: }
2826:
2827: List l = new LinkedList();
2828: List sdl = null;
2829:
2830: for (int i = 0; i < value.length; i++) {
2831: if ((sdl == null)
2832: && (value[i].getElement() != null)
2833: && "SchemaDescriptionLanguage".equals(value[i]
2834: .getElement().getName())) {
2835: sdl = (List) value[i].getValue();
2836: } else {
2837: OperationType t = (OperationType) value[i]
2838: .getValue();
2839: l.add(t);
2840: }
2841: }
2842:
2843: OperationType[] ot = new OperationType[l.size()];
2844:
2845: for (int i = 0; i < ot.length; i++) {
2846: ot[i] = (OperationType) l.get(i);
2847: ot[i].setFormats(sdl);
2848: }
2849:
2850: return ot;
2851: }
2852:
2853: /**
2854: * @see org.geotools.xml.schema.Type#getName()
2855: */
2856: public String getName() {
2857: return "DescribeFeatureTypeType";
2858: }
2859:
2860: /**
2861: * @see org.geotools.xml.schema.Type#getInstanceType()
2862: */
2863: public Class getInstanceType() {
2864: return OperationType[].class;
2865: }
2866:
2867: /**
2868: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2869: * java.lang.Object, java.util.Map)
2870: */
2871: public boolean canEncode(Element element, Object value,
2872: Map hints) {
2873: //
2874: return false;
2875: }
2876:
2877: /**
2878: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2879: * java.lang.Object, org.geotools.xml.PrintHandler,
2880: * java.util.Map)
2881: */
2882: public void encode(Element element, Object value,
2883: PrintHandler output, Map hints)
2884: throws OperationNotSupportedException {
2885: //
2886: throw new OperationNotSupportedException();
2887: }
2888: }
2889:
2890: /**
2891: * <p>
2892: * This class represents an TransactionType within the WFS Schema. This
2893: * includes both the data and parsing functionality associated with a
2894: * TransactionType.
2895: * </p>
2896: *
2897: * @see WFSComplexType
2898: */
2899: static class TransactionType extends WFSComplexType {
2900: // singleton instance
2901: private static final WFSComplexType instance = new TransactionType();
2902:
2903: // static element list
2904: private static final Element[] elements = { new WFSElement(
2905: "DCPType", DCPTypeType.getInstance(), 1,
2906: Integer.MAX_VALUE, false, null) };
2907:
2908: // static sequence
2909: private static final SequenceGT seq = new SequenceGT(elements);
2910:
2911: public static WFSComplexType getInstance() {
2912: return instance;
2913: }
2914:
2915: /**
2916: * @see org.geotools.xml.schema.ComplexType#getChild()
2917: */
2918: public ElementGrouping getChild() {
2919: return seq;
2920: }
2921:
2922: /**
2923: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2924: */
2925: public Attribute[] getAttributes() {
2926: return null;
2927: }
2928:
2929: /**
2930: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2931: */
2932: public Element[] getChildElements() {
2933: return elements;
2934: }
2935:
2936: /**
2937: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
2938: * org.geotools.xml.schema.ElementValue[],
2939: * org.xml.sax.Attributes, java.util.Map)
2940: */
2941: public Object getValue(Element element, ElementValue[] value,
2942: Attributes attrs, Map hints) throws SAXException,
2943: SAXNotSupportedException {
2944: if ((element == null) || (value == null)) {
2945: throw new SAXException(
2946: "Invalid inputs for parsing a GetCapabilitiesType");
2947: }
2948:
2949: if (value.length < 1) {
2950: throw new SAXException(
2951: "Invalid number of inputs for parsing a GetCapabilitiesType");
2952: }
2953:
2954: List l = new LinkedList();
2955:
2956: for (int i = 0; i < value.length; i++) {
2957: OperationType t = (OperationType) value[i].getValue();
2958: l.add(t);
2959: }
2960:
2961: return l.toArray(new OperationType[l.size()]);
2962: }
2963:
2964: /**
2965: * @see org.geotools.xml.schema.Type#getName()
2966: */
2967: public String getName() {
2968: return "TransactionType";
2969: }
2970:
2971: /**
2972: * @see org.geotools.xml.schema.Type#getInstanceType()
2973: */
2974: public Class getInstanceType() {
2975: return OperationType[].class;
2976: }
2977:
2978: /**
2979: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
2980: * java.lang.Object, java.util.Map)
2981: */
2982: public boolean canEncode(Element element, Object value,
2983: Map hints) {
2984: //
2985: return false;
2986: }
2987:
2988: /**
2989: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
2990: * java.lang.Object, org.geotools.xml.PrintHandler,
2991: * java.util.Map)
2992: */
2993: public void encode(Element element, Object value,
2994: PrintHandler output, Map hints)
2995: throws OperationNotSupportedException {
2996: //
2997: throw new OperationNotSupportedException();
2998: }
2999: }
3000:
3001: /**
3002: * <p>
3003: * This class represents an GetFeatureTypeType within the WFS Schema. This
3004: * includes both the data and parsing functionality associated with a
3005: * GetFeatureTypeType.
3006: * </p>
3007: *
3008: * @see WFSComplexType
3009: */
3010: static class GetFeatureTypeType extends WFSComplexType {
3011: // singleton instance
3012: private static final WFSComplexType instance = new GetFeatureTypeType();
3013:
3014: // static element list
3015: private static final Element[] elements = {
3016: new WFSElement("ResultFormat", ResultFormatType
3017: .getInstance(), 1, 1, false, null),
3018: new WFSElement("DCPType", DCPTypeType.getInstance(), 1,
3019: Integer.MAX_VALUE, false, null) };
3020:
3021: // static sequence
3022: private static final SequenceGT seq = new SequenceGT(elements);
3023:
3024: public static WFSComplexType getInstance() {
3025: return instance;
3026: }
3027:
3028: /**
3029: * @see org.geotools.xml.schema.ComplexType#getChild()
3030: */
3031: public ElementGrouping getChild() {
3032: return seq;
3033: }
3034:
3035: /**
3036: * @see org.geotools.xml.schema.ComplexType#getAttributes()
3037: */
3038: public Attribute[] getAttributes() {
3039: return null;
3040: }
3041:
3042: /**
3043: * @see org.geotools.xml.schema.ComplexType#getChildElements()
3044: */
3045: public Element[] getChildElements() {
3046: return elements;
3047: }
3048:
3049: /**
3050: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element,
3051: * org.geotools.xml.schema.ElementValue[],
3052: * org.xml.sax.Attributes, java.util.Map)
3053: */
3054: public Object getValue(Element element, ElementValue[] value,
3055: Attributes attrs, Map hints) throws SAXException,
3056: SAXNotSupportedException {
3057: if ((element == null) || (value == null)) {
3058: throw new SAXException(
3059: "Invalid inputs for parsing a GetCapabilitiesType");
3060: }
3061:
3062: if (value.length < 1) {
3063: throw new SAXException(
3064: "Invalid number of inputs for parsing a GetCapabilitiesType");
3065: }
3066:
3067: List l = new LinkedList();
3068: List sdl = null;
3069:
3070: for (int i = 0; i < value.length; i++) {
3071: if ((sdl == null)
3072: && (value[i].getElement() != null)
3073: && elements[0].getName().equals(
3074: value[i].getElement().getName())) {
3075: sdl = (List) value[i].getValue();
3076: } else {
3077: OperationType t = (OperationType) value[i]
3078: .getValue();
3079: l.add(t);
3080: }
3081: }
3082:
3083: OperationType[] ot = new OperationType[l.size()];
3084:
3085: for (int i = 0; i < ot.length; i++) {
3086: ot[i] = (OperationType) l.get(i);
3087: ot[i].setFormats(sdl);
3088: }
3089:
3090: return ot;
3091: }
3092:
3093: /**
3094: * @see org.geotools.xml.schema.Type#getName()
3095: */
3096: public String getName() {
3097: return "GetFeatureTypeType";
3098: }
3099:
3100: /**
3101: * @see org.geotools.xml.schema.Type#getInstanceType()
3102: */
3103: public Class getInstanceType() {
3104: return OperationType[].class;
3105: }
3106:
3107: /**
3108: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
3109: * java.lang.Object, java.util.Map)
3110: */
3111: public boolean canEncode(Element element, Object value,
3112: Map hints) {
3113: //
3114: return false;
3115: }
3116:
3117: /**
3118: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
3119: * java.lang.Object, org.geotools.xml.PrintHandler,
3120: * java.util.Map)
3121: */
3122: public void encode(Element element, Object value,
3123: PrintHandler output, Map hints)
3124: throws OperationNotSupportedException {
3125: //
3126: throw new OperationNotSupportedException();
3127: }
3128: }
3129: }
|