Top Description Inners Fields Constructors Methods
jakarta.xml.bind

pack-priv final Class DatatypeConverterImpl

extends Object
implements DatatypeConverterInterface
Class Inheritance
All Implemented Interfaces
jakarta.xml.bind.DatatypeConverterInterface
Imports
java.math.BigDecimal, .BigInteger, java.util.Calendar, .GregorianCalendar, .TimeZone, javax.xml.namespace.QName, .NamespaceContext, javax.xml.datatype.DatatypeFactory, .DatatypeConfigurationException

This class is the Jakarta XML Binding CI's default implementation of the DatatypeConverterInterface.

When client applications specify the use of the static print/parse methods in DatatypeConverter, it will delegate to this class.

This class is responsible for whitespace normalization.

Author
Since
JAXB 2.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final DatatypeFactory
private static final byte[]
private static final char[]
private static final char[]
private static final byte
public static final DatatypeConverterInterface
theInstance

To avoid re-creating instances, we cache one instance.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static byte[]
_parseBase64Binary(String
base64Binary data is likely to be long, and decoding requires each character to be accessed twice (once for counting length, another for decoding.) A benchmark showed that taking String is faster, presumably because JIT can inline a lot of string access (with data of 1K chars, it was twice as fast)
text
)

public static Boolean
public static byte
public static GregorianCalendar
public static BigDecimal
public static double
public static float
public static int
_parseInt(CharSequence s)

Faster but less robust String->int conversion.

public static BigInteger
public static long
public static QName

Returns:

null if fails to convert.
_parseQName
(CharSequence text, NamespaceContext nsc)

public static short
public static String
_printBase64Binary(byte[] input)

public static String
_printBase64Binary(byte[] input, int offset, int len)

public static int

Returns:

the value of ptr+((len+2)/3)*4, which is the new offset in the output buffer where the further bytes should be placed.
_printBase64Binary
(byte[] input, int offset, int len, char[] buf, int ptr)

Encodes a byte array into a char array by doing base64 encoding.

public static int

Returns:

the value of ptr+((len+2)/3)*4, which is the new offset in the output buffer where the further bytes should be placed.
_printBase64Binary
(byte[] input, int offset, int len, byte[] out, int ptr)

Encodes a byte array into another byte array by first doing base64 encoding then encoding the result in ASCII.

public static String
_printBoolean(boolean val)

public static String
_printByte(byte val)

public static String
public static String
public static String
public static String
_printDouble(double v)

public static String
_printFloat(float v)

public static String
_printInt(int val)

public static String
public static String
_printLong(long val)

public static String
public static String
_printShort(short val)

public static char
encode(int i)

public static byte
encodeByte(int i)

private static int
guessLength(String text)

computes the length of binary data speculatively.

private static int
hexToBin(char ch)

private static byte[]
private static char[]
public static String
installHook(String s)

Just return the string passed as a parameter but installs an instance of this class as the DatatypeConverter implementation.

private static boolean
public String
parseAnySimpleType(String
A string containing lexical representation of the simple type.
lexicalXSDAnySimpleType
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseAnySimpleType.

Return a string containing the lexical representation of the simple type.
public byte[]
parseBase64Binary(String
A string containing lexical representation of xsd:base64Binary.
lexicalXSDBase64Binary
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseBase64Binary.

Converts the string argument into an array of bytes.
public boolean
parseBoolean(String
A string containing lexical representation of xsd:boolean.
lexicalXSDBoolean
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseBoolean.

Converts the string argument into a boolean value.
public byte
parseByte(String
A string containing lexical representation of xsd:byte.
lexicalXSDByte
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseByte.

Converts the string argument into a byte value.
public Calendar
parseDate(String
A string containing lexical representation of xsd:Date.
lexicalXSDDate
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseDate.

Converts the string argument into a Calendar value.
public Calendar
parseDateTime(String
A string containing lexical representation of xsd:datetime.
lexicalXSDDateTime
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseDateTime.

Converts the string argument into a Calendar value.
public BigDecimal
parseDecimal(String
A string containing lexical representation of xsd:decimal.
content
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseDecimal.

Converts the string argument into a BigDecimal value.
public double
parseDouble(String
A string containing lexical representation of xsd:double.
lexicalXSDDouble
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseDouble.

Converts the string argument into a double value.
public float
parseFloat(String
A string containing lexical representation of xsd:float.
lexicalXSDFloat
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseFloat.

Converts the string argument into a float value.
public byte[]
parseHexBinary(String
A string containing lexical representation of xsd:hexBinary.
s
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseHexBinary.

Converts the string argument into an array of bytes.
public int
parseInt(String
A string containing a lexical representation of xsd:int.
s
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseInt.

Convert the string argument into an int value.
public BigInteger
parseInteger(String
A string containing a lexical representation of xsd:integer.
lexicalXSDInteger
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseInteger.

Convert the string argument into a BigInteger value.
public long
parseLong(String
A string containing lexical representation of xsd:long.
lexicalXSLong
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseLong.

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

Implements jakarta.xml.bind.DatatypeConverterInterface.parseQName.

Converts the string argument into a QName value.
public short
parseShort(String
A string containing lexical representation of xsd:short.
lexicalXSDShort
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseShort.

Converts the string argument into a short value.
public String
parseString(String
A lexical representation of the XML Schema datatype xsd:string
lexicalXSDString
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseString.

Convert the string argument into a string.
public Calendar
parseTime(String
A string containing lexical representation of xsd:Time.
lexicalXSDTime
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseTime.

Converts the string argument into a Calendar value.
public long
parseUnsignedInt(String
A string containing lexical representation of xsd:unsignedInt.
lexicalXSDUnsignedInt
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseUnsignedInt.

Converts the string argument into a long value.
public int
parseUnsignedShort(String
A string containing lexical representation of xsd:unsignedShort.
lexicalXSDUnsignedShort
)

Implements jakarta.xml.bind.DatatypeConverterInterface.parseUnsignedShort.

Converts the string argument into an int value.
public String
printAnySimpleType(String
A string value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printAnySimpleType.

Converts a string value into a string.
public String
printBase64Binary(byte[]
an array of bytes
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printBase64Binary.

Converts an array of bytes into a string.
public String
printBoolean(boolean
A boolean value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printBoolean.

Converts a boolean value into a string.
public String
printByte(byte
A byte value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printByte.

Converts a byte value into a string.
public String
printDate(Calendar
A Calendar value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printDate.

Converts a Calendar value into a string.
public String
printDateTime(Calendar
A Calendar value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printDateTime.

Converts a Calendar value into a string.
public String
printDecimal(BigDecimal
A BigDecimal value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printDecimal.

Converts a BigDecimal value into a string.
public String
printDouble(double
A double value
v
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printDouble.

Converts a double value into a string.
public String
printFloat(float
A float value
v
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printFloat.

Converts a float value into a string.
public String
printHexBinary(byte[]
an array of bytes
data
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printHexBinary.

Converts an array of bytes into a string.
public String
printInt(int
An int value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printInt.

Converts an int value into a string.
public String
printInteger(BigInteger
A BigInteger value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printInteger.

Converts a BigInteger value into a string.
public String
printLong(long
A long value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printLong.

Converts a long value into a string.
public String
printQName(QName
A QName value
val
,
NamespaceContext
A namespace context for interpreting a prefix within a QName.
nsc
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printQName.

Converts a QName instance into a string.
public String
printShort(short
A short value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printShort.

Converts a short value into a string.
public String
printString(String
A string value.
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printString.

Converts the string argument into a string.
public String
printTime(Calendar
A Calendar value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printTime.

Converts a Calendar value into a string.
public String
printUnsignedInt(long
A long value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printUnsignedInt.

Converts a long value into a string.
public String
printUnsignedShort(int
An int value
val
)

Implements jakarta.xml.bind.DatatypeConverterInterface.printUnsignedShort.

Converts an int value into a string.
private static CharSequence
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait