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.v1_0_0;
006:
007: import net.opengis.wfs.GetFeatureType;
008: import net.opengis.wfs.QueryType;
009: import net.opengis.wfs.WfsFactory;
010: import org.geotools.xml.AbstractComplexBinding;
011: import org.geotools.xml.ElementInstance;
012: import org.geotools.xml.Node;
013: import java.math.BigInteger;
014: import javax.xml.namespace.QName;
015:
016: /**
017: * Binding object for the type http://www.opengis.net/wfs:GetFeatureType.
018: *
019: * <p>
020: * <pre>
021: * <code>
022: * <xsd:complexType name="GetFeatureType"> <xsd:annotation>
023: * <xsd:documentation> A GetFeature element
024: * contains one or more Query elements that
025: * describe a query operation on one feature type. In
026: * response to a GetFeature request, a Web Feature Service
027: * must be able to generate a GML2 response that validates
028: * using a schema generated by the DescribeFeatureType request.
029: * A Web Feature Service may support other possibly non-XML
030: * (and even binary) output formats as long as those formats
031: * are advertised in the capabilities document.
032: * </xsd:documentation> </xsd:annotation>
033: * <xsd:sequence> <xsd:element maxOccurs="unbounded"
034: * ref="wfs:Query"/> </xsd:sequence> <xsd:attribute
035: * fixed="1.0.0" name="version" type="xsd:string" use="required"/>
036: * <xsd:attribute fixed="WFS" name="service" type="xsd:string"
037: * use="required"/> <xsd:attribute name="handle"
038: * type="xsd:string" use="optional"/> <xsd:attribute
039: * default="GML2" name="outputFormat" type="xsd:string"
040: * use="optional"> <xsd:annotation>
041: * <xsd:documentation> The outputFormat
042: * attribute is used to specify the output
043: * format that the Web Feature Service should generate in
044: * response to a GetFeature or GetFeatureWithLock element.
045: * The default value of GML2 indicates that the output is
046: * an XML document that conforms to the
047: * Geography Markup Language (GML)
048: * Implementation Specification V2.0. Other
049: * values may be used to specify other formats as long
050: * as those values are advertised in the capabilities
051: * document. For example, the value WKB may
052: * be used to indicate that a Well Known
053: * Binary format be used to encode the output.
054: * </xsd:documentation> </xsd:annotation>
055: * </xsd:attribute> <xsd:attribute name="maxFeatures"
056: * type="xsd:positiveInteger" use="optional">
057: * <xsd:annotation> <xsd:documentation>
058: * The maxFeatures attribute is used to specify the maximum
059: * number of features that a GetFeature operation should
060: * generate (regardless of the actual number of query
061: * hits). </xsd:documentation>
062: * </xsd:annotation> </xsd:attribute> </xsd:complexType>
063: *
064: * </code>
065: * </pre>
066: * </p>
067: *
068: * @generated
069: */
070: public class GetFeatureTypeBinding extends AbstractComplexBinding {
071: WfsFactory wfsfactory;
072:
073: public GetFeatureTypeBinding(WfsFactory wfsfactory) {
074: this .wfsfactory = wfsfactory;
075: }
076:
077: /**
078: * @generated
079: */
080: public QName getTarget() {
081: return WFS.GETFEATURETYPE;
082: }
083:
084: /**
085: * <!-- begin-user-doc -->
086: * <!-- end-user-doc -->
087: *
088: * @generated modifiable
089: */
090: public Class getType() {
091: return GetFeatureType.class;
092: }
093:
094: /**
095: * <!-- begin-user-doc -->
096: * <!-- end-user-doc -->
097: *
098: * @generated modifiable
099: */
100: public Object parse(ElementInstance instance, Node node,
101: Object value) throws Exception {
102: GetFeatureType getFeature = wfsfactory.createGetFeatureType();
103:
104: WFSBindingUtils.service(getFeature, node);
105: WFSBindingUtils.version(getFeature, node);
106: WFSBindingUtils.outputFormat(getFeature, node, "GML2");
107:
108: if (node.getAttributeValue("handle") != null) {
109: getFeature.setHandle((String) node
110: .getAttributeValue("handle"));
111: }
112:
113: //get the max features
114: BigInteger maxFeatures = null;
115: Number number = (Number) node.getAttributeValue("maxFeatures");
116:
117: if (number != null) {
118: if (number instanceof BigInteger) {
119: maxFeatures = (BigInteger) number;
120: } else {
121: maxFeatures = BigInteger.valueOf(number.longValue());
122: }
123:
124: getFeature.setMaxFeatures(maxFeatures);
125: }
126:
127: //queries
128: getFeature.getQuery().addAll(
129: node.getChildValues(QueryType.class));
130:
131: return getFeature;
132: }
133: }
|