Package com.stardog.stark

# Class XMLDatatypes

java.lang.Object
com.stardog.stark.XMLDatatypes

public final class XMLDatatypes extends Object

Utility for XML schema datatypes

Since:
  1.0
Version:
  1.0
Author:
  Arjohn Kampman, Michael Grove

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final EnumSet<Datatype>`
  `CALENDAR`
  `static final String`
  `DATE`
  `static final String`
  `DAY_TIME_DURATION`
  `static final EnumSet<Datatype>`
  `DERIVED`
  `static final String`
  `DURATION`
  `static final EnumSet<Datatype>`
  `DURATIONS`
  `static final EnumSet<Datatype>`
  `FP`
  `static final String`
  `GDAY`
  `static final String`
  `GMONTH`
  `static final String`
  `GMONTHDAY`
  `static final String`
  `GYEAR`
  `static final String`
  `GYEARMONTH_REGEX`
  `static final EnumSet<Datatype>`
  `INTEGERS`
  `static final EnumSet<Datatype>`
  `PRIMITIVES`
  `static final String`
  `TIME`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `collapseWhiteSpace(String s)`
  Replaces all contiguous sequences of #x9 (tab), #xA (line feed) and #xD (carriage return) with a single #x20 (space) character, and removes any leading and trailing whitespace characters, as specified for whiteSpace facet `collapse`.
  `static int`
  `compareCanonicalDecimals(String dec1, String dec2)`
  Compares two canonical decimals to eachother.
  `static int`
  `compareCanonicalIntegers(String int1, String int2)`
  Compares two canonical integers to eachother.
  `static boolean`
  `isBuiltInDatatype(Datatype theDatatype)`
  Return whether or not the `Datatype` is a built-in XML schema type.
  `static boolean`
  `isBuiltInDatatype(IRI theIRI)`
  Return whether or not the `IRI` is a built-in XML schema type.
  `static boolean`
  `isCalendarDatatype(Datatype theDatatype)`
  Return whether or not the `Datatype` is an XML datatype calendar type
  `static boolean`
  `isDecimalDatatype(Datatype theDatatype)`
  Return whether or not the `Datatype` is `xsd:decimal` or derived from it
  `static boolean`
  `isDurationDatatype(Datatype theDatatype)`
  `static boolean`
  `isFloatingPointDatatype(Datatype theDatatype)`
  `static boolean`
  `isIntegerDatatype(Datatype theDatatype)`
  Return whether or not the `Datatype` is `xsd:integer` or derived from it
  `static boolean`
  `isNumericDatatype(Datatype theDatatype)`
  Return whether or not the `Datatype` is a numeric datatype such as `xsd:long` or `xsd:decimal`.
  `static boolean`
  `isPrimitiveDatatype(Datatype theDatatype)`
  Return whether or not the `Datatype` is a primitive XML schema type.
  `static boolean`
  `isValidBoolean(String value)`
  `static boolean`
  `isValidByte(String value)`
  `static boolean`
  `isValidDate(String value)`
  Determines if the supplied value is a valid xsd:date string.
  `static boolean`
  `isValidDateTime(String value)`
  `static boolean`
  `isValidDayTimeDuration(String value)`
  `static boolean`
  `isValidDecimal(String value)`
  `static boolean`
  `isValidDouble(String value)`
  `static boolean`
  `isValidDuration(String value)`
  `static boolean`
  `isValidFloat(String value)`
  `static boolean`
  `isValidGDay(String value)`
  Determines if the supplied value is a valid xsd:gDay string.
  `static boolean`
  `isValidGMonth(String value)`
  Determines if the supplied value is a valid xsd:gMonth string.
  `static boolean`
  `isValidGMonthDay(String value)`
  Determines if the supplied value is a valid xsd:gMonthDay string.
  `static boolean`
  `isValidGYear(String value)`
  Determines if the supplied value is a valid xsd:gYear string.
  `static boolean`
  `isValidGYearMonth(String value)`
  Determines if the supplied value is a valid xsd:gYearMonth string.
  `static boolean`
  `isValidInt(String value)`
  `static boolean`
  `isValidInteger(String value)`
  `static boolean`
  `isValidLong(String value)`
  `static boolean`
  `isValidNegativeInteger(String value)`
  `static boolean`
  `isValidNonNegativeInteger(String value)`
  `static boolean`
  `isValidNonPositiveInteger(String value)`
  `static boolean`
  `isValidPositiveInteger(String value)`
  `static boolean`
  `isValidQName(String value)`
  Determines if the supplied value is a valid xsd:QName string.
  `static boolean`
  `isValidShort(String value)`
  `static boolean`
  `isValidTime(String value)`
  Determines if the supplied value is a valid xsd:time string.
  `static boolean`
  `isValidUnsignedByte(String value)`
  `static boolean`
  `isValidUnsignedInt(String value)`
  `static boolean`
  `isValidUnsignedLong(String value)`
  `static boolean`
  `isValidUnsignedShort(String value)`
  `static boolean`
  `isValidValue(Literal theLiteral)`
  Verifies if the supplied lexical value is valid for the given literal.
  `static boolean`
  `isValidValue(String theValue, Datatype theDatatype)`
  Verifies if the supplied lexical value is valid for the given datatype.
  `static String`
  `normalize(String value, Datatype datatype)`
  Normalizes the supplied value according to the normalization rules for the supplied datatype.
  `static String`
  `normalizeBoolean(String theValue)`
  Normalizes a boolean value to its canonical representation.
  `static String`
  `normalizeByte(String value)`
  Normalizes an xsd:byte.
  `static String`
  `normalizeDateTime(String value)`
  Normalizes an xsd:dateTime.
  `static String`
  `normalizeDecimal(String decimal)`
  Normalizes a decimal to its canonical representation.
  `static String`
  `normalizeDouble(String value)`
  Normalizes a double to its canonical representation.
  `static String`
  `normalizeFloat(String value)`
  Normalizes a float to its canonical representation.
  `static String`
  `normalizeInt(String value)`
  Normalizes an xsd:int.
  `static String`
  `normalizeInteger(String value)`
  Normalizes an integer to its canonical representation.
  `static String`
  `normalizeLong(String value)`
  Normalizes an xsd:long.
  `static String`
  `normalizeNegativeInteger(String value)`
  Normalizes an xsd:negativeInteger.
  `static String`
  `normalizeNonNegativeInteger(String value)`
  Normalizes an xsd:nonNegativeInteger.
  `static String`
  `normalizeNonPositiveInteger(String value)`
  Normalizes an xsd:nonPositiveInteger.
  `static String`
  `normalizePositiveInteger(String value)`
  Normalizes an xsd:positiveInteger.
  `static String`
  `normalizeShort(String value)`
  Normalizes an xsd:short.
  `static String`
  `normalizeUnsignedByte(String value)`
  Normalizes an xsd:unsignedByte.
  `static String`
  `normalizeUnsignedInt(String value)`
  Normalizes an xsd:unsignedInt.
  `static String`
  `normalizeUnsignedLong(String value)`
  Normalizes an xsd:unsignedLong.
  `static String`
  `normalizeUnsignedShort(String value)`
  Normalizes an xsd:unsignedShort.
  `static XMLGregorianCalendar`
  `parseCalendar(String s)`
  Parses the supplied calendar value string and returns its value.

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

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

- ## Field Details

  - ### PRIMITIVES

    public static final EnumSet<Datatype> PRIMITIVES

  - ### DERIVED

    public static final EnumSet<Datatype> DERIVED

  - ### INTEGERS

    public static final EnumSet<Datatype> INTEGERS

  - ### FP

    public static final EnumSet<Datatype> FP

  - ### CALENDAR

    public static final EnumSet<Datatype> CALENDAR

  - ### DURATIONS

    public static final EnumSet<Datatype> DURATIONS

  - ### GYEARMONTH_REGEX

    public static final String GYEARMONTH_REGEX
    See Also:
      - Constant Field Values

  - ### GYEAR

    public static final String GYEAR
    See Also:
      - Constant Field Values

  - ### GMONTHDAY

    public static final String GMONTHDAY
    See Also:
      - Constant Field Values

  - ### GMONTH

    public static final String GMONTH
    See Also:
      - Constant Field Values

  - ### GDAY

    public static final String GDAY
    See Also:
      - Constant Field Values

  - ### TIME

    public static final String TIME
    See Also:
      - Constant Field Values

  - ### DATE

    public static final String DATE
    See Also:
      - Constant Field Values

  - ### DAY_TIME_DURATION

    public static final String DAY_TIME_DURATION
    See Also:
      - Constant Field Values

  - ### DURATION

    public static final String DURATION
    See Also:
      - Constant Field Values

- ## Method Details

  - ### isPrimitiveDatatype

    public static boolean isPrimitiveDatatype(@Nonnull Datatype theDatatype)
    Return whether or not the `Datatype` is a primitive XML schema type.
    Parameters:
      `theDatatype` - the datatype
    Returns:
      `true` if a built-in type, `false` otherwise

  - ### isCalendarDatatype

    public static boolean isCalendarDatatype(@Nonnull Datatype theDatatype)
    Return whether or not the `Datatype` is an XML datatype calendar type
    Parameters:
      `theDatatype` - the datatype
    Returns:
      `true` if a calendar type, `false` otherwise

  - ### isBuiltInDatatype

    public static boolean isBuiltInDatatype(@Nonnull IRI theIRI)
    Return whether or not the `IRI` is a built-in XML schema type.
    Parameters:
      `theIRI` - the datatype theIRI
    Returns:
      `true` if a built-in type, `false` otherwise

  - ### isBuiltInDatatype

    public static boolean isBuiltInDatatype(@Nonnull Datatype theDatatype)
    Return whether or not the `Datatype` is a built-in XML schema type.
    Parameters:
      `theDatatype` - the datatype
    Returns:
      `true` if a built-in type, `false` otherwise

  - ### isNumericDatatype

    public static boolean isNumericDatatype(@Nonnull Datatype theDatatype)
    Return whether or not the `Datatype` is a numeric datatype such as `xsd:long` or `xsd:decimal`.
    Parameters:
      `theDatatype` - the datatype
    Returns:
      `true` if a numeric type, `false` otherwise

  - ### isDecimalDatatype

    public static boolean isDecimalDatatype(@Nonnull Datatype theDatatype)
    Return whether or not the `Datatype` is `xsd:decimal` or derived from it
    Parameters:
      `theDatatype` - the datatype
    Returns:
      `true` if a decimal type, `false` otherwise

  - ### isDurationDatatype

    public static boolean isDurationDatatype(@Nonnull Datatype theDatatype)

  - ### isIntegerDatatype

    public static boolean isIntegerDatatype(@Nonnull Datatype theDatatype)
    Return whether or not the `Datatype` is `xsd:integer` or derived from it
    Parameters:
      `theDatatype` - the datatype
    Returns:
      `true` if a integer type, `false` otherwise

  - ### isFloatingPointDatatype

    public static boolean isFloatingPointDatatype(@Nonnull Datatype theDatatype)

  - ### isValidValue

    public static boolean isValidValue(@Nonnull Literal theLiteral)
    Verifies if the supplied lexical value is valid for the given literal.
    Parameters:
      `theLiteral` - the literal
    Returns:
      `true` if the supplied lexical value is valid, `false` otherwise.

  - ### isValidValue

    public static boolean isValidValue(@Nonnull String theValue, @Nonnull Datatype theDatatype)
    Verifies if the supplied lexical value is valid for the given datatype.
    Parameters:
      `theValue` - a lexical value
      `theDatatype` - an XML Schema datatatype.
    Returns:
      `true` if the supplied lexical value is valid, `false` otherwise.

  - ### isValidDecimal

    public static boolean isValidDecimal(String value)

  - ### isValidInteger

    public static boolean isValidInteger(String value)

  - ### isValidNegativeInteger

    public static boolean isValidNegativeInteger(String value)

  - ### isValidNonPositiveInteger

    public static boolean isValidNonPositiveInteger(String value)

  - ### isValidNonNegativeInteger

    public static boolean isValidNonNegativeInteger(String value)

  - ### isValidPositiveInteger

    public static boolean isValidPositiveInteger(String value)

  - ### isValidLong

    public static boolean isValidLong(String value)

  - ### isValidInt

    public static boolean isValidInt(String value)

  - ### isValidShort

    public static boolean isValidShort(String value)

  - ### isValidByte

    public static boolean isValidByte(String value)

  - ### isValidUnsignedLong

    public static boolean isValidUnsignedLong(String value)

  - ### isValidUnsignedInt

    public static boolean isValidUnsignedInt(String value)

  - ### isValidUnsignedShort

    public static boolean isValidUnsignedShort(String value)

  - ### isValidUnsignedByte

    public static boolean isValidUnsignedByte(String value)

  - ### isValidFloat

    public static boolean isValidFloat(String value)

  - ### isValidDouble

    public static boolean isValidDouble(String value)

  - ### isValidBoolean

    public static boolean isValidBoolean(String value)

  - ### isValidDuration

    public static boolean isValidDuration(String value)

  - ### isValidDayTimeDuration

    public static boolean isValidDayTimeDuration(String value)

  - ### isValidDateTime

    public static boolean isValidDateTime(String value)

  - ### isValidDate

    public static boolean isValidDate(String value)
    Determines if the supplied value is a valid xsd:date string.
    Parameters:
      `value` - the date
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidTime

    public static boolean isValidTime(String value)
    Determines if the supplied value is a valid xsd:time string.
    Parameters:
      `value` - the time
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidGDay

    public static boolean isValidGDay(String value)
    Determines if the supplied value is a valid xsd:gDay string.
    Parameters:
      `value` - the gday
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidGMonth

    public static boolean isValidGMonth(String value)
    Determines if the supplied value is a valid xsd:gMonth string.
    Parameters:
      `value` - the gmonth
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidGMonthDay

    public static boolean isValidGMonthDay(String value)
    Determines if the supplied value is a valid xsd:gMonthDay string.
    Parameters:
      `value` - the gmonthday
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidGYear

    public static boolean isValidGYear(String value)
    Determines if the supplied value is a valid xsd:gYear string.
    Parameters:
      `value` - the value
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidGYearMonth

    public static boolean isValidGYearMonth(String value)
    Determines if the supplied value is a valid xsd:gYearMonth string.
    Parameters:
      `value` - the value
    Returns:
      `true` if valid, `false` otherwise

  - ### isValidQName

    public static boolean isValidQName(String value)
    Determines if the supplied value is a valid xsd:QName string. Note that this method only checks for syntax errors in the supplied string itself. It does not validate that the prefix is a declared and in-scope namespace prefix.
    Parameters:
      `value` - the qname
    Returns:
      `true` if valid, `false` otherwise

  - ### normalize

    public static String normalize(String value, Datatype datatype)
    Normalizes the supplied value according to the normalization rules for the supplied datatype.
    Parameters:
      `value` - The value to normalize.
      `datatype` - The value's datatype.
    Returns:
      The normalized value if there are any (supported) normalization rules for the supplied datatype, or the original supplied value otherwise.
    Throws:
      `IllegalArgumentException` - If the supplied value is illegal considering the supplied datatype.

  - ### normalizeBoolean

    public static String normalizeBoolean(String theValue)
    Normalizes a boolean value to its canonical representation. More specifically, the values `1` and `0` will be normalized to the canonical values `true` and `false`, respectively. Supplied canonical values will remain as is.
    Parameters:
      `theValue` - The boolean value to normalize.
    Returns:
      The normalized value.
    Throws:
      `IllegalArgumentException` - If the supplied value is not a legal boolean.

  - ### normalizeDecimal

    public static String normalizeDecimal(String decimal)
    Normalizes a decimal to its canonical representation. For example: `120` becomes `120.0`, `+.3` becomes `0.3`, `00012.45000` becomes `12.45` and `-.0` becomes `0.0`.
    Parameters:
      `decimal` - The decimal to normalize.
    Returns:
      The canonical representation of `decimal`.
    Throws:
      `IllegalArgumentException` - If one of the supplied strings is not a legal decimal.

  - ### normalizeInteger

    public static String normalizeInteger(String value)
    Normalizes an integer to its canonical representation. For example: `+120` becomes `120` and `00012` becomes `12`.
    Parameters:
      `value` - The value to normalize.
    Returns:
      The canonical representation of `value`.
    Throws:
      `IllegalArgumentException` - If the supplied value is not a legal integer.

  - ### normalizeNegativeInteger

    public static String normalizeNegativeInteger(String value)
    Normalizes an xsd:negativeInteger.

  - ### normalizeNonPositiveInteger

    public static String normalizeNonPositiveInteger(String value)
    Normalizes an xsd:nonPositiveInteger.

  - ### normalizeNonNegativeInteger

    public static String normalizeNonNegativeInteger(String value)
    Normalizes an xsd:nonNegativeInteger.

  - ### normalizePositiveInteger

    public static String normalizePositiveInteger(String value)
    Normalizes an xsd:positiveInteger.

  - ### normalizeLong

    public static String normalizeLong(String value)
    Normalizes an xsd:long.

  - ### normalizeInt

    public static String normalizeInt(String value)
    Normalizes an xsd:int.

  - ### normalizeShort

    public static String normalizeShort(String value)
    Normalizes an xsd:short.

  - ### normalizeByte

    public static String normalizeByte(String value)
    Normalizes an xsd:byte.

  - ### normalizeUnsignedLong

    public static String normalizeUnsignedLong(String value)
    Normalizes an xsd:unsignedLong.

  - ### normalizeUnsignedInt

    public static String normalizeUnsignedInt(String value)
    Normalizes an xsd:unsignedInt.

  - ### normalizeUnsignedShort

    public static String normalizeUnsignedShort(String value)
    Normalizes an xsd:unsignedShort.

  - ### normalizeUnsignedByte

    public static String normalizeUnsignedByte(String value)
    Normalizes an xsd:unsignedByte.

  - ### normalizeFloat

    public static String normalizeFloat(String value)
    Normalizes a float to its canonical representation.
    Parameters:
      `value` - The value to normalize.
    Returns:
      The canonical representation of `value`.
    Throws:
      `IllegalArgumentException` - If the supplied value is not a legal float.

  - ### normalizeDouble

    public static String normalizeDouble(String value)
    Normalizes a double to its canonical representation.
    Parameters:
      `value` - The value to normalize.
    Returns:
      The canonical representation of `value`.
    Throws:
      `IllegalArgumentException` - If the supplied value is not a legal double.

  - ### normalizeDateTime

    public static String normalizeDateTime(String value)
    Normalizes an xsd:dateTime.
    Parameters:
      `value` - The value to normalize.
    Returns:
      The normalized value.
    Throws:
      `IllegalArgumentException` - If the supplied value is not a legal xsd:dateTime value.

  - ### collapseWhiteSpace

    public static String collapseWhiteSpace(String s)
    Replaces all contiguous sequences of #x9 (tab), #xA (line feed) and #xD (carriage return) with a single #x20 (space) character, and removes any leading and trailing whitespace characters, as specified for whiteSpace facet `collapse`.

  - ### compareCanonicalDecimals

    public static int compareCanonicalDecimals(String dec1, String dec2)
    Compares two canonical decimals to eachother.
    Returns:
      A negative number if `dec1` is smaller than `dec2`, `0` if they are equal, or positive (>0) if `dec1` is larger than `dec2`. The result is undefined when one or both of the arguments is not a canonical decimal.
    Throws:
      `IllegalArgumentException` - If one of the supplied strings is not a legal decimal.

  - ### compareCanonicalIntegers

    public static int compareCanonicalIntegers(String int1, String int2)
    Compares two canonical integers to eachother.
    Returns:
      A negative number if `int1` is smaller than `int2`, `0` if they are equal, or positive (>0) if `int1` is larger than `int2`. The result is undefined when one or both of the arguments is not a canonical integer.
    Throws:
      `IllegalArgumentException` - If one of the supplied strings is not a legal integer.

  - ### parseCalendar

    public static XMLGregorianCalendar parseCalendar(String s)
    Parses the supplied calendar value string and returns its value.
    Parameters:
      `s` - A string representation of an xsd:dateTime, xsd:time, xsd:date, xsd:gYearMonth, xsd:gMonthDay, xsd:gYear, xsd:gMonth or xsd:gDay value.
    Returns:
      The calendar value represented by the supplied string argument.
    Throws:
      `NumberFormatException` - If the supplied string is not a valid calendar value.