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

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

ohair@286: * ohair@286: *

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

ohair@286: * ohair@286: *

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

ohair@286: * ohair@286: *

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

ohair@286: * ohair@286: *

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

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

ohair@286: * @author

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

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

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

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

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

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

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

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

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

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

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

ohair@286: * Converts the string argument into a QName value. ohair@286: * ohair@286: *

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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