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.DatatypeConverter;
019: import javax.xml.namespace.QName;
020:
021: import org.geotools.xml.InstanceComponent;
022: import org.geotools.xml.SimpleBinding;
023:
024: import com.sun.xml.bind.DatatypeConverterImpl;
025:
026: /**
027: * Binding object for the type http://www.w3.org/2001/XMLSchema:hexBinary.
028: *
029: * <p>
030: * <pre>
031: * <code>
032: * <xs:simpleType name="hexBinary" id="hexBinary">
033: * <xs:annotation>
034: * <xs:appinfo>
035: * <hfp:hasFacet name="length"/>
036: * <hfp:hasFacet name="minLength"/>
037: * <hfp:hasFacet name="maxLength"/>
038: * <hfp:hasFacet name="pattern"/>
039: * <hfp:hasFacet name="enumeration"/>
040: * <hfp:hasFacet name="whiteSpace"/>
041: * <hfp:hasProperty name="ordered" value="false"/>
042: * <hfp:hasProperty name="bounded" value="false"/>
043: * <hfp:hasProperty name="cardinality" value="countably infinite"/>
044: * <hfp:hasProperty name="numeric" value="false"/>
045: * </xs:appinfo>
046: * <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#binary"/>
047: * </xs:annotation>
048: * <xs:restriction base="xs:anySimpleType">
049: * <xs:whiteSpace value="collapse" fixed="true" id="hexBinary.whiteSpace"/>
050: * </xs:restriction>
051: * </xs:simpleType>
052: *
053: * </code>
054: * </pre>
055: * </p>
056: *
057: * @generated
058: */
059: public class XSHexBinaryBinding implements SimpleBinding {
060:
061: public XSHexBinaryBinding() {
062: DatatypeConverter
063: .setDatatypeConverter(DatatypeConverterImpl.theInstance);
064: }
065:
066: /**
067: * @generated
068: */
069: public QName getTarget() {
070: return XS.HEXBINARY;
071: }
072:
073: /**
074: * <!-- begin-user-doc -->
075: * <!-- end-user-doc -->
076: *
077: * @generated modifiable
078: */
079: public int getExecutionMode() {
080: return AFTER;
081: }
082:
083: /**
084: * <!-- begin-user-doc -->
085: * <!-- end-user-doc -->
086: *
087: * @generated modifiable
088: */
089: public Class getType() {
090: return byte[].class;
091: }
092:
093: /**
094: * <!-- begin-user-doc -->
095: * <!-- end-user-doc -->
096: *
097: * @generated modifiable
098: */
099: public Object parse(InstanceComponent instance, Object value)
100: throws Exception {
101:
102: return DatatypeConverter.parseHexBinary((String) value);
103: }
104:
105: /**
106: * <!-- begin-user-doc -->
107: * <!-- end-user-doc -->
108: *
109: * @generated modifiable
110: */
111: public String encode(Object object, String value) {
112: return DatatypeConverter.printHexBinary((byte[]) object);
113: }
114: }
|