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:time.
030: *
031: * <p>
032: * <pre>
033: * <code>
034: * <xs:simpleType name="time" id="time">
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/#time"/>
050: * </xs:annotation>
051: * <xs:restriction base="xs:anySimpleType">
052: * <xs:whiteSpace value="collapse" fixed="true" id="time.whiteSpace"/>
053: * </xs:restriction>
054: * </xs:simpleType>
055: *
056: * </code>
057: * </pre>
058: * </p>
059: *
060: * @generated
061: */
062: public class XSTimeBinding implements SimpleBinding {
063: /**
064: * @generated
065: */
066: public QName getTarget() {
067: return XS.TIME;
068: }
069:
070: /**
071: * <!-- begin-user-doc -->
072: * <!-- end-user-doc -->
073: *
074: * @generated modifiable
075: */
076: public int getExecutionMode() {
077: return AFTER;
078: }
079:
080: /**
081: * <!-- begin-user-doc -->
082: * This binding returns objects of type {@link Calendar}.
083: * <!-- end-user-doc -->
084: *
085: * @generated modifiable
086: */
087: public Class getType() {
088: return Calendar.class;
089: }
090:
091: /**
092: * <!-- begin-user-doc -->
093: * This binding returns objects of type {@link Calendar}.
094: * <!-- end-user-doc -->
095: *
096: * @generated modifiable
097: */
098: public Object parse(InstanceComponent instance, Object value)
099: throws Exception {
100: DatatypeConverter
101: .setDatatypeConverter(DatatypeConverterImpl.theInstance);
102:
103: return DatatypeConverter.parseTime((String) value);
104: }
105:
106: /**
107: * <!-- begin-user-doc -->
108: * <!-- end-user-doc -->
109: *
110: * @generated modifiable
111: */
112: public String encode(Object object, String value) {
113: Calendar calendar = (Calendar) object;
114:
115: return DatatypeConverter.printTime(calendar);
116: }
117: }
|