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