Class TLcdXMLBuiltInDatatypeConverter

java.lang.Object
com.luciad.format.xml.bind.schema.TLcdXMLBuiltInDatatypeConverter

public final class TLcdXMLBuiltInDatatypeConverter extends Object
Utility class providing static methods for converting XML lexical values to Java representations and vice versa.

This functionality in this class is similar to the one provided by javax.xml.bind.DatatypeConverter in JDK 1.6.

The mapping performed by both classes is slightly different however:

  • All XML types which are mapped on Calendar by DatatypeConverter are mapped on XMLGregorianCalendar by this class.
  • For some types, the parse methods in this class are less strict than the XML Schema specification requires.
  • This class provides extra methods for mapping some XML list types to dedicated Java classes (such as ILcdBooleanList, ILcdDoubleList, ....
Since:
9.0
  • Method Details

    • parseAnySimpleType

      public static String parseAnySimpleType(String aLexicalString)
      Converts the specified lexical value to a String value.
      Parameters:
      aLexicalString - A lexical value.
      Returns:
      A String value representing the specified lexical value.
    • printAnySimpleType

      public static String printAnySimpleType(String aString)
      Converts the specified String into an XSD lexical value.
      Parameters:
      aString - A String.
      Returns:
      An XSD lexical value representing the specified String.
    • parseString

      public static String parseString(String aLexicalString)
      Converts the specified lexical XSD string to a String value.
      Parameters:
      aLexicalString - A lexical representation of xsd:string.
      Returns:
      A String value representing the specified XSD string.
    • printString

      public static String printString(String aString)
      Converts the specified String into an XSD lexical string.
      Parameters:
      aString - A String.
      Returns:
      An XSD lexical string representing the specified String.
    • parseBoolean

      public static boolean parseBoolean(String aLexicalBoolean)
      Converts the specified lexical XSD boolean to a boolean value.
      Parameters:
      aLexicalBoolean - A lexical representation of xsd:boolean.
      Returns:
      A boolean value representing the specified XSD boolean.
    • printBoolean

      public static String printBoolean(boolean aBoolean)
      Converts the specified boolean into an XSD lexical boolean.
      Parameters:
      aBoolean - A boolean.
      Returns:
      An XSD lexical boolean representing the specified boolean.
    • parseByte

      public static byte parseByte(String aLexicalByte)
      Converts the specified lexical XSD byte to a byte value.
      Parameters:
      aLexicalByte - A lexical representation of xsd:byte.
      Returns:
      A byte value representing the specified XSD byte.
    • printByte

      public static String printByte(byte aByte)
      Converts the specified byte into an XSD lexical byte.
      Parameters:
      aByte - A byte.
      Returns:
      An XSD lexical byte representing the specified byte.
    • parseShort

      public static short parseShort(String aLexicalShort)
      Converts the specified lexical XSD short to a short value.
      Parameters:
      aLexicalShort - A lexical representation of xsd:short.
      Returns:
      A short value representing the specified XSD short.
    • printShort

      public static String printShort(short aShort)
      Converts the specified short into an XSD lexical short.
      Parameters:
      aShort - A short.
      Returns:
      An XSD lexical short representing the specified short.
    • parseInt

      public static int parseInt(String aLexicalInt)
      Converts the specified lexical XSD int to a int value.
      Parameters:
      aLexicalInt - A lexical representation of xsd:int.
      Returns:
      A int value representing the specified XSD int.
    • printInt

      public static String printInt(int aInt)
      Converts the specified int into an XSD lexical int.
      Parameters:
      aInt - A int.
      Returns:
      An XSD lexical int representing the specified int.
    • parseLong

      public static long parseLong(String aLexicalLong)
      Converts the specified lexical XSD long to a long value.
      Parameters:
      aLexicalLong - A lexical representation of xsd:long.
      Returns:
      A long value representing the specified XSD long.
    • printLong

      public static String printLong(long aLong)
      Converts the specified long into an XSD lexical long.
      Parameters:
      aLong - A long.
      Returns:
      An XSD lexical long representing the specified long.
    • parseUnsignedByte

      public static short parseUnsignedByte(String aLexicalUnsignedByte)
      Converts the specified lexical XSD unsigned byte to a short value.
      Parameters:
      aLexicalUnsignedByte - A lexical representation of xsd:unsignedByte.
      Returns:
      A short value representing the specified XSD unsigned byte.
    • printUnsignedByte

      public static String printUnsignedByte(short aShort)
      Converts the specified short into an XSD lexical unsigned byte.
      Parameters:
      aShort - A short.
      Returns:
      An XSD lexical unsigned byte representing the specified short.
    • parseUnsignedShort

      public static int parseUnsignedShort(String aLexicalUnsignedShort)
      Converts the specified lexical XSD unsigned short to an int value.
      Parameters:
      aLexicalUnsignedShort - A lexical representation of xsd:unsignedShort.
      Returns:
      An int value representing the specified XSD unsigned short.
    • printUnsignedShort

      public static String printUnsignedShort(int aInt)
      Converts the specified int into an XSD lexical unsigned short.
      Parameters:
      aInt - An int.
      Returns:
      An XSD lexical unsigned short representing the specified int.
    • parseUnsignedInt

      public static long parseUnsignedInt(String aLexicalUnsignedInt)
      Converts the specified lexical XSD unsigned int to an long value.
      Parameters:
      aLexicalUnsignedInt - A lexical representation of xsd:unsignedInt.
      Returns:
      An long value representing the specified XSD unsigned int.
    • printUnsignedInt

      public static String printUnsignedInt(long aLong)
      Converts the specified long into an XSD lexical unsigned int.
      Parameters:
      aLong - A long.
      Returns:
      An XSD lexical unsigned int representing the specified long.
    • parseInteger

      public static BigInteger parseInteger(String aLexicalInteger)
      Converts the specified lexical XSD integer to an BigInteger value.
      Parameters:
      aLexicalInteger - A lexical representation of xsd:integer.
      Returns:
      An BigInteger value representing the specified XSD integer.
    • printInteger

      public static String printInteger(BigInteger aBigInteger)
      Converts the specified BigInteger into an XSD lexical integer.
      Parameters:
      aBigInteger - A BigInteger.
      Returns:
      An XSD lexical integer representing the specified BigInteger.
    • parseDecimal

      public static BigDecimal parseDecimal(String aLexicalDecimal)
      Converts the specified lexical XSD decimal to an BigDecimal value.
      Parameters:
      aLexicalDecimal - A lexical representation of xsd:decimal.
      Returns:
      An BigDecimal value representing the specified XSD decimal.
    • printDecimal

      public static String printDecimal(BigDecimal aBigDecimal)
      Converts the specified BigDecimal into an XSD lexical decimal.
      Parameters:
      aBigDecimal - A BigDecimal.
      Returns:
      An XSD lexical decimal representing the specified BigDecimal.
    • parseFloat

      public static float parseFloat(String aLexicalFloat)
      Converts the specified lexical XSD float to an float value.
      Parameters:
      aLexicalFloat - A lexical representation of xsd:float.
      Returns:
      An float value representing the specified XSD float.
    • printFloat

      public static String printFloat(float aFloat)
      Converts the specified float into an XSD lexical float.
      Parameters:
      aFloat - A float.
      Returns:
      An XSD lexical float representing the specified float.
    • parseDouble

      public static double parseDouble(String aLexicalDouble)
      Converts the specified lexical XSD double to an double value.
      Parameters:
      aLexicalDouble - A lexical representation of xsd:double.
      Returns:
      An double value representing the specified XSD double.
    • printDouble

      public static String printDouble(double aDouble)
      Converts the specified double into an XSD lexical double.
      Parameters:
      aDouble - A double.
      Returns:
      An XSD lexical double representing the specified double.
    • parseQName

      public static QName parseQName(String aLexicalQName, XMLStreamReader aReader)
      Converts the specified lexical XSD QName to a QName value.
      Parameters:
      aLexicalQName - A lexical representation of xsd:QName.
      aReader - the XMLStreamReader containing contextual information on how to interpret the lexical value.
      Returns:
      a QName value representing the specified XSD QName
    • parseQName

      public static QName parseQName(String aLexicalQName, NamespaceContext aNamespaceContext)
      Converts the specified lexical XSD QName to a QName value.
      Parameters:
      aLexicalQName - A lexical representation of xsd:QName.
      aNamespaceContext - the NamespaceContext containing contextual information on how to interpret the lexical value.
      Returns:
      a QName value representing the specified XSD QName
      Since:
      2017.0
    • printQName

      public static String printQName(QName aQName, XMLStreamWriter aStreamWriter) throws XMLStreamException
      Converts the specified QName into an XSD lexical QName.
      Parameters:
      aQName - A QName.
      aStreamWriter - the XMLStreamWriter to which contextual information (prefix definitions) may be written.
      Returns:
      An XSD lexical QName representing the specified QName.
      Throws:
      XMLStreamException - if a required prefix definition could not be written on the specified XMLStreamWriter.
    • parseHexBinary

      public static byte[] parseHexBinary(String aLexicalHexBinary)
      Converts the specified lexical XSD hexBinary to an byte array value.
      Parameters:
      aLexicalHexBinary - A lexical representation of xsd:hexBinary.
      Returns:
      An double value representing the specified XSD hexBinary.
    • parseBase64Binary

      public static byte[] parseBase64Binary(String aBase64Binary)
      Converts the specified lexical XSD base64Binary to a byte array value.
      Parameters:
      aBase64Binary - A lexical representation of xsd:base64Binary.
      Returns:
      A byte array value representing the specified XSD base64Binary.
      See Also:
    • printBase64Binary

      public static String printBase64Binary(byte[] aByteArray)
      Converts the specified byte array into an XSD lexical base64Binary.
      Parameters:
      aByteArray - A byte array.
      Returns:
      An XSD lexical base64Binary representing the specified byte array.
      See Also:
    • printHexBinary

      public static String printHexBinary(byte[] aByteArray)
      Converts the specified byte array into an XSD lexical hexBinary.
      Parameters:
      aByteArray - A byte array.
      Returns:
      An XSD lexical hexBinary representing the specified byte array.
    • parseDuration

      public static Duration parseDuration(String aLexicalDuration)
      Converts the specified lexical XSD duration to an Duration value.
      Parameters:
      aLexicalDuration - A lexical representation of xsd:duration.
      Returns:
      An Duration value representing the specified XSD duration.
    • printDuration

      public static String printDuration(Duration aDuration)
      Converts the specified Duration into an XSD lexical duration.
      Parameters:
      aDuration - A Duration.
      Returns:
      An XSD lexical duration representing the specified Duration.
    • parseDateTime

      public static XMLGregorianCalendar parseDateTime(String aLexicalDateTime)
      Converts the specified lexical XSD dateTime to an XMLGregorianCalendar value.
      Parameters:
      aLexicalDateTime - A lexical representation of xsd:dateTime.
      Returns:
      An XMLGregorianCalendar value representing the specified XSD dateTime.
    • printDateTime

      public static String printDateTime(XMLGregorianCalendar aXMLGregorianCalendar)
      Converts the specified XMLGregorianCalendar into an XSD lexical dateTime.
      Parameters:
      aXMLGregorianCalendar - An XMLGregorianCalendar.
      Returns:
      An XSD lexical dateTime representing the specified XMLGregorianCalendar.
    • parseDate

      public static XMLGregorianCalendar parseDate(String aLexicalDate)
      Converts the specified lexical XSD date to an XMLGregorianCalendar value.
      Parameters:
      aLexicalDate - A lexical representation of xsd:date.
      Returns:
      An XMLGregorianCalendar value representing the specified XSD date.
    • printDate

      public static String printDate(XMLGregorianCalendar aXMLGregorianCalendar)
      Converts the specified XMLGregorianCalendar into an XSD lexical date.
      Parameters:
      aXMLGregorianCalendar - An XMLGregorianCalendar.
      Returns:
      An XSD lexical date representing the specified XMLGregorianCalendar.
    • toXMLGregorianCalendar

      public static XMLGregorianCalendar toXMLGregorianCalendar(Date aDate)
      Converts a Date into an XMLGregorianCalendar. This method can be used in combination with for example printDate(XMLGregorianCalendar) to write Dates to XML.
      Parameters:
      aDate - A Date
      Returns:
      An XMLGregorianCalendar
      Since:
      2017.0
    • toXMLGregorianCalendar

      public static XMLGregorianCalendar toXMLGregorianCalendar(Instant aInstant)
      Converts an Instant into an XMLGregorianCalendar.
      Parameters:
      aInstant - An instant
      Returns:
      An XMLGregorianCalendar
      Since:
      2018.0
    • toDate

      public static Date toDate(XMLGregorianCalendar aXMLGregorianCalendar)
      Converts an XMLGregorianCalendar into a Date. This method can be used in combination with for example parseDate(String) to read Dates from XML
      Parameters:
      aXMLGregorianCalendar - An XMLGregorianCalendar
      Returns:
      A Date value
      Since:
      2017.0
    • parseTime

      public static XMLGregorianCalendar parseTime(String aLexicalTime)
      Converts the specified lexical XSD time to an XMLGregorianCalendar value.
      Parameters:
      aLexicalTime - A lexical representation of xsd:time.
      Returns:
      An XMLGregorianCalendar value representing the specified XSD time.
    • printTime

      public static String printTime(XMLGregorianCalendar aXMLGregorianCalendar)
      Converts the specified XMLGregorianCalendar into an XSD lexical time.
      Parameters:
      aXMLGregorianCalendar - An XMLGregorianCalendar.
      Returns:
      An XSD lexical time representing the specified XMLGregorianCalendar.
    • parseStringList

      public static List<String> parseStringList(String aLexicalStringList)
      Converts the specified XSD list of lexical XSD string to a list of String values.
      Parameters:
      aLexicalStringList - A lexical representation of list of xsd:string.
      Returns:
      An List of String values representing the specified XSD list of string.
    • printStringList

      public static String printStringList(List<String> aStringList)
      Converts the specified List of String into an XSD lexical list of string.
      Parameters:
      aStringList - A List of String.
      Returns:
      An XSD lexical list of string representing the specified List of String.
    • parseBooleanList

      public static ILcdBooleanList parseBooleanList(String aLexicalBooleanList)
      Converts the specified XSD list of lexical XSD boolean to an ILcdBooleanList.
      Parameters:
      aLexicalBooleanList - A lexical representation of list of xsd:boolean.
      Returns:
      An ILcdBooleanList representing the specified XSD list of boolean.
    • printBooleanList

      public static String printBooleanList(ILcdBooleanList aBooleanList)
      Converts the specified ILcdBooleanList into an XSD lexical list of boolean.
      Parameters:
      aBooleanList - A ILcdBooleanList.
      Returns:
      An XSD lexical list of boolean representing the specified ILcdBooleanList.
    • parseByteList

      public static ILcdByteList parseByteList(String aLexicalByteList)
      Converts the specified XSD list of lexical XSD byte to an ILcdByteList.
      Parameters:
      aLexicalByteList - A lexical representation of list of xsd:byte.
      Returns:
      An ILcdByteList representing the specified XSD list of byte.
    • printByteList

      public static String printByteList(ILcdByteList aByteList)
      Converts the specified ILcdByteList into an XSD lexical list of byte.
      Parameters:
      aByteList - A ILcdByteList.
      Returns:
      An XSD lexical list of byte representing the specified ILcdByteList.
    • parseShortList

      public static ILcdShortList parseShortList(String aLexicalShortList)
      Converts the specified XSD list of lexical XSD short to an ILcdShortList.
      Parameters:
      aLexicalShortList - A lexical representation of list of xsd:short.
      Returns:
      An ILcdShortList representing the specified XSD list of short.
    • printShortList

      public static String printShortList(ILcdShortList aShortList)
      Converts the specified ILcdShortList into an XSD lexical list of short.
      Parameters:
      aShortList - A ILcdShortList.
      Returns:
      An XSD lexical list of short representing the specified ILcdShortList.
    • parseIntList

      public static ILcdIntList parseIntList(String aLexicalIntList)
      Converts the specified XSD list of lexical XSD int to an ILcdIntList.
      Parameters:
      aLexicalIntList - A lexical representation of list of xsd:int.
      Returns:
      An ILcdIntList representing the specified XSD list of int.
    • printIntList

      public static String printIntList(ILcdIntList aIntList)
      Converts the specified ILcdIntList into an XSD lexical list of int.
      Parameters:
      aIntList - A ILcdIntList.
      Returns:
      An XSD lexical list of int representing the specified ILcdIntList.
    • parseLongList

      public static ILcdLongList parseLongList(String aLexicalLongList)
      Converts the specified XSD list of lexical XSD long to an ILcdLongList.
      Parameters:
      aLexicalLongList - A lexical representation of list of xsd:long.
      Returns:
      An ILcdLongList representing the specified XSD list of long.
    • printLongList

      public static String printLongList(ILcdLongList aLongList)
      Converts the specified ILcdLongList into an XSD lexical list of long.
      Parameters:
      aLongList - A ILcdLongList.
      Returns:
      An XSD lexical list of long representing the specified ILcdLongList.
    • parseIntegerList

      public static List<BigInteger> parseIntegerList(String aLexicalIntegerList)
      Converts the specified XSD list of lexical XSD integer to a List of BigInteger.
      Parameters:
      aLexicalIntegerList - A lexical representation of list of xsd:integer.
      Returns:
      A List of BigInteger representing the specified XSD list of integer.
    • printIntegerList

      public static String printIntegerList(List<BigInteger> aIntegerList)
      Converts the specified List of BigInteger into an XSD lexical list of integer.
      Parameters:
      aIntegerList - A List of BigInteger.
      Returns:
      An XSD lexical list of integer representing the specified List of BigInteger.
    • parseDecimalList

      public static List<BigDecimal> parseDecimalList(String aLexicalDecimalList)
      Converts the specified XSD list of lexical XSD decimal to an List of BigDecimal.
      Parameters:
      aLexicalDecimalList - A lexical representation of list of xsd:decimal.
      Returns:
      An List of BigDecimal representing the specified XSD list of decimal.
    • printDecimalList

      public static String printDecimalList(List<BigDecimal> aBigDecimalList)
      Converts the specified List of BigDecimal into an XSD lexical list of decimal.
      Parameters:
      aBigDecimalList - A List of BigDecimal.
      Returns:
      An XSD lexical list of decimal representing the specified List of BigDecimal.
    • parseFloatList

      public static ILcdFloatList parseFloatList(String aLexicalFloatList)
      Converts the specified XSD list of lexical XSD float to an ILcdFloatList.
      Parameters:
      aLexicalFloatList - A lexical representation of list of xsd:float.
      Returns:
      An ILcdFloatList representing the specified XSD list of float.
    • printFloatList

      public static String printFloatList(ILcdFloatList aFloatList)
      Converts the specified ILcdFloatList into an XSD lexical list of float.
      Parameters:
      aFloatList - A ILcdFloatList.
      Returns:
      An XSD lexical list of float representing the specified ILcdFloatList.
    • parseDoubleList

      public static ILcdDoubleList parseDoubleList(String aLexicalDoubleList)
      Converts the specified XSD list of lexical XSD double to an ILcdDoubleList.
      Parameters:
      aLexicalDoubleList - A lexical representation of list of xsd:double.
      Returns:
      An ILcdDoubleList representing the specified XSD list of double.
    • printDoubleList

      public static String printDoubleList(ILcdDoubleList aDoubleList)
      Converts the specified ILcdDoubleList into an XSD lexical list of double.
      Parameters:
      aDoubleList - A ILcdDoubleList.
      Returns:
      An XSD lexical list of double representing the specified ILcdDoubleList.
    • parseQNameList

      public static List<QName> parseQNameList(String aLexicalQNameList, XMLStreamReader aReader)
      Converts the specified XSD list of lexical XSD QName to an List of QName.
      Parameters:
      aLexicalQNameList - A lexical representation of list of xsd:QName.
      aReader - the XMLStreamReader containing contextual information on how to interpet the lexical value.
      Returns:
      An List of QName representing the specified XSD list of QName.
    • printQNameList

      public static String printQNameList(List<QName> aQNameList, XMLStreamWriter aStreamWriter) throws XMLStreamException
      Converts the specified List of QName into an XSD lexical list of QName.
      Parameters:
      aQNameList - A List of QName.
      aStreamWriter - the XMLStreamWriter to which contextual information (prefix definitions) may be written.
      Returns:
      An XSD lexical list of QName representing the specified List of QName.
      Throws:
      XMLStreamException - if a required prefix definition could not be written on the specified XMLStreamWriter.
    • parseHexBinaryList

      public static List<byte[]> parseHexBinaryList(String aLexicalHexBinaryList)
      Converts the specified XSD list of lexical XSD hexBinary to an List of byte[].
      Parameters:
      aLexicalHexBinaryList - A lexical representation of list of xsd:hexBinary.
      Returns:
      An List of byte[] representing the specified XSD list of hexBinary.
    • printHexBinaryList

      public static String printHexBinaryList(List<?> aByteArrayList)
      Converts the specified List of byte arrays into an XSD lexical list of hexBinary.
      Parameters:
      aByteArrayList - A List of byte arrays.
      Returns:
      An XSD lexical list of hexBinary representing the specified List of byte arrays.
    • parseAnyURI

      public static URI parseAnyURI(String aText)
      Converts the specified lexical anyURI to a URI instance.
      Parameters:
      aText - A lexical representation of xsd:anyURI.
      Returns:
      A URI representing the specified XSD anyURI.
    • printAnyURI

      public static String printAnyURI(URI aURI)
      Converts the specified URI into an XSD anyURI.
      Parameters:
      aURI - a URI
      Returns:
      An XSD lexical string representing the specified URI.