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:long.
025: *
026: * <p>
027: * <pre>
028: * <code>
029: * <xs:simpleType name="long" id="long">
030: * <xs:annotation>
031: * <xs:appinfo>
032: * <hfp:hasProperty name="bounded" value="true"/>
033: * <hfp:hasProperty name="cardinality" value="finite"/>
034: * </xs:appinfo>
035: * <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#long"/>
036: * </xs:annotation>
037: * <xs:restriction base="xs:integer">
038: * <xs:minInclusive value="-9223372036854775808" id="long.minInclusive"/>
039: * <xs:maxInclusive value="9223372036854775807" id="long.maxInclusive"/>
040: * </xs:restriction>
041: * </xs:simpleType>
042: *
043: * </code>
044: * </pre>
045: * </p>
046: *
047: * @generated
048: */
049: public class XSLongBinding implements SimpleBinding {
050: /**
051: * @generated
052: */
053: public QName getTarget() {
054: return XS.LONG;
055: }
056:
057: /**
058: * <!-- begin-user-doc -->
059: * <!-- end-user-doc -->
060: *
061: * @generated modifiable
062: */
063: public int getExecutionMode() {
064: return OVERRIDE;
065: }
066:
067: /**
068: * <!-- begin-user-doc -->
069: * This binding returns objects of type {@link Long}.
070: * <!-- end-user-doc -->
071: *
072: * @generated modifiable
073: */
074: public Class getType() {
075: return Long.class;
076: }
077:
078: /**
079: * <!-- begin-user-doc -->
080: * This binding returns objects of type {@link Long}.
081: * <!-- end-user-doc -->
082: *
083: * @generated modifiable
084: */
085: public Object parse(InstanceComponent instance, Object value)
086: throws Exception {
087: String text = (String) value;
088:
089: if (text.charAt(0) == '+') {
090: text = text.substring(1);
091: }
092:
093: return new Long(text);
094: }
095:
096: /**
097: * <!-- begin-user-doc -->
098: * <!-- end-user-doc -->
099: *
100: * @generated modifiable
101: */
102: public String encode(Object object, String value) {
103: Long l = (Long) object;
104:
105: return l.toString();
106: }
107: }
|