XsTypeConverter (xmlbeans API)

org.apache.xmlbeans.impl.util

## Class XsTypeConverter

- java.lang.Object
- - org.apache.xmlbeans.impl.util.XsTypeConverter

-     public final class XsTypeConverter
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XsTypeConverter()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static GDateSpecification` | `getGDateValue(Calendar c, int builtin_type_code)`
    `static GDateSpecification` | `getGDateValue(CharSequence v, int builtin_type_code)`
    `static GDateSpecification` | `getGDateValue(Date d, int builtin_type_code)`
    `static String` | `getQNameString(String uri, String localpart, String prefix)`
    `static CharSequence` | `lexAnyURI(CharSequence lexical_value)` Checks the regular expression of URI, defined by RFC2369 http://www.ietf.org/rfc/rfc2396.txt Appendix B.
    `static boolean` | `lexBoolean(CharSequence v)`
    `static boolean` | `lexBoolean(CharSequence value, Collection<XmlError> errors)`
    `static byte` | `lexByte(CharSequence cs)`
    `static byte` | `lexByte(CharSequence cs, Collection<XmlError> errors)`
    `static XmlCalendar` | `lexDateTime(CharSequence v)`
    `static BigDecimal` | `lexDecimal(CharSequence cs)`
    `static BigDecimal` | `lexDecimal(CharSequence cs, boolean allowExponent)` Parses an xsd:decimal lexical value.
    `static double` | `lexDouble(CharSequence cs)`
    `static double` | `lexDouble(CharSequence cs, boolean strict, int maxNumberOfChars)` Parses an xsd:double lexical value.
    `static double` | `lexDouble(CharSequence cs, Collection<XmlError> errors)`
    `static float` | `lexFloat(CharSequence cs)`
    `static float` | `lexFloat(CharSequence cs, boolean strict, int maxNumberOfChars)` Parses an xsd:float lexical value.
    `static float` | `lexFloat(CharSequence cs, Collection<XmlError> errors)`
    `static GDate` | `lexGDate(CharSequence charSeq)`
    `static GDate` | `lexGDate(String xsd_gdate, Collection<XmlError> errors)`
    `static int` | `lexInt(CharSequence cs)`
    `static int` | `lexInt(CharSequence cs, Collection<XmlError> errors)`
    `static BigInteger` | `lexInteger(CharSequence cs)`
    `static BigInteger` | `lexInteger(CharSequence cs, Collection<XmlError> errors)`
    `static long` | `lexLong(CharSequence cs)`
    `static long` | `lexLong(CharSequence cs, Collection<XmlError> errors)`
    `static QName` | `lexQName(CharSequence charSeq, NamespaceContext nscontext)`
    `static QName` | `lexQName(String xsd_qname, Collection<XmlError> errors, NamespaceContext nscontext)`
    `static short` | `lexShort(CharSequence cs)`
    `static short` | `lexShort(CharSequence cs, Collection<XmlError> errors)`
    `static String` | `printBoolean(boolean value)`
    `static String` | `printByte(byte value)`
    `static String` | `printDate(Calendar c)`
    `static String` | `printDate(Date d)`
    `static String` | `printDateTime(Calendar c)`
    `static String` | `printDateTime(Calendar c, int type_code)`
    `static String` | `printDateTime(Date c)`
    `static String` | `printDecimal(BigDecimal value)`
    `static String` | `printDouble(double value)`
    `static String` | `printFloat(float value)`
    `static String` | `printGDate(GDate gdate, Collection<XmlError> errors)`
    `static CharSequence` | `printHexBinary(byte[] val)`
    `static String` | `printInt(int value)`
    `static String` | `printInteger(BigInteger value)`
    `static String` | `printLong(long value)`
    `static String` | `printQName(QName qname, NamespaceContext nsContext, Collection<XmlError> errors)`
    `static String` | `printShort(short value)`
    `static String` | `printString(String value)`
    `static String` | `printTime(Calendar c)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### XsTypeConverter

          public XsTypeConverter()

  - ### Method Detail

    - #### lexFloat

          public static float lexFloat(CharSequence cs)
                                throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexFloat

          public static float lexFloat(CharSequence cs,
                                       boolean strict,
                                       int maxNumberOfChars)
                                throws NumberFormatException

      Parses an xsd:float lexical value.
      Parameters:
        `cs` - the lexical value
        `strict` - when `true`, lexical forms that `Float.parseFloat(java.lang.String)` accepts but XSD does not are rejected: hexadecimal floats (`0x1p4`), the Java `Infinity` token, and a trailing type suffix (`f`/`F`/`d`/`D`). When `false` the long-standing lenient behaviour applies. Driven by `XmlOptions.setLoadStrictFloatingPoint()`.
        `maxNumberOfChars` - the maximum number of characters allowed in the string
      Returns:
        the parsed float
      Throws:
        `NumberFormatException` - if the value is not a valid xsd:float
      Since:
        5.4.0

    - #### lexFloat

          public static float lexFloat(CharSequence cs,
                                       Collection<XmlError> errors)

    - #### printFloat

          public static String printFloat(float value)

    - #### lexDouble

          public static double lexDouble(CharSequence cs)
                                  throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexDouble

          public static double lexDouble(CharSequence cs,
                                         boolean strict,
                                         int maxNumberOfChars)
                                  throws NumberFormatException

      Parses an xsd:double lexical value.
      Parameters:
        `cs` - the lexical value
        `strict` - when `true`, lexical forms that `Double.parseDouble(java.lang.String)` accepts but XSD does not are rejected: hexadecimal floats (`0x1p4`), the Java `Infinity` token, and a trailing type suffix (`f`/`F`/`d`/`D`). When `false` the long-standing lenient behaviour applies. Driven by `XmlOptions.setLoadStrictFloatingPoint()`.
        `maxNumberOfChars` - the maximum number of characters allowed in the string
      Returns:
        the parsed double
      Throws:
        `NumberFormatException` - if the value is not a valid xsd:double
      Since:
        5.4.0

    - #### lexDouble

          public static double lexDouble(CharSequence cs,
                                         Collection<XmlError> errors)

    - #### printDouble

          public static String printDouble(double value)

    - #### lexDecimal

          public static BigDecimal lexDecimal(CharSequence cs)
                                       throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexDecimal

          public static BigDecimal lexDecimal(CharSequence cs,
                                              boolean allowExponent)
                                       throws NumberFormatException

      Parses an xsd:decimal lexical value.
      Parameters:
        `cs` - the lexical value
        `allowExponent` - when `false` (the default) scientific/exponent notation such as `1E5` is rejected: it is outside the xsd:decimal lexical space (that form belongs to xsd:double/xsd:float) and `BigDecimal` would otherwise parse it to a wrong value (`1E5 -> 100000`). When `true` the long-standing lenient behaviour applies and an exponent is accepted. Driven by `XmlOptions.setLoadAllowDecimalExponent()`.
      Returns:
        the parsed decimal
      Throws:
        `NumberFormatException` - if the value is not a valid xsd:decimal
      Since:
        5.4.0

    - #### printDecimal

          public static String printDecimal(BigDecimal value)

    - #### lexInteger

          public static BigInteger lexInteger(CharSequence cs)
                                       throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexInteger

          public static BigInteger lexInteger(CharSequence cs,
                                              Collection<XmlError> errors)

    - #### printInteger

          public static String printInteger(BigInteger value)

    - #### lexLong

          public static long lexLong(CharSequence cs)
                              throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexLong

          public static long lexLong(CharSequence cs,
                                     Collection<XmlError> errors)

    - #### printLong

          public static String printLong(long value)

    - #### lexShort

          public static short lexShort(CharSequence cs)
                                throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexShort

          public static short lexShort(CharSequence cs,
                                       Collection<XmlError> errors)

    - #### printShort

          public static String printShort(short value)

    - #### lexInt

          public static int lexInt(CharSequence cs)
                            throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexInt

          public static int lexInt(CharSequence cs,
                                   Collection<XmlError> errors)

    - #### printInt

          public static String printInt(int value)

    - #### lexByte

          public static byte lexByte(CharSequence cs)
                              throws NumberFormatException

      Throws:
        `NumberFormatException`

    - #### lexByte

          public static byte lexByte(CharSequence cs,
                                     Collection<XmlError> errors)

    - #### printByte

          public static String printByte(byte value)

    - #### lexBoolean

          public static boolean lexBoolean(CharSequence v)

    - #### lexBoolean

          public static boolean lexBoolean(CharSequence value,
                                           Collection<XmlError> errors)

    - #### printBoolean

          public static String printBoolean(boolean value)

    - #### printString

          public static String printString(String value)

    - #### lexQName

          public static QName lexQName(CharSequence charSeq,
                                       NamespaceContext nscontext)

    - #### lexQName

          public static QName lexQName(String xsd_qname,
                                       Collection<XmlError> errors,
                                       NamespaceContext nscontext)

    - #### printQName

          public static String printQName(QName qname,
                                          NamespaceContext nsContext,
                                          Collection<XmlError> errors)

    - #### getQNameString

          public static String getQNameString(String uri,
                                              String localpart,
                                              String prefix)

    - #### lexGDate

          public static GDate lexGDate(CharSequence charSeq)

    - #### lexGDate

          public static GDate lexGDate(String xsd_gdate,
                                       Collection<XmlError> errors)

    - #### printGDate

          public static String printGDate(GDate gdate,
                                          Collection<XmlError> errors)

    - #### lexDateTime

          public static XmlCalendar lexDateTime(CharSequence v)

    - #### printDateTime

          public static String printDateTime(Calendar c)

    - #### printTime

          public static String printTime(Calendar c)

    - #### printDate

          public static String printDate(Calendar c)

    - #### printDate

          public static String printDate(Date d)

    - #### printDateTime

          public static String printDateTime(Calendar c,
                                             int type_code)

    - #### printDateTime

          public static String printDateTime(Date c)

    - #### printHexBinary

          public static CharSequence printHexBinary(byte[] val)

    - #### getGDateValue

          public static GDateSpecification getGDateValue(Date d,
                                                         int builtin_type_code)

    - #### getGDateValue

          public static GDateSpecification getGDateValue(Calendar c,
                                                         int builtin_type_code)

    - #### getGDateValue

          public static GDateSpecification getGDateValue(CharSequence v,
                                                         int builtin_type_code)

    - #### lexAnyURI

          public static CharSequence lexAnyURI(CharSequence lexical_value)

      Checks the regular expression of URI, defined by RFC2369 http://www.ietf.org/rfc/rfc2396.txt Appendix B. Note: The whitespace normalization rule collapse must be applied prior to calling this method.
      Parameters:
        `lexical_value` - the lexical value
      Returns:
        same input value if input value is in the lexical space