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