aoqi@0: /* aoqi@0: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package javax.xml.bind; aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * The DatatypeConverterInterface is for JAXB provider use only. A aoqi@0: * JAXB provider must supply a class that implements this interface. aoqi@0: * JAXB Providers are required to call the aoqi@0: * {@link DatatypeConverter#setDatatypeConverter(DatatypeConverterInterface) aoqi@0: * DatatypeConverter.setDatatypeConverter} api at aoqi@0: * some point before the first marshal or unmarshal operation (perhaps during aoqi@0: * the call to JAXBContext.newInstance). This step is necessary to configure aoqi@0: * the converter that should be used to perform the print and parse aoqi@0: * functionality. Calling this api repeatedly will have no effect - the aoqi@0: * DatatypeConverter instance passed into the first invocation is the one that aoqi@0: * will be used from then on. aoqi@0: *

aoqi@0: * aoqi@0: *

aoqi@0: * This interface defines the parse and print methods. There is one aoqi@0: * parse and print method for each XML schema datatype specified in the aoqi@0: * the default binding Table 5-1 in the JAXB specification. aoqi@0: *

aoqi@0: * aoqi@0: *

aoqi@0: * The parse and print methods defined here are invoked by the static parse aoqi@0: * and print methods defined in the {@link DatatypeConverter DatatypeConverter} aoqi@0: * class. aoqi@0: *

aoqi@0: * aoqi@0: *

aoqi@0: * A parse method for a XML schema datatype must be capable of converting any aoqi@0: * lexical representation of the XML schema datatype ( specified by the aoqi@0: * XML Schema Part2: Datatypes aoqi@0: * specification into a value in the value space of the XML schema datatype. aoqi@0: * If an error is encountered during conversion, then an IllegalArgumentException aoqi@0: * or a subclass of IllegalArgumentException must be thrown by the method. aoqi@0: * aoqi@0: *

aoqi@0: * aoqi@0: *

aoqi@0: * A print method for a XML schema datatype can output any lexical aoqi@0: * representation that is valid with respect to the XML schema datatype. aoqi@0: * If an error is encountered during conversion, then an IllegalArgumentException, aoqi@0: * or a subclass of IllegalArgumentException must be thrown by the method. aoqi@0: *

aoqi@0: * aoqi@0: * The prefix xsd: is used to refer to XML schema datatypes aoqi@0: * XML Schema Part2: Datatypes aoqi@0: * specification. aoqi@0: * aoqi@0: *

aoqi@0: * @author

aoqi@0: * @see DatatypeConverter aoqi@0: * @see ParseConversionEvent aoqi@0: * @see PrintConversionEvent aoqi@0: * @since JAXB1.0 aoqi@0: */ aoqi@0: aoqi@0: public interface DatatypeConverterInterface { aoqi@0: /** aoqi@0: *

aoqi@0: * Convert the string argument into a string. aoqi@0: * @param lexicalXSDString aoqi@0: * A lexical representation of the XML Schema datatype xsd:string aoqi@0: * @return aoqi@0: * A string that is the same as the input string. aoqi@0: */ aoqi@0: public String parseString( String lexicalXSDString ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Convert the string argument into a BigInteger value. aoqi@0: * @param lexicalXSDInteger aoqi@0: * A string containing a lexical representation of aoqi@0: * xsd:integer. aoqi@0: * @return aoqi@0: * A BigInteger value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDInteger is not a valid string representation of a {@link java.math.BigInteger} value. aoqi@0: */ aoqi@0: public java.math.BigInteger parseInteger( String lexicalXSDInteger ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Convert the string argument into an int value. aoqi@0: * @param lexicalXSDInt aoqi@0: * A string containing a lexical representation of aoqi@0: * xsd:int. aoqi@0: * @return aoqi@0: * An int value represented byte the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDInt is not a valid string representation of an int value. aoqi@0: */ aoqi@0: public int parseInt( String lexicalXSDInt ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a long value. aoqi@0: * @param lexicalXSDLong aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:long. aoqi@0: * @return aoqi@0: * A long value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDLong is not a valid string representation of a long value. aoqi@0: */ aoqi@0: public long parseLong( String lexicalXSDLong ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a short value. aoqi@0: * @param lexicalXSDShort aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:short. aoqi@0: * @return aoqi@0: * A short value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDShort is not a valid string representation of a short value. aoqi@0: */ aoqi@0: public short parseShort( String lexicalXSDShort ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a BigDecimal value. aoqi@0: * @param lexicalXSDDecimal aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:decimal. aoqi@0: * @return aoqi@0: * A BigDecimal value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDDecimal is not a valid string representation of {@link java.math.BigDecimal}. aoqi@0: */ aoqi@0: public java.math.BigDecimal parseDecimal( String lexicalXSDDecimal ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a float value. aoqi@0: * @param lexicalXSDFloat aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:float. aoqi@0: * @return aoqi@0: * A float value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDFloat is not a valid string representation of a float value. aoqi@0: */ aoqi@0: public float parseFloat( String lexicalXSDFloat ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a double value. aoqi@0: * @param lexicalXSDDouble aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:double. aoqi@0: * @return aoqi@0: * A double value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDDouble is not a valid string representation of a double value. aoqi@0: */ aoqi@0: public double parseDouble( String lexicalXSDDouble ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a boolean value. aoqi@0: * @param lexicalXSDBoolean aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:boolean. aoqi@0: * @return aoqi@0: * A boolean value represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean. aoqi@0: */ aoqi@0: public boolean parseBoolean( String lexicalXSDBoolean ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a byte value. aoqi@0: * @param lexicalXSDByte aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:byte. aoqi@0: * @return aoqi@0: * A byte value represented by the string argument. aoqi@0: * @throws NumberFormatException lexicalXSDByte does not contain a parseable byte. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:byte. aoqi@0: */ aoqi@0: public byte parseByte( String lexicalXSDByte ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a QName value. aoqi@0: * aoqi@0: *

aoqi@0: * String parameter lexicalXSDQname must conform to lexical value space specifed at aoqi@0: * XML Schema Part 2:Datatypes specification:QNames aoqi@0: * aoqi@0: * @param lexicalXSDQName aoqi@0: * A string containing lexical representation of xsd:QName. aoqi@0: * @param nsc aoqi@0: * A namespace context for interpreting a prefix within a QName. aoqi@0: * @return aoqi@0: * A QName value represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to XML Schema Part 2 specification or aoqi@0: * if namespace prefix of lexicalXSDQname is not bound to a URI in NamespaceContext nsc. aoqi@0: */ aoqi@0: public javax.xml.namespace.QName parseQName( String lexicalXSDQName, aoqi@0: javax.xml.namespace.NamespaceContext nsc); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a Calendar value. aoqi@0: * @param lexicalXSDDateTime aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:datetime. aoqi@0: * @return aoqi@0: * A Calendar object represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:dateTime. aoqi@0: */ aoqi@0: public java.util.Calendar parseDateTime( String lexicalXSDDateTime ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into an array of bytes. aoqi@0: * @param lexicalXSDBase64Binary aoqi@0: * A string containing lexical representation aoqi@0: * of xsd:base64Binary. aoqi@0: * @return aoqi@0: * An array of bytes represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:base64Binary aoqi@0: */ aoqi@0: public byte[] parseBase64Binary( String lexicalXSDBase64Binary ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into an array of bytes. aoqi@0: * @param lexicalXSDHexBinary aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:hexBinary. aoqi@0: * @return aoqi@0: * An array of bytes represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary. aoqi@0: */ aoqi@0: public byte[] parseHexBinary( String lexicalXSDHexBinary ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a long value. aoqi@0: * @param lexicalXSDUnsignedInt aoqi@0: * A string containing lexical representation aoqi@0: * of xsd:unsignedInt. aoqi@0: * @return aoqi@0: * A long value represented by the string argument. aoqi@0: * @throws NumberFormatException if string parameter can not be parsed into a long value. aoqi@0: */ aoqi@0: public long parseUnsignedInt( String lexicalXSDUnsignedInt ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into an int value. aoqi@0: * @param lexicalXSDUnsignedShort aoqi@0: * A string containing lexical aoqi@0: * representation of xsd:unsignedShort. aoqi@0: * @return aoqi@0: * An int value represented by the string argument. aoqi@0: * @throws NumberFormatException if string parameter can not be parsed into an int value. aoqi@0: */ aoqi@0: public int parseUnsignedShort( String lexicalXSDUnsignedShort ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a Calendar value. aoqi@0: * @param lexicalXSDTime aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:Time. aoqi@0: * @return aoqi@0: * A Calendar value represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Time. aoqi@0: */ aoqi@0: public java.util.Calendar parseTime( String lexicalXSDTime ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a Calendar value. aoqi@0: * @param lexicalXSDDate aoqi@0: * A string containing lexical representation of aoqi@0: * xsd:Date. aoqi@0: * @return aoqi@0: * A Calendar value represented by the string argument. aoqi@0: * @throws IllegalArgumentException if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Date. aoqi@0: */ aoqi@0: public java.util.Calendar parseDate( String lexicalXSDDate ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Return a string containing the lexical representation of the aoqi@0: * simple type. aoqi@0: * @param lexicalXSDAnySimpleType aoqi@0: * A string containing lexical aoqi@0: * representation of the simple type. aoqi@0: * @return aoqi@0: * A string containing the lexical representation of the aoqi@0: * simple type. aoqi@0: */ aoqi@0: public String parseAnySimpleType( String lexicalXSDAnySimpleType ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts the string argument into a string. aoqi@0: * @param val aoqi@0: * A string value. aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:string aoqi@0: */ aoqi@0: public String printString( String val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a BigInteger value into a string. aoqi@0: * @param val aoqi@0: * A BigInteger value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:integer aoqi@0: * @throws IllegalArgumentException val is null. aoqi@0: */ aoqi@0: public String printInteger( java.math.BigInteger val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts an int value into a string. aoqi@0: * @param val aoqi@0: * An int value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:int aoqi@0: */ aoqi@0: public String printInt( int val ); aoqi@0: aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a long value into a string. aoqi@0: * @param val aoqi@0: * A long value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:long aoqi@0: */ aoqi@0: public String printLong( long val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a short value into a string. aoqi@0: * @param val aoqi@0: * A short value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:short aoqi@0: */ aoqi@0: public String printShort( short val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a BigDecimal value into a string. aoqi@0: * @param val aoqi@0: * A BigDecimal value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:decimal aoqi@0: * @throws IllegalArgumentException val is null. aoqi@0: */ aoqi@0: public String printDecimal( java.math.BigDecimal val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a float value into a string. aoqi@0: * @param val aoqi@0: * A float value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:float aoqi@0: */ aoqi@0: public String printFloat( float val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a double value into a string. aoqi@0: * @param val aoqi@0: * A double value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:double aoqi@0: */ aoqi@0: public String printDouble( double val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a boolean value into a string. aoqi@0: * @param val aoqi@0: * A boolean value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:boolean aoqi@0: */ aoqi@0: public String printBoolean( boolean val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a byte value into a string. aoqi@0: * @param val aoqi@0: * A byte value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:byte aoqi@0: */ aoqi@0: public String printByte( byte val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a QName instance into a string. aoqi@0: * @param val aoqi@0: * A QName value aoqi@0: * @param nsc aoqi@0: * A namespace context for interpreting a prefix within a QName. aoqi@0: * @return aoqi@0: * A string containing a lexical representation of QName aoqi@0: * @throws IllegalArgumentException if val is null or aoqi@0: * if nsc is non-null or nsc.getPrefix(nsprefixFromVal) is null. aoqi@0: */ aoqi@0: public String printQName( javax.xml.namespace.QName val, aoqi@0: javax.xml.namespace.NamespaceContext nsc ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a Calendar value into a string. aoqi@0: * @param val aoqi@0: * A Calendar value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:dateTime aoqi@0: * @throws IllegalArgumentException if val is null. aoqi@0: */ aoqi@0: public String printDateTime( java.util.Calendar val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts an array of bytes into a string. aoqi@0: * @param val aoqi@0: * an array of bytes aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:base64Binary aoqi@0: * @throws IllegalArgumentException if val is null. aoqi@0: */ aoqi@0: public String printBase64Binary( byte[] val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts an array of bytes into a string. aoqi@0: * @param val aoqi@0: * an array of bytes aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:hexBinary aoqi@0: * @throws IllegalArgumentException if val is null. aoqi@0: */ aoqi@0: public String printHexBinary( byte[] val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a long value into a string. aoqi@0: * @param val aoqi@0: * A long value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:unsignedInt aoqi@0: */ aoqi@0: public String printUnsignedInt( long val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts an int value into a string. aoqi@0: * @param val aoqi@0: * An int value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:unsignedShort aoqi@0: */ aoqi@0: public String printUnsignedShort( int val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a Calendar value into a string. aoqi@0: * @param val aoqi@0: * A Calendar value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:time aoqi@0: * @throws IllegalArgumentException if val is null. aoqi@0: */ aoqi@0: public String printTime( java.util.Calendar val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a Calendar value into a string. aoqi@0: * @param val aoqi@0: * A Calendar value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:date aoqi@0: * @throws IllegalArgumentException if val is null. aoqi@0: */ aoqi@0: public String printDate( java.util.Calendar val ); aoqi@0: aoqi@0: /** aoqi@0: *

aoqi@0: * Converts a string value into a string. aoqi@0: * @param val aoqi@0: * A string value aoqi@0: * @return aoqi@0: * A string containing a lexical representation of xsd:AnySimpleType aoqi@0: */ aoqi@0: public String printAnySimpleType( String val ); aoqi@0: }