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:short.
025: *
026: * <p>
027: * <pre>
028: * <code>
029: * <xs:simpleType name="short" id="short">
030: * <xs:annotation>
031: * <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#short"/>
032: * </xs:annotation>
033: * <xs:restriction base="xs:int">
034: * <xs:minInclusive value="-32768" id="short.minInclusive"/>
035: * <xs:maxInclusive value="32767" id="short.maxInclusive"/>
036: * </xs:restriction>
037: * </xs:simpleType>
038: *
039: * </code>
040: * </pre>
041: * </p>
042: *
043: * @generated
044: */
045: public class XSShortBinding implements SimpleBinding {
046: /**
047: * @generated
048: */
049: public QName getTarget() {
050: return XS.SHORT;
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 Short}.
066: * <!-- end-user-doc -->
067: *
068: * @generated modifiable
069: */
070: public Class getType() {
071: return Short.class;
072: }
073:
074: /**
075: * <!-- begin-user-doc -->
076: * This binding returns objects of type {@link Short}.
077: * <!-- end-user-doc -->
078: *
079: * @generated modifiable
080: */
081: public Object parse(InstanceComponent instance, Object value)
082: throws Exception {
083: String text = instance.getText();
084:
085: if (text.charAt(0) == '+') {
086: text = text.substring(1);
087: }
088:
089: return new Short(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: Short s = (Short) object;
100:
101: return s.toString();
102: }
103: }
|