001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.gml3.bindings;
017:
018: import javax.xml.namespace.QName;
019: import org.geotools.feature.DefaultFeatureCollections;
020: import org.geotools.feature.Feature;
021: import org.geotools.feature.FeatureCollection;
022: import org.geotools.xml.*;
023:
024: /**
025: * Binding object for the type http://www.opengis.net/gml:AbstractFeatureCollectionType.
026: *
027: * <p>
028: * <pre>
029: * <code>
030: * <complexType abstract="true" name="AbstractFeatureCollectionType">
031: * <annotation>
032: * <documentation>A feature collection contains zero or more features.</documentation>
033: * </annotation>
034: * <complexContent>
035: * <extension base="gml:AbstractFeatureType">
036: * <sequence>
037: * <element maxOccurs="unbounded" minOccurs="0" ref="gml:featureMember"/>
038: * <element minOccurs="0" ref="gml:featureMembers"/>
039: * </sequence>
040: * </extension>
041: * </complexContent>
042: * </complexType>
043: *
044: * </code>
045: * </pre>
046: * </p>
047: *
048: * @generated
049: */
050: public class AbstractFeatureCollectionTypeBinding extends
051: AbstractComplexBinding {
052: /**
053: * @generated
054: */
055: public QName getTarget() {
056: return GML.AbstractFeatureCollectionType;
057: }
058:
059: /**
060: * <!-- begin-user-doc -->
061: * <!-- end-user-doc -->
062: *
063: * @generated modifiable
064: */
065: public Class getType() {
066: return FeatureCollection.class;
067: }
068:
069: /**
070: * <!-- begin-user-doc -->
071: * <!-- end-user-doc -->
072: *
073: * @generated modifiable
074: */
075: public Object parse(ElementInstance instance, Node node,
076: Object value) throws Exception {
077: FeatureCollection featureCollection = DefaultFeatureCollections
078: .newCollection();
079:
080: //<element maxOccurs="unbounded" minOccurs="0" ref="gml:featureMember"/>
081: featureCollection.addAll(node.getChildValues(Feature.class));
082:
083: //<element minOccurs="0" ref="gml:featureMembers"/>
084: Feature[] featureMembers = (Feature[]) node
085: .getChildValue(Feature[].class);
086:
087: if (featureMembers != null) {
088: for (int i = 0; i < featureMembers.length; i++) {
089: featureCollection.add(featureMembers[i]);
090: }
091: }
092:
093: return featureCollection;
094: }
095:
096: public Object getProperty(Object object, QName name) {
097: //just return the features themselves
098: if (GML.featureMembers.equals(name)) {
099: FeatureCollection fc = (FeatureCollection) object;
100:
101: return fc;
102:
103: //return fc.toArray(new Feature[fc.size()]);
104: }
105:
106: return null;
107: }
108: }
|