Top Description Methods
javax.xml.bind

public Interface DatatypeConverterInterface

Known Direct Implementers
javax.xml.bind.DatatypeConverterImpl

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

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

The parse and print methods defined here are invoked by the static parse and print methods defined in the DatatypeConverter class.

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

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

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

Author
Since
1.6, JAXB 1.0
See Also
DatatypeConverter, ParseConversionEvent, PrintConversionEvent

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

A string containing the lexical representation of the simple type.
parseAnySimpleType
(String
A string containing lexical representation of the simple type.
lexicalXSDAnySimpleType
)

Return a string containing the lexical representation of the simple type.

public byte[]

Returns:

An array of bytes represented by the string argument.
parseBase64Binary
(String
A string containing lexical representation of xsd:base64Binary.
lexicalXSDBase64Binary
)

Converts the string argument into an array of bytes.

public boolean

Returns:

A boolean value represented by the string argument.
parseBoolean
(String
A string containing lexical representation of xsd:boolean.
lexicalXSDBoolean
)

Converts the string argument into a boolean value.

public byte

Returns:

A byte value represented by the string argument.
parseByte
(String
A string containing lexical representation of xsd:byte.
lexicalXSDByte
)

Converts the string argument into a byte value.

public Calendar

Returns:

A Calendar value represented by the string argument.
parseDate
(String
A string containing lexical representation of xsd:Date.
lexicalXSDDate
)

Converts the string argument into a Calendar value.

public Calendar

Returns:

A Calendar object represented by the string argument.
parseDateTime
(String
A string containing lexical representation of xsd:datetime.
lexicalXSDDateTime
)

Converts the string argument into a Calendar value.

public BigDecimal

Returns:

A BigDecimal value represented by the string argument.
parseDecimal
(String
A string containing lexical representation of xsd:decimal.
lexicalXSDDecimal
)

Converts the string argument into a BigDecimal value.

public double

Returns:

A double value represented by the string argument.
parseDouble
(String
A string containing lexical representation of xsd:double.
lexicalXSDDouble
)

Converts the string argument into a double value.

public float

Returns:

A float value represented by the string argument.
parseFloat
(String
A string containing lexical representation of xsd:float.
lexicalXSDFloat
)

Converts the string argument into a float value.

public byte[]

Returns:

An array of bytes represented by the string argument.
parseHexBinary
(String
A string containing lexical representation of xsd:hexBinary.
lexicalXSDHexBinary
)

Converts the string argument into an array of bytes.

public int

Returns:

An int value represented byte the string argument.
parseInt
(String
A string containing a lexical representation of xsd:int.
lexicalXSDInt
)

Convert the string argument into an int value.

public BigInteger

Returns:

A BigInteger value represented by the string argument.
parseInteger
(String
A string containing a lexical representation of xsd:integer.
lexicalXSDInteger
)

Convert the string argument into a BigInteger value.

public long

Returns:

A long value represented by the string argument.
parseLong
(String
A string containing lexical representation of xsd:long.
lexicalXSDLong
)

Converts the string argument into a long value.

public QName

Returns:

A QName value represented by the string argument.
parseQName
(String
A string containing lexical representation of xsd:QName.
lexicalXSDQName
,
NamespaceContext
A namespace context for interpreting a prefix within a QName.
nsc
)

Converts the string argument into a QName value.

public short

Returns:

A short value represented by the string argument.
parseShort
(String
A string containing lexical representation of xsd:short.
lexicalXSDShort
)

Converts the string argument into a short value.

public String

Returns:

A string that is the same as the input string.
parseString
(String
A lexical representation of the XML Schema datatype xsd:string
lexicalXSDString
)

Convert the string argument into a string.

public Calendar

Returns:

A Calendar value represented by the string argument.
parseTime
(String
A string containing lexical representation of xsd:Time.
lexicalXSDTime
)

Converts the string argument into a Calendar value.

public long

Returns:

A long value represented by the string argument.
parseUnsignedInt
(String
A string containing lexical representation of xsd:unsignedInt.
lexicalXSDUnsignedInt
)

Converts the string argument into a long value.

public int

Returns:

An int value represented by the string argument.
parseUnsignedShort
(String
A string containing lexical representation of xsd:unsignedShort.
lexicalXSDUnsignedShort
)

Converts the string argument into an int value.

public String

Returns:

A string containing a lexical representation of xsd:AnySimpleType
printAnySimpleType
(String
A string value
val
)

Converts a string value into a string.

public String

Returns:

A string containing a lexical representation of xsd:base64Binary
printBase64Binary
(byte[]
an array of bytes
val
)

Converts an array of bytes into a string.

public String

Returns:

A string containing a lexical representation of xsd:boolean
printBoolean
(boolean
A boolean value
val
)

Converts a boolean value into a string.

public String

Returns:

A string containing a lexical representation of xsd:byte
printByte
(byte
A byte value
val
)

Converts a byte value into a string.

public String

Returns:

A string containing a lexical representation of xsd:date
printDate
(Calendar
A Calendar value
val
)

Converts a Calendar value into a string.

public String

Returns:

A string containing a lexical representation of xsd:dateTime
printDateTime
(Calendar
A Calendar value
val
)

Converts a Calendar value into a string.

public String

Returns:

A string containing a lexical representation of xsd:decimal
printDecimal
(BigDecimal
A BigDecimal value
val
)

Converts a BigDecimal value into a string.

public String

Returns:

A string containing a lexical representation of xsd:double
printDouble
(double
A double value
val
)

Converts a double value into a string.

public String

Returns:

A string containing a lexical representation of xsd:float
printFloat
(float
A float value
val
)

Converts a float value into a string.

public String

Returns:

A string containing a lexical representation of xsd:hexBinary
printHexBinary
(byte[]
an array of bytes
val
)

Converts an array of bytes into a string.

public String

Returns:

A string containing a lexical representation of xsd:int
printInt
(int
An int value
val
)

Converts an int value into a string.

public String

Returns:

A string containing a lexical representation of xsd:integer
printInteger
(BigInteger
A BigInteger value
val
)

Converts a BigInteger value into a string.

public String

Returns:

A string containing a lexical representation of xsd:long
printLong
(long
A long value
val
)

Converts a long value into a string.

public String

Returns:

A string containing a lexical representation of QName
printQName
(QName
A QName value
val
,
NamespaceContext
A namespace context for interpreting a prefix within a QName.
nsc
)

Converts a QName instance into a string.

public String

Returns:

A string containing a lexical representation of xsd:short
printShort
(short
A short value
val
)

Converts a short value into a string.

public String

Returns:

A string containing a lexical representation of xsd:string
printString
(String
A string value.
val
)

Converts the string argument into a string.

public String

Returns:

A string containing a lexical representation of xsd:time
printTime
(Calendar
A Calendar value
val
)

Converts a Calendar value into a string.

public String

Returns:

A string containing a lexical representation of xsd:unsignedInt
printUnsignedInt
(long
A long value
val
)

Converts a long value into a string.

public String

Returns:

A string containing a lexical representation of xsd:unsignedShort
printUnsignedShort
(int
An int value
val
)

Converts an int value into a string.

Method Detail

parseAnySimpleTypeback to summary
public String parseAnySimpleType(String lexicalXSDAnySimpleType)

Return a string containing the lexical representation of the simple type.

Parameters
lexicalXSDAnySimpleType:String

A string containing lexical representation of the simple type.

Returns:String

A string containing the lexical representation of the simple type.

parseBase64Binaryback to summary
public byte[] parseBase64Binary(String lexicalXSDBase64Binary)

Converts the string argument into an array of bytes.

Parameters
lexicalXSDBase64Binary:String

A string containing lexical representation of xsd:base64Binary.

Returns:byte[]

An array of bytes represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:base64Binary
parseBooleanback to summary
public boolean parseBoolean(String lexicalXSDBoolean)

Converts the string argument into a boolean value.

Parameters
lexicalXSDBoolean:String

A string containing lexical representation of xsd:boolean.

Returns:boolean

A boolean value represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean.
parseByteback to summary
public byte parseByte(String lexicalXSDByte)

Converts the string argument into a byte value.

Parameters
lexicalXSDByte:String

A string containing lexical representation of xsd:byte.

Returns:byte

A byte value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDByte does not contain a parseable byte.
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:byte.
parseDateback to summary
public Calendar parseDate(String lexicalXSDDate)

Converts the string argument into a Calendar value.

Parameters
lexicalXSDDate:String

A string containing lexical representation of xsd:Date.

Returns:Calendar

A Calendar value represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Date.
parseDateTimeback to summary
public Calendar parseDateTime(String lexicalXSDDateTime)

Converts the string argument into a Calendar value.

Parameters
lexicalXSDDateTime:String

A string containing lexical representation of xsd:datetime.

Returns:Calendar

A Calendar object represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:dateTime.
parseDecimalback to summary
public BigDecimal parseDecimal(String lexicalXSDDecimal)

Converts the string argument into a BigDecimal value.

Parameters
lexicalXSDDecimal:String

A string containing lexical representation of xsd:decimal.

Returns:BigDecimal

A BigDecimal value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDDecimal is not a valid string representation of java.math.BigDecimal.
parseDoubleback to summary
public double parseDouble(String lexicalXSDDouble)

Converts the string argument into a double value.

Parameters
lexicalXSDDouble:String

A string containing lexical representation of xsd:double.

Returns:double

A double value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDDouble is not a valid string representation of a double value.
parseFloatback to summary
public float parseFloat(String lexicalXSDFloat)

Converts the string argument into a float value.

Parameters
lexicalXSDFloat:String

A string containing lexical representation of xsd:float.

Returns:float

A float value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDFloat is not a valid string representation of a float value.
parseHexBinaryback to summary
public byte[] parseHexBinary(String lexicalXSDHexBinary)

Converts the string argument into an array of bytes.

Parameters
lexicalXSDHexBinary:String

A string containing lexical representation of xsd:hexBinary.

Returns:byte[]

An array of bytes represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
parseIntback to summary
public int parseInt(String lexicalXSDInt)

Convert the string argument into an int value.

Parameters
lexicalXSDInt:String

A string containing a lexical representation of xsd:int.

Returns:int

An int value represented byte the string argument.

Exceptions
NumberFormatException:
lexicalXSDInt is not a valid string representation of an int value.
parseIntegerback to summary
public BigInteger parseInteger(String lexicalXSDInteger)

Convert the string argument into a BigInteger value.

Parameters
lexicalXSDInteger:String

A string containing a lexical representation of xsd:integer.

Returns:BigInteger

A BigInteger value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDInteger is not a valid string representation of a java.math.BigInteger value.
parseLongback to summary
public long parseLong(String lexicalXSDLong)

Converts the string argument into a long value.

Parameters
lexicalXSDLong:String

A string containing lexical representation of xsd:long.

Returns:long

A long value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDLong is not a valid string representation of a long value.
parseQNameback to summary
public QName parseQName(String lexicalXSDQName, NamespaceContext nsc)

Converts the string argument into a QName value.

String parameter lexicalXSDQname must conform to lexical value space specifed at XML Schema Part 2:Datatypes specification:QNames

Parameters
lexicalXSDQName:String

A string containing lexical representation of xsd:QName.

nsc:NamespaceContext

A namespace context for interpreting a prefix within a QName.

Returns:QName

A QName value represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to XML Schema Part 2 specification or if namespace prefix of lexicalXSDQname is not bound to a URI in NamespaceContext nsc.
parseShortback to summary
public short parseShort(String lexicalXSDShort)

Converts the string argument into a short value.

Parameters
lexicalXSDShort:String

A string containing lexical representation of xsd:short.

Returns:short

A short value represented by the string argument.

Exceptions
NumberFormatException:
lexicalXSDShort is not a valid string representation of a short value.
parseStringback to summary
public String parseString(String lexicalXSDString)

Convert the string argument into a string.

Parameters
lexicalXSDString:String

A lexical representation of the XML Schema datatype xsd:string

Returns:String

A string that is the same as the input string.

parseTimeback to summary
public Calendar parseTime(String lexicalXSDTime)

Converts the string argument into a Calendar value.

Parameters
lexicalXSDTime:String

A string containing lexical representation of xsd:Time.

Returns:Calendar

A Calendar value represented by the string argument.

Exceptions
IllegalArgumentException:
if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Time.
parseUnsignedIntback to summary
public long parseUnsignedInt(String lexicalXSDUnsignedInt)

Converts the string argument into a long value.

Parameters
lexicalXSDUnsignedInt:String

A string containing lexical representation of xsd:unsignedInt.

Returns:long

A long value represented by the string argument.

Exceptions
NumberFormatException:
if string parameter can not be parsed into a long value.
parseUnsignedShortback to summary
public int parseUnsignedShort(String lexicalXSDUnsignedShort)

Converts the string argument into an int value.

Parameters
lexicalXSDUnsignedShort:String

A string containing lexical representation of xsd:unsignedShort.

Returns:int

An int value represented by the string argument.

Exceptions
NumberFormatException:
if string parameter can not be parsed into an int value.
printAnySimpleTypeback to summary
public String printAnySimpleType(String val)

Converts a string value into a string.

Parameters
val:String

A string value

Returns:String

A string containing a lexical representation of xsd:AnySimpleType

printBase64Binaryback to summary
public String printBase64Binary(byte[] val)

Converts an array of bytes into a string.

Parameters
val:byte[]

an array of bytes

Returns:String

A string containing a lexical representation of xsd:base64Binary

Exceptions
IllegalArgumentException:
if val is null.
printBooleanback to summary
public String printBoolean(boolean val)

Converts a boolean value into a string.

Parameters
val:boolean

A boolean value

Returns:String

A string containing a lexical representation of xsd:boolean

printByteback to summary
public String printByte(byte val)

Converts a byte value into a string.

Parameters
val:byte

A byte value

Returns:String

A string containing a lexical representation of xsd:byte

printDateback to summary
public String printDate(Calendar val)

Converts a Calendar value into a string.

Parameters
val:Calendar

A Calendar value

Returns:String

A string containing a lexical representation of xsd:date

Exceptions
IllegalArgumentException:
if val is null.
printDateTimeback to summary
public String printDateTime(Calendar val)

Converts a Calendar value into a string.

Parameters
val:Calendar

A Calendar value

Returns:String

A string containing a lexical representation of xsd:dateTime

Exceptions
IllegalArgumentException:
if val is null.
printDecimalback to summary
public String printDecimal(BigDecimal val)

Converts a BigDecimal value into a string.

Parameters
val:BigDecimal

A BigDecimal value

Returns:String

A string containing a lexical representation of xsd:decimal

Exceptions
IllegalArgumentException:
val is null.
printDoubleback to summary
public String printDouble(double val)

Converts a double value into a string.

Parameters
val:double

A double value

Returns:String

A string containing a lexical representation of xsd:double

printFloatback to summary
public String printFloat(float val)

Converts a float value into a string.

Parameters
val:float

A float value

Returns:String

A string containing a lexical representation of xsd:float

printHexBinaryback to summary
public String printHexBinary(byte[] val)

Converts an array of bytes into a string.

Parameters
val:byte[]

an array of bytes

Returns:String

A string containing a lexical representation of xsd:hexBinary

Exceptions
IllegalArgumentException:
if val is null.
printIntback to summary
public String printInt(int val)

Converts an int value into a string.

Parameters
val:int

An int value

Returns:String

A string containing a lexical representation of xsd:int

printIntegerback to summary
public String printInteger(BigInteger val)

Converts a BigInteger value into a string.

Parameters
val:BigInteger

A BigInteger value

Returns:String

A string containing a lexical representation of xsd:integer

Exceptions
IllegalArgumentException:
val is null.
printLongback to summary
public String printLong(long val)

Converts a long value into a string.

Parameters
val:long

A long value

Returns:String

A string containing a lexical representation of xsd:long

printQNameback to summary
public String printQName(QName val, NamespaceContext nsc)

Converts a QName instance into a string.

Parameters
val:QName

A QName value

nsc:NamespaceContext

A namespace context for interpreting a prefix within a QName.

Returns:String

A string containing a lexical representation of QName

Exceptions
IllegalArgumentException:
if val is null or if nsc is non-null or nsc.getPrefix(nsprefixFromVal) is null.
printShortback to summary
public String printShort(short val)

Converts a short value into a string.

Parameters
val:short

A short value

Returns:String

A string containing a lexical representation of xsd:short

printStringback to summary
public String printString(String val)

Converts the string argument into a string.

Parameters
val:String

A string value.

Returns:String

A string containing a lexical representation of xsd:string

printTimeback to summary
public String printTime(Calendar val)

Converts a Calendar value into a string.

Parameters
val:Calendar

A Calendar value

Returns:String

A string containing a lexical representation of xsd:time

Exceptions
IllegalArgumentException:
if val is null.
printUnsignedIntback to summary
public String printUnsignedInt(long val)

Converts a long value into a string.

Parameters
val:long

A long value

Returns:String

A string containing a lexical representation of xsd:unsignedInt

printUnsignedShortback to summary
public String printUnsignedShort(int val)

Converts an int value into a string.

Parameters
val:int

An int value

Returns:String

A string containing a lexical representation of xsd:unsignedShort