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.gml2.bindings;
017:
018: import javax.xml.namespace.QName;
019: import com.vividsolutions.jts.geom.Envelope;
020: import org.geotools.xml.AbstractComplexBinding;
021: import org.geotools.xml.ElementInstance;
022: import org.geotools.xml.Node;
023:
024: /**
025: * Binding object for the type http://www.opengis.net/gml:BoundingShapeType.
026: *
027: * <p>
028: * <pre>
029: * <code>
030: * <complexType name="BoundingShapeType">
031: * <annotation>
032: * <documentation> Bounding shapes--a Box or a null element
033: * are currently allowed. </documentation>
034: * </annotation>
035: * <sequence>
036: * <choice>
037: * <element ref="gml:Box"/>
038: * <element name="null" type="gml:NullType"/>
039: * </choice>
040: * </sequence>
041: * </complexType>
042: *
043: * </code>
044: * </pre>
045: * </p>
046: *
047: * @generated
048: */
049: public class GMLBoundingShapeTypeBinding extends AbstractComplexBinding {
050: /**
051: * @generated
052: */
053: public QName getTarget() {
054: return GML.BoundingShapeType;
055: }
056:
057: /**
058: * <!-- begin-user-doc -->
059: * <!-- end-user-doc -->
060: *
061: * @generated modifiable
062: */
063: public Class getType() {
064: return Envelope.class;
065: }
066:
067: /**
068: * <!-- begin-user-doc -->
069: * <!-- end-user-doc -->
070: *
071: * @generated modifiable
072: */
073: public Object parse(ElementInstance instance, Node node,
074: Object value) throws Exception {
075: //do the null check
076: if (node.getChild("null") != null) {
077: //ignore the description as to why its null
078: Envelope e = new Envelope();
079: e.setToNull();
080:
081: return e;
082: }
083:
084: //has to be a valid bounding box
085: return (Envelope) node.getChildValue(0);
086: }
087:
088: public Object getProperty(Object object, QName name)
089: throws Exception {
090: Envelope e = (Envelope) object;
091:
092: if (GML.Box.equals(name) && !e.isNull()) {
093: return e;
094: }
095:
096: if ("null".equals(name.getLocalPart()) && e.isNull()) {
097: return e;
098: }
099:
100: return null;
101: }
102: }
|