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.bind.ValidationException;
019: import javax.xml.namespace.QName;
020:
021: import org.geotools.xml.InstanceComponent;
022: import org.geotools.xml.SimpleBinding;
023:
024: /**
025: * Binding object for the type http://www.w3.org/2001/XMLSchema:negativeInteger.
026: *
027: * <p>
028: * <pre>
029: * <code>
030: * <xs:simpleType name="negativeInteger" id="negativeInteger">
031: * <xs:annotation>
032: * <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#negativeInteger"/>
033: * </xs:annotation>
034: * <xs:restriction base="xs:nonPositiveInteger">
035: * <xs:maxInclusive value="-1" id="negativeInteger.maxInclusive"/>
036: * </xs:restriction>
037: * </xs:simpleType>
038: *
039: * </code>
040: * </pre>
041: * </p>
042: *
043: * @generated
044: */
045: public class XSNegativeIntegerBinding implements SimpleBinding {
046: /**
047: * @generated
048: */
049: public QName getTarget() {
050: return XS.NEGATIVEINTEGER;
051: }
052:
053: /**
054: * <!-- begin-user-doc -->
055: * <!-- end-user-doc -->
056: *
057: * @generated modifiable
058: */
059: public int getExecutionMode() {
060: return AFTER;
061: }
062:
063: /**
064: * <!-- begin-user-doc -->
065: * This method returns objects of type {@link Number}.
066: * <!-- end-user-doc -->
067: *
068: * @generated modifiable
069: */
070: public Class getType() {
071: return Number.class;
072: }
073:
074: /**
075: *
076: * <!-- begin-user-doc -->
077: * This method returns objects of type {@link Number}. The value returned
078: * is negative.
079: * <!-- end-user-doc -->
080: *
081: * @generated modifiable
082: */
083: public Object parse(InstanceComponent instance, Object value)
084: throws Exception {
085: Number number = (Number) value;
086:
087: if (number.intValue() == 0) {
088: throw new ValidationException("negativeInteger value '"
089: + number + "' required to be negative");
090: }
091:
092: return number;
093: }
094:
095: /**
096: * <!-- begin-user-doc -->
097: * <!-- end-user-doc -->
098: *
099: * @generated modifiable
100: */
101: public String encode(Object object, String value) {
102: //TODO: implement
103: return null;
104: }
105: }
|