Interface DatatypeConverterInterface
-
public interface DatatypeConverterInterfaceThe 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.setDatatypeConverterapi 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
DatatypeConverterclass.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.
- See Also:
DatatypeConverter,ParseConversionEvent,PrintConversionEvent- Author:
- Sekhar Vajjhala, Sun Microsystems, Inc.
- Joe Fialli, Sun Microsystems Inc.
- Kohsuke Kawaguchi, Sun Microsystems, Inc.
- Ryan Shoemaker,Sun Microsystems Inc.
- Since:
- 1.6, JAXB 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringparseAnySimpleType(java.lang.String lexicalXSDAnySimpleType)Return a string containing the lexical representation of the simple type.byte[]parseBase64Binary(java.lang.String lexicalXSDBase64Binary)Converts the string argument into an array of bytes.booleanparseBoolean(java.lang.String lexicalXSDBoolean)Converts the string argument into a boolean value.byteparseByte(java.lang.String lexicalXSDByte)Converts the string argument into a byte value.java.util.CalendarparseDate(java.lang.String lexicalXSDDate)Converts the string argument into a Calendar value.java.util.CalendarparseDateTime(java.lang.String lexicalXSDDateTime)Converts the string argument into a Calendar value.java.math.BigDecimalparseDecimal(java.lang.String lexicalXSDDecimal)Converts the string argument into a BigDecimal value.doubleparseDouble(java.lang.String lexicalXSDDouble)Converts the string argument into a double value.floatparseFloat(java.lang.String lexicalXSDFloat)Converts the string argument into a float value.byte[]parseHexBinary(java.lang.String lexicalXSDHexBinary)Converts the string argument into an array of bytes.intparseInt(java.lang.String lexicalXSDInt)Convert the string argument into an int value.java.math.BigIntegerparseInteger(java.lang.String lexicalXSDInteger)Convert the string argument into a BigInteger value.longparseLong(java.lang.String lexicalXSDLong)Converts the string argument into a long value.javax.xml.namespace.QNameparseQName(java.lang.String lexicalXSDQName, javax.xml.namespace.NamespaceContext nsc)Converts the string argument into a QName value.shortparseShort(java.lang.String lexicalXSDShort)Converts the string argument into a short value.java.lang.StringparseString(java.lang.String lexicalXSDString)Convert the string argument into a string.java.util.CalendarparseTime(java.lang.String lexicalXSDTime)Converts the string argument into a Calendar value.longparseUnsignedInt(java.lang.String lexicalXSDUnsignedInt)Converts the string argument into a long value.intparseUnsignedShort(java.lang.String lexicalXSDUnsignedShort)Converts the string argument into an int value.java.lang.StringprintAnySimpleType(java.lang.String val)Converts a string value into a string.java.lang.StringprintBase64Binary(byte[] val)Converts an array of bytes into a string.java.lang.StringprintBoolean(boolean val)Converts a boolean value into a string.java.lang.StringprintByte(byte val)Converts a byte value into a string.java.lang.StringprintDate(java.util.Calendar val)Converts a Calendar value into a string.java.lang.StringprintDateTime(java.util.Calendar val)Converts a Calendar value into a string.java.lang.StringprintDecimal(java.math.BigDecimal val)Converts a BigDecimal value into a string.java.lang.StringprintDouble(double val)Converts a double value into a string.java.lang.StringprintFloat(float val)Converts a float value into a string.java.lang.StringprintHexBinary(byte[] val)Converts an array of bytes into a string.java.lang.StringprintInt(int val)Converts an int value into a string.java.lang.StringprintInteger(java.math.BigInteger val)Converts a BigInteger value into a string.java.lang.StringprintLong(long val)Converts a long value into a string.java.lang.StringprintQName(javax.xml.namespace.QName val, javax.xml.namespace.NamespaceContext nsc)Converts a QName instance into a string.java.lang.StringprintShort(short val)Converts a short value into a string.java.lang.StringprintString(java.lang.String val)Converts the string argument into a string.java.lang.StringprintTime(java.util.Calendar val)Converts a Calendar value into a string.java.lang.StringprintUnsignedInt(long val)Converts a long value into a string.java.lang.StringprintUnsignedShort(int val)Converts an int value into a string.
-
-
-
Method Detail
-
parseString
java.lang.String parseString(java.lang.String lexicalXSDString)
Convert the string argument into a string.- Parameters:
lexicalXSDString- A lexical representation of the XML Schema datatype xsd:string- Returns:
- A string that is the same as the input string.
-
parseInteger
java.math.BigInteger parseInteger(java.lang.String lexicalXSDInteger)
Convert the string argument into a BigInteger value.- Parameters:
lexicalXSDInteger- A string containing a lexical representation of xsd:integer.- Returns:
- A BigInteger value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDIntegeris not a valid string representation of aBigIntegervalue.
-
parseInt
int parseInt(java.lang.String lexicalXSDInt)
Convert the string argument into an int value.- Parameters:
lexicalXSDInt- A string containing a lexical representation of xsd:int.- Returns:
- An int value represented byte the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDIntis not a valid string representation of anintvalue.
-
parseLong
long parseLong(java.lang.String lexicalXSDLong)
Converts the string argument into a long value.- Parameters:
lexicalXSDLong- A string containing lexical representation of xsd:long.- Returns:
- A long value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDLongis not a valid string representation of alongvalue.
-
parseShort
short parseShort(java.lang.String lexicalXSDShort)
Converts the string argument into a short value.- Parameters:
lexicalXSDShort- A string containing lexical representation of xsd:short.- Returns:
- A short value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDShortis not a valid string representation of ashortvalue.
-
parseDecimal
java.math.BigDecimal parseDecimal(java.lang.String lexicalXSDDecimal)
Converts the string argument into a BigDecimal value.- Parameters:
lexicalXSDDecimal- A string containing lexical representation of xsd:decimal.- Returns:
- A BigDecimal value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDDecimalis not a valid string representation ofBigDecimal.
-
parseFloat
float parseFloat(java.lang.String lexicalXSDFloat)
Converts the string argument into a float value.- Parameters:
lexicalXSDFloat- A string containing lexical representation of xsd:float.- Returns:
- A float value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDFloatis not a valid string representation of afloatvalue.
-
parseDouble
double parseDouble(java.lang.String lexicalXSDDouble)
Converts the string argument into a double value.- Parameters:
lexicalXSDDouble- A string containing lexical representation of xsd:double.- Returns:
- A double value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDDoubleis not a valid string representation of adoublevalue.
-
parseBoolean
boolean parseBoolean(java.lang.String lexicalXSDBoolean)
Converts the string argument into a boolean value.- Parameters:
lexicalXSDBoolean- A string containing lexical representation of xsd:boolean.- Returns:
- A boolean value represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:boolean.
-
parseByte
byte parseByte(java.lang.String lexicalXSDByte)
Converts the string argument into a byte value.- Parameters:
lexicalXSDByte- A string containing lexical representation of xsd:byte.- Returns:
- A byte value represented by the string argument.
- Throws:
java.lang.NumberFormatException-lexicalXSDBytedoes not contain a parseable byte.java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:byte.
-
parseQName
javax.xml.namespace.QName parseQName(java.lang.String lexicalXSDQName, javax.xml.namespace.NamespaceContext nsc)Converts the string argument into a QName value.String parameter
lexicalXSDQnamemust conform to lexical value space specifed at XML Schema Part 2:Datatypes specification:QNames- Parameters:
lexicalXSDQName- A string containing lexical representation of xsd:QName.nsc- A namespace context for interpreting a prefix within a QName.- Returns:
- A QName value represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to XML Schema Part 2 specification or if namespace prefix oflexicalXSDQnameis not bound to a URI in NamespaceContextnsc.
-
parseDateTime
java.util.Calendar parseDateTime(java.lang.String lexicalXSDDateTime)
Converts the string argument into a Calendar value.- Parameters:
lexicalXSDDateTime- A string containing lexical representation of xsd:datetime.- Returns:
- A Calendar object represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:dateTime.
-
parseBase64Binary
byte[] parseBase64Binary(java.lang.String lexicalXSDBase64Binary)
Converts the string argument into an array of bytes.- Parameters:
lexicalXSDBase64Binary- A string containing lexical representation of xsd:base64Binary.- Returns:
- An array of bytes represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:base64Binary
-
parseHexBinary
byte[] parseHexBinary(java.lang.String lexicalXSDHexBinary)
Converts the string argument into an array of bytes.- Parameters:
lexicalXSDHexBinary- A string containing lexical representation of xsd:hexBinary.- Returns:
- An array of bytes represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
-
parseUnsignedInt
long parseUnsignedInt(java.lang.String lexicalXSDUnsignedInt)
Converts the string argument into a long value.- Parameters:
lexicalXSDUnsignedInt- A string containing lexical representation of xsd:unsignedInt.- Returns:
- A long value represented by the string argument.
- Throws:
java.lang.NumberFormatException- if string parameter can not be parsed into alongvalue.
-
parseUnsignedShort
int parseUnsignedShort(java.lang.String lexicalXSDUnsignedShort)
Converts the string argument into an int value.- Parameters:
lexicalXSDUnsignedShort- A string containing lexical representation of xsd:unsignedShort.- Returns:
- An int value represented by the string argument.
- Throws:
java.lang.NumberFormatException- if string parameter can not be parsed into anintvalue.
-
parseTime
java.util.Calendar parseTime(java.lang.String lexicalXSDTime)
Converts the string argument into a Calendar value.- Parameters:
lexicalXSDTime- A string containing lexical representation of xsd:Time.- Returns:
- A Calendar value represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Time.
-
parseDate
java.util.Calendar parseDate(java.lang.String lexicalXSDDate)
Converts the string argument into a Calendar value.- Parameters:
lexicalXSDDate- A string containing lexical representation of xsd:Date.- Returns:
- A Calendar value represented by the string argument.
- Throws:
java.lang.IllegalArgumentException- if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:Date.
-
parseAnySimpleType
java.lang.String parseAnySimpleType(java.lang.String lexicalXSDAnySimpleType)
Return a string containing the lexical representation of the simple type.- Parameters:
lexicalXSDAnySimpleType- A string containing lexical representation of the simple type.- Returns:
- A string containing the lexical representation of the simple type.
-
printString
java.lang.String printString(java.lang.String val)
Converts the string argument into a string.- Parameters:
val- A string value.- Returns:
- A string containing a lexical representation of xsd:string
-
printInteger
java.lang.String printInteger(java.math.BigInteger val)
Converts a BigInteger value into a string.- Parameters:
val- A BigInteger value- Returns:
- A string containing a lexical representation of xsd:integer
- Throws:
java.lang.IllegalArgumentException-valis null.
-
printInt
java.lang.String printInt(int val)
Converts an int value into a string.- Parameters:
val- An int value- Returns:
- A string containing a lexical representation of xsd:int
-
printLong
java.lang.String printLong(long val)
Converts a long value into a string.- Parameters:
val- A long value- Returns:
- A string containing a lexical representation of xsd:long
-
printShort
java.lang.String printShort(short val)
Converts a short value into a string.- Parameters:
val- A short value- Returns:
- A string containing a lexical representation of xsd:short
-
printDecimal
java.lang.String printDecimal(java.math.BigDecimal val)
Converts a BigDecimal value into a string.- Parameters:
val- A BigDecimal value- Returns:
- A string containing a lexical representation of xsd:decimal
- Throws:
java.lang.IllegalArgumentException-valis null.
-
printFloat
java.lang.String printFloat(float val)
Converts a float value into a string.- Parameters:
val- A float value- Returns:
- A string containing a lexical representation of xsd:float
-
printDouble
java.lang.String printDouble(double val)
Converts a double value into a string.- Parameters:
val- A double value- Returns:
- A string containing a lexical representation of xsd:double
-
printBoolean
java.lang.String printBoolean(boolean val)
Converts a boolean value into a string.- Parameters:
val- A boolean value- Returns:
- A string containing a lexical representation of xsd:boolean
-
printByte
java.lang.String printByte(byte val)
Converts a byte value into a string.- Parameters:
val- A byte value- Returns:
- A string containing a lexical representation of xsd:byte
-
printQName
java.lang.String printQName(javax.xml.namespace.QName val, javax.xml.namespace.NamespaceContext nsc)Converts a QName instance into a string.- Parameters:
val- A QName valuensc- A namespace context for interpreting a prefix within a QName.- Returns:
- A string containing a lexical representation of QName
- Throws:
java.lang.IllegalArgumentException- ifvalis null or ifnscis non-null ornsc.getPrefix(nsprefixFromVal)is null.
-
printDateTime
java.lang.String printDateTime(java.util.Calendar val)
Converts a Calendar value into a string.- Parameters:
val- A Calendar value- Returns:
- A string containing a lexical representation of xsd:dateTime
- Throws:
java.lang.IllegalArgumentException- ifvalis null.
-
printBase64Binary
java.lang.String printBase64Binary(byte[] val)
Converts an array of bytes into a string.- Parameters:
val- an array of bytes- Returns:
- A string containing a lexical representation of xsd:base64Binary
- Throws:
java.lang.IllegalArgumentException- ifvalis null.
-
printHexBinary
java.lang.String printHexBinary(byte[] val)
Converts an array of bytes into a string.- Parameters:
val- an array of bytes- Returns:
- A string containing a lexical representation of xsd:hexBinary
- Throws:
java.lang.IllegalArgumentException- ifvalis null.
-
printUnsignedInt
java.lang.String printUnsignedInt(long val)
Converts a long value into a string.- Parameters:
val- A long value- Returns:
- A string containing a lexical representation of xsd:unsignedInt
-
printUnsignedShort
java.lang.String printUnsignedShort(int val)
Converts an int value into a string.- Parameters:
val- An int value- Returns:
- A string containing a lexical representation of xsd:unsignedShort
-
printTime
java.lang.String printTime(java.util.Calendar val)
Converts a Calendar value into a string.- Parameters:
val- A Calendar value- Returns:
- A string containing a lexical representation of xsd:time
- Throws:
java.lang.IllegalArgumentException- ifvalis null.
-
printDate
java.lang.String printDate(java.util.Calendar val)
Converts a Calendar value into a string.- Parameters:
val- A Calendar value- Returns:
- A string containing a lexical representation of xsd:date
- Throws:
java.lang.IllegalArgumentException- ifvalis null.
-
printAnySimpleType
java.lang.String printAnySimpleType(java.lang.String val)
Converts a string value into a string.- Parameters:
val- A string value- Returns:
- A string containing a lexical representation of xsd:AnySimpleType
-
-