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.Iterator;
019: import java.util.List;
020: import javax.xml.namespace.QName;
021: import com.vividsolutions.jts.geom.GeometryFactory;
022: import com.vividsolutions.jts.geom.LineString;
023: import com.vividsolutions.jts.geom.MultiLineString;
024: import org.geotools.xml.*;
025:
026: /**
027: * Binding object for the type http://www.opengis.net/gml:MultiLineStringType.
028: *
029: * <p>
030: * <pre>
031: * <code>
032: * <complexType name="MultiLineStringType">
033: * <annotation>
034: * <documentation>A MultiLineString is defined by one or more LineStrings, referenced through lineStringMember elements. Deprecated with GML version 3.0. Use MultiCurveType instead.</documentation>
035: * </annotation>
036: * <complexContent>
037: * <extension base="gml:AbstractGeometricAggregateType">
038: * <sequence>
039: * <element maxOccurs="unbounded" minOccurs="0" ref="gml:lineStringMember"/>
040: * </sequence>
041: * </extension>
042: * </complexContent>
043: * </complexType>
044: *
045: * </code>
046: * </pre>
047: * </p>
048: *
049: * @generated
050: */
051: public class MultiLineStringTypeBinding extends AbstractComplexBinding {
052: GeometryFactory gFactory;
053:
054: public MultiLineStringTypeBinding(GeometryFactory gFactory) {
055: this .gFactory = gFactory;
056: }
057:
058: /**
059: * @generated
060: */
061: public QName getTarget() {
062: return GML.MultiLineStringType;
063: }
064:
065: /**
066: * <!-- begin-user-doc -->
067: * <!-- end-user-doc -->
068: *
069: * @generated modifiable
070: */
071: public Class getType() {
072: return MultiLineString.class;
073: }
074:
075: public int getExecutionMode() {
076: return BEFORE;
077: }
078:
079: /**
080: * <!-- begin-user-doc -->
081: * <!-- end-user-doc -->
082: *
083: * @generated modifiable
084: */
085: public Object parse(ElementInstance instance, Node node,
086: Object value) throws Exception {
087: List lines = node.getChildValues(LineString.class);
088:
089: return gFactory.createMultiLineString((LineString[]) lines
090: .toArray(new LineString[lines.size()]));
091: }
092:
093: public Object getProperty(Object object, QName name)
094: throws Exception {
095: if (GML.lineStringMember.equals(name)) {
096: MultiLineString multiLineString = (MultiLineString) object;
097: LineString[] members = new LineString[multiLineString
098: .getNumGeometries()];
099:
100: for (int i = 0; i < members.length; i++) {
101: members[i] = (LineString) multiLineString
102: .getGeometryN(i);
103: }
104:
105: return members;
106: }
107:
108: return null;
109: }
110: }
|