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 java.util.List;
019: import javax.xml.namespace.QName;
020: import com.vividsolutions.jts.geom.GeometryFactory;
021: import com.vividsolutions.jts.geom.LineString;
022: import com.vividsolutions.jts.geom.MultiLineString;
023: import org.geotools.xml.AbstractComplexBinding;
024: import org.geotools.xml.ElementInstance;
025: import org.geotools.xml.Node;
026:
027: /**
028: * Binding object for the type http://www.opengis.net/gml:MultiCurveType.
029: *
030: * <p>
031: * <pre>
032: * <code>
033: * <complexType name="MultiCurveType">
034: * <annotation>
035: * <documentation>A MultiCurve is defined by one or more Curves, referenced through curveMember elements.</documentation>
036: * </annotation>
037: * <complexContent>
038: * <extension base="gml:AbstractGeometricAggregateType">
039: * <sequence>
040: * <annotation>
041: * <documentation>The members of the geometric aggregate can be specified either using the "standard" property or the array property style. It is also valid to use both the "standard" and the array property style in the same collection.
042: * NOTE: Array properties cannot reference remote geometry elements.</documentation>
043: * </annotation>
044: * <element maxOccurs="unbounded" minOccurs="0" ref="gml:curveMember"/>
045: * <element minOccurs="0" ref="gml:curveMembers"/>
046: * </sequence>
047: * </extension>
048: * </complexContent>
049: * </complexType>
050: *
051: * </code>
052: * </pre>
053: * </p>
054: *
055: * @generated
056: */
057: public class MultiCurveTypeBinding extends AbstractComplexBinding {
058: GeometryFactory gf;
059:
060: public MultiCurveTypeBinding(GeometryFactory gf) {
061: this .gf = gf;
062: }
063:
064: /**
065: * @generated
066: */
067: public QName getTarget() {
068: return GML.MultiCurveType;
069: }
070:
071: /**
072: * <!-- begin-user-doc -->
073: * <!-- end-user-doc -->
074: *
075: * @generated modifiable
076: */
077: public Class getType() {
078: //return MultiCurve.class;
079: return MultiLineString.class;
080: }
081:
082: public int getExecutionMode() {
083: return BEFORE;
084: }
085:
086: /**
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: *
090: * @generated modifiable
091: */
092: public Object parse(ElementInstance instance, Node node,
093: Object value) throws Exception {
094: //<element maxOccurs="unbounded" minOccurs="0" ref="gml:curveMember"/>
095: List curves = node.getChildValues(LineString.class);
096:
097: return gf.createMultiLineString((LineString[]) curves
098: .toArray(new LineString[curves.size()]));
099: }
100:
101: public Object getProperty(Object object, QName name)
102: throws Exception {
103: if (GML.curveMember.equals(name)) {
104: //MultiCurve multiCurve = (MultiCurve) object;
105: MultiLineString multiCurve = (MultiLineString) object;
106: LineString[] members = new LineString[multiCurve
107: .getNumGeometries()];
108:
109: for (int i = 0; i < members.length; i++) {
110: members[i] = (LineString) multiCurve.getGeometryN(i);
111: }
112:
113: return members;
114: }
115:
116: return null;
117: }
118: }
|