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.xs.bindings;
017:
018: import java.util.Calendar;
019:
020: import javax.xml.bind.DatatypeConverter;
021: import javax.xml.namespace.QName;
022:
023: import org.geotools.xml.InstanceComponent;
024: import org.geotools.xml.SimpleBinding;
025:
026: import com.sun.xml.bind.DatatypeConverterImpl;
027:
028: /**
029: * Binding object for the type http://www.w3.org/2001/XMLSchema:dateTime.
030: *
031: * <p>
032: * <pre>
033: * <code>
034: * <xs:simpleType name="dateTime" id="dateTime">
035: * <xs:annotation>
036: * <xs:appinfo>
037: * <hfp:hasFacet name="pattern"/>
038: * <hfp:hasFacet name="enumeration"/>
039: * <hfp:hasFacet name="whiteSpace"/>
040: * <hfp:hasFacet name="maxInclusive"/>
041: * <hfp:hasFacet name="maxExclusive"/>
042: * <hfp:hasFacet name="minInclusive"/>
043: * <hfp:hasFacet name="minExclusive"/>
044: * <hfp:hasProperty name="ordered" value="partial"/>
045: * <hfp:hasProperty name="bounded" value="false"/>
046: * <hfp:hasProperty name="cardinality" value="countably infinite"/>
047: * <hfp:hasProperty name="numeric" value="false"/>
048: * </xs:appinfo>
049: * <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#dateTime"/>
050: * </xs:annotation>
051: * <xs:restriction base="xs:anySimpleType">
052: * <xs:whiteSpace value="collapse" fixed="true" id="dateTime.whiteSpace"/>
053: * </xs:restriction>
054: * </xs:simpleType>
055: *
056: * </code>
057: * </pre>
058: * </p>
059: *
060: * @generated
061: */
062: public class XSDateTimeBinding implements SimpleBinding {
063:
064: static {
065: DatatypeConverter
066: .setDatatypeConverter(DatatypeConverterImpl.theInstance);
067: }
068:
069: /**
070: * @generated
071: */
072: public QName getTarget() {
073: return XS.DATETIME;
074: }
075:
076: /**
077: * <!-- begin-user-doc -->
078: * <!-- end-user-doc -->
079: *
080: * @generated modifiable
081: */
082: public int getExecutionMode() {
083: return OVERRIDE;
084: }
085:
086: /**
087: * <!-- begin-user-doc -->
088: * This binding returns objects of type {@link Calendar}.
089: * <!-- end-user-doc -->
090: *
091: * @generated modifiable
092: */
093: public Class getType() {
094: return Calendar.class;
095: }
096:
097: /**
098: * <!-- begin-user-doc -->
099: * This binding returns objects of type {@link Calendar}.
100: * <!-- end-user-doc -->
101: *
102: * @generated modifiable
103: */
104: public Object parse(InstanceComponent instance, Object value)
105: throws Exception {
106:
107: return DatatypeConverter.parseDateTime((String) value);
108: }
109:
110: /**
111: * <!-- begin-user-doc -->
112: * <!-- end-user-doc -->
113: *
114: * @generated modifiable
115: */
116: public String encode(Object object, String value) {
117: Calendar datetime = (Calendar) object;
118:
119: return DatatypeConverter.printDateTime(datetime);
120: }
121: }
|