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_1_0;
006:
007: import net.opengis.wfs.FeatureCollectionType;
008: import net.opengis.wfs.WfsFactory;
009: import org.geoserver.feature.CompositeFeatureCollection;
010: import org.geotools.feature.FeatureCollection;
011: import org.geotools.gml3.bindings.GML;
012: import org.geotools.xml.AbstractComplexEMFBinding;
013: import org.geotools.xml.ElementInstance;
014: import org.geotools.xml.Node;
015: import javax.xml.namespace.QName;
016:
017: /**
018: * Binding object for the type http://www.opengis.net/wfs:FeatureCollectionType.
019: *
020: * <p>
021: * <pre>
022: * <code>
023: * <xsd:complexType name="FeatureCollectionType">
024: * <xsd:annotation>
025: * <xsd:documentation>
026: * This type defines a container for the response to a
027: * GetFeature or GetFeatureWithLock request. If the
028: * request is GetFeatureWithLock, the lockId attribute
029: * must be populated. The lockId attribute can otherwise
030: * be safely ignored.
031: * </xsd:documentation>
032: * </xsd:annotation>
033: * <xsd:complexContent>
034: * <xsd:extension base="gml:AbstractFeatureCollectionType">
035: * <xsd:attribute name="lockId" type="xsd:string" use="optional">
036: * <xsd:annotation>
037: * <xsd:documentation>
038: * The value of the lockId attribute is an identifier
039: * that a Web Feature Service generates when responding
040: * to a GetFeatureWithLock request. A client application
041: * can use this value in subsequent operations (such as a
042: * Transaction request) to reference the set of locked
043: * features.
044: * </xsd:documentation>
045: * </xsd:annotation>
046: * </xsd:attribute>
047: * <xsd:attribute name="timeStamp" type="xsd:dateTime" use="optional">
048: * <xsd:annotation>
049: * <xsd:documentation>
050: * The timeStamp attribute should contain the date and time
051: * that the response was generated.
052: * </xsd:documentation>
053: * </xsd:annotation>
054: * </xsd:attribute>
055: * <xsd:attribute name="numberOfFeatures"
056: * type="xsd:nonNegativeInteger" use="optional">
057: * <xsd:annotation>
058: * <xsd:documentation>
059: * The numberOfFeatures attribute should contain a
060: * count of the number of features in the response.
061: * That is a count of all features elements dervied
062: * from gml:AbstractFeatureType.
063: * </xsd:documentation>
064: * </xsd:annotation>
065: * </xsd:attribute>
066: * </xsd:extension>
067: * </xsd:complexContent>
068: * </xsd:complexType>
069: *
070: * </code>
071: * </pre>
072: * </p>
073: *
074: * @generated
075: */
076: public class FeatureCollectionTypeBinding extends
077: AbstractComplexEMFBinding {
078: WfsFactory wfsfactory;
079:
080: public FeatureCollectionTypeBinding(WfsFactory wfsfactory) {
081: this .wfsfactory = wfsfactory;
082: }
083:
084: public int getExecutionMode() {
085: return OVERRIDE;
086: }
087:
088: /**
089: * @generated
090: */
091: public QName getTarget() {
092: return WFS.FEATURECOLLECTIONTYPE;
093: }
094:
095: /**
096: * <!-- begin-user-doc -->
097: * <!-- end-user-doc -->
098: *
099: * @generated modifiable
100: */
101: public Class getType() {
102: return FeatureCollection.class;
103: }
104:
105: /**
106: * <!-- begin-user-doc -->
107: * <!-- end-user-doc -->
108: *
109: * @generated modifiable
110: */
111: public Object parse(ElementInstance instance, Node node,
112: Object value) throws Exception {
113: return value;
114: }
115:
116: public Object getProperty(Object object, QName name)
117: throws Exception {
118: //check for feature collection memebers
119: if (GML.featureMembers.equals(name)) {
120: FeatureCollectionType featureCollection = (FeatureCollectionType) object;
121:
122: if (!featureCollection.getFeature().isEmpty()) {
123: if (featureCollection.getFeature().size() > 1) {
124: //wrap in a single
125: return new CompositeFeatureCollection(
126: featureCollection.getFeature());
127: }
128:
129: //just return the single
130: return featureCollection.getFeature().iterator().next();
131: }
132: }
133:
134: //delegate to parent lookup
135: return super.getProperty(object, name);
136: }
137: }
|