/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.wcs.v1_1.bindings;
import javax.xml.namespace.QName;
import org.geotools.gml3.v3_2.GML;
import org.geotools.temporal.object.DefaultPosition;
import org.geotools.util.SimpleInternationalString;
import org.geotools.xml.AbstractComplexBinding;
import org.geotools.xml.ElementInstance;
import org.geotools.xml.Node;
import org.opengis.temporal.Position;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Binding object for the type http://www.opengis.net/gml:TimePositionType.
*
* <p>
*
* <pre>
* <code>
* <complexType final="#all" name="TimePositionType">
* <annotation>
* <documentation>
* Indeterminate time values are also allowed, as described in ISO 19108. The indeterminatePosition
* attribute can be used alone or it can qualify a specific value for temporal position (e.g. before
* 2002-12, after 1019624400). For time values that identify position within a calendar, the
* calendarEraName attribute provides the name of the calendar era to which the date is
* referenced (e.g. the Meiji era of the Japanese calendar).
* </documentation>
* </annotation>
* <simpleContent>
* <extension base="gml:TemporalPositionType">
* <attribute name="calendarEraName" type="string" use="optional"/>
* <attribute default="#ISO-8601" name="frame" type="anyURI" use="optional"/>
* <attribute name="indeterminatePosition"
* type="gml:TimeIndeterminateValueType" use="optional"/>
* </extension>
* </simpleContent>
* </complexType>
*
* </code>
* </pre>
*
* </p>
*
* @generated
*/
public class TimePositionTypeBinding extends AbstractComplexBinding {
/**
* @generated
*/
public QName getTarget() {
return GML.TimePositionType;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated modifiable
*/
public Class getType() {
return Position.class;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated modifiable
*/
public Object parse(ElementInstance instance, Node node, Object value)
throws Exception {
Position timePosition = new DefaultPosition(new SimpleInternationalString((String) value));
return timePosition;
}
/*
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public Element encode(Object object, Document document, Element value)
throws Exception {
Position timePosition = (Position) object;
if (timePosition == null) {
value.appendChild(document.createElementNS(GML.NAMESPACE, org.geotools.gml3.GML.Null.getLocalPart()));
}
value.appendChild(document.createTextNode(timePosition.getDateTime().toString()));
return null;
}
public Object getProperty(Object object, QName name) {
Position value = (Position) object;
if (name.getLocalPart().equals("frame")) {
return "ISO-8601";
}
if (name.getLocalPart().equals("calendarEraName")) {
return null;
}
if (name.getLocalPart().equals("indeterminatePosition")) {
return null;
}
return null;
}
}