Class XMLDatatypeUtil


  • public class XMLDatatypeUtil
    extends java.lang.Object
    Provides methods for handling the standard XML Schema datatypes.
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLDatatypeUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String collapseWhiteSpace​(java.lang.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 compare​(java.lang.String value1, java.lang.String value2, IRI datatype)  
      static int compareBytes​(java.lang.String int1, java.lang.String int2)  
      static int compareCanonicalDecimals​(java.lang.String dec1, java.lang.String dec2)
      Compares two canonical decimals to each other.
      static int compareCanonicalDoubles​(java.lang.String double1, java.lang.String double2)
      Compares two canonical doubles to eachother.
      static int compareCanonicalFloats​(java.lang.String float1, java.lang.String float2)
      Compares two canonical floats to each other.
      static int compareCanonicalFPNumbers​(java.lang.String float1, java.lang.String float2)
      Compares two canonical floating point numbers to each other.
      static int compareCanonicalIntegers​(java.lang.String int1, java.lang.String int2)
      Compares two canonical integers to each other.
      static int compareDateTime​(java.lang.String value1, java.lang.String value2)
      Compares two dateTime objects.
      static int compareDecimals​(java.lang.String dec1, java.lang.String dec2)
      Compares two decimals to eachother.
      static int compareDoubles​(java.lang.String double1, java.lang.String double2)
      Compares two doubles to each other.
      static int compareFloats​(java.lang.String float1, java.lang.String float2)
      Compares two floats to each other.
      static int compareFPNumbers​(java.lang.String fp1, java.lang.String fp2)
      Compares two floating point numbers to eachother.
      static int compareIntegers​(java.lang.String int1, java.lang.String int2)
      Compares two integers to each other.
      static int compareInts​(java.lang.String int1, java.lang.String int2)  
      static int compareLongs​(java.lang.String int1, java.lang.String int2)  
      static int compareNegativeIntegers​(java.lang.String int1, java.lang.String int2)  
      static int compareNonNegativeIntegers​(java.lang.String int1, java.lang.String int2)  
      static int compareNonPositiveIntegers​(java.lang.String int1, java.lang.String int2)  
      static int comparePositiveIntegers​(java.lang.String int1, java.lang.String int2)  
      static int compareShorts​(java.lang.String int1, java.lang.String int2)  
      static int compareUnsignedBytes​(java.lang.String int1, java.lang.String int2)  
      static int compareUnsignedInts​(java.lang.String int1, java.lang.String int2)  
      static int compareUnsignedLongs​(java.lang.String int1, java.lang.String int2)  
      static int compareUnsignedShorts​(java.lang.String int1, java.lang.String int2)  
      static boolean isBuiltInDatatype​(IRI datatype)
      Checks whether the supplied datatype is a built-in XML Schema datatype.
      static boolean isCalendarDatatype​(IRI datatype)
      Checks whether the supplied datatype is equal to xsd:dateTime, xsd:date, xsd:time, xsd:gYearMonth, xsd:gMonthDay, xsd:gYear, xsd:gMonth or xsd:gDay.These are the primitive datatypes that represent dates and/or times.
      static boolean isDecimalDatatype​(IRI datatype)
      Checks whether the supplied datatype is equal to xsd:decimal or one of the built-in datatypes that is derived from xsd:decimal.
      static boolean isDerivedDatatype​(IRI datatype)
      Checks whether the supplied datatype is a derived XML Schema datatype.
      static boolean isDurationDatatype​(IRI datatype)
      Checks whether the supplied datatype is equal to xsd:duration, xsd:dayTimeDuration, xsd:yearMonthDuration.
      static boolean isFloatingPointDatatype​(IRI datatype)
      Checks whether the supplied datatype is equal to xsd:float or xsd:double.
      static boolean isIntegerDatatype​(IRI datatype)
      Checks whether the supplied datatype is equal to xsd:integer or one of the built-in datatypes that is derived from xsd:integer.
      private static boolean isNotDigit​(char c)
      Checks whether the supplied character is a digit.
      private static boolean isNotNameChar​(int c)  
      private static boolean isNotNameStartChar​(int c)  
      private static boolean isNotPrefixStartChar​(int c)  
      static boolean isNumericDatatype​(IRI datatype)
      Checks whether the supplied datatype is a numeric datatype, i.e.if it is equal to xsd:float, xsd:double, xsd:decimal or one of the datatypes derived from xsd:decimal.
      static boolean isOrderedDatatype​(IRI datatype)
      Checks whether the supplied datatype is ordered.The values of an ordered datatype can be compared to each other using operators like < and >.
      static boolean isPrimitiveDatatype​(IRI datatype)
      Checks whether the supplied datatype is a primitive XML Schema datatype.
      static boolean isValidAnyURI​(java.lang.String value)
      Determines if the supplied value is an Internationalized Resource Identifier Reference (IRI).
      static boolean isValidBoolean​(java.lang.String value)
      Verifies if the supplied lexical value is a valid boolean or not.
      static boolean isValidByte​(java.lang.String value)
      Verifies if the supplied lexical value is a valid byte or not.
      private static boolean isValidCalendarValue​(java.lang.String value)
      Determines if the supplied string can be parsed to a valid XMLGregorianCalendar value.
      static boolean isValidDate​(java.lang.String value)
      Determines if the supplied value is a valid xsd:date string.
      static boolean isValidDateTime​(java.lang.String value)
      Verifies if the supplied lexical value is a valid date-time.
      static boolean isValidDateTimeStamp​(java.lang.String value)
      Verifies if the supplied lexical value is a valid date-timestamp.
      static boolean isValidDayTimeDuration​(java.lang.String value)
      Verifies if the supplied lexical value is a valid day-time duration ot not.
      static boolean isValidDecimal​(java.lang.String value)
      Verifies if the supplied lexical value is a valid decimal or not.
      static boolean isValidDouble​(java.lang.String value)
      Verifies if the supplied lexical value is a valid double or not.
      static boolean isValidDuration​(java.lang.String value)
      Verifies if the supplied lexical value is a valid duration.
      static boolean isValidFloat​(java.lang.String value)
      Verifies if the supplied lexical value is a valid float or not.
      static boolean isValidGDay​(java.lang.String value)
      Determines if the supplied value is a valid xsd:gDay string.
      static boolean isValidGMonth​(java.lang.String value)
      Determines if the supplied value is a valid xsd:gMonth string.
      static boolean isValidGMonthDay​(java.lang.String value)
      Determines if the supplied value is a valid xsd:gMonthDay string.
      static boolean isValidGYear​(java.lang.String value)
      Determines if the supplied value is a valid xsd:gYear string.
      static boolean isValidGYearMonth​(java.lang.String value)
      Determines if the supplied value is a valid xsd:gYearMonth string.
      static boolean isValidInt​(java.lang.String value)
      Verifies if the supplied lexical value is a valid integer or not.
      static boolean isValidInteger​(java.lang.String value)
      Verifies if the supplied lexical value is a valid integer or not.
      static boolean isValidLong​(java.lang.String value)
      Verifies if the supplied lexical value is a valid long or not.
      static boolean isValidNegativeInteger​(java.lang.String value)
      Verifies if the supplied lexical value is a valid negative integer or not.
      static boolean isValidNonNegativeInteger​(java.lang.String value)
      Verifies if the supplied lexical value is a valid non-negative integer or not.
      static boolean isValidNonPositiveInteger​(java.lang.String value)
      Verifies if the supplied lexical value is a valid non-positive integer or not.
      static boolean isValidPositiveInteger​(java.lang.String value)
      Verifies if the supplied lexical value is a valid positive integer or not.
      static boolean isValidQName​(java.lang.String value)
      Determines if the supplied value is a valid xsd:QName string.
      static boolean isValidShort​(java.lang.String value)
      Verifies if the supplied lexical value is a valid short or not.
      static boolean isValidTime​(java.lang.String value)
      Determines if the supplied value is a valid xsd:time string.
      static boolean isValidUnsignedByte​(java.lang.String value)
      Verifies if the supplied lexical value is a valid unsigned byte or not.
      static boolean isValidUnsignedInt​(java.lang.String value)
      Verifies if the supplied lexical value is a valid unsigned int.
      static boolean isValidUnsignedLong​(java.lang.String value)
      Verifies if the supplied lexical value is a valid unsigned long or not.
      static boolean isValidUnsignedShort​(java.lang.String value)
      Verifies if the supplied lexical value is a valid unsigned short or not.
      static boolean isValidValue​(java.lang.String value, CoreDatatype datatype)  
      static boolean isValidValue​(java.lang.String value, CoreDatatype.XSD datatype)  
      static boolean isValidValue​(java.lang.String value, IRI datatype)
      Verifies if the supplied lexical value is valid for the given datatype.
      static boolean isValidYearMonthDuration​(java.lang.String value)
      Verifies if the supplied lexical value is a valid year-month duration.
      static java.lang.String normalize​(java.lang.String value, CoreDatatype.XSD datatype)  
      static java.lang.String normalize​(java.lang.String value, IRI datatype)
      Normalizes the supplied value according to the normalization rules for the supplied datatype.
      static java.lang.String normalizeBoolean​(java.lang.String value)
      Normalizes a boolean value to its canonical representation.
      static java.lang.String normalizeByte​(java.lang.String value)
      Normalizes an xsd:byte.
      static java.lang.String normalizeDateTime​(java.lang.String value)
      Normalizes an xsd:dateTime.
      static java.lang.String normalizeDecimal​(java.lang.String decimal)
      Normalizes a decimal to its canonical representation.
      static java.lang.String normalizeDouble​(java.lang.String value)
      Normalizes a double to its canonical representation.
      static java.lang.String normalizeFloat​(java.lang.String value)
      Normalizes a float to its canonical representation.
      static java.lang.String normalizeFPNumber​(java.lang.String value)
      Normalizes a floating point number to its canonical representation.
      private static java.lang.String normalizeFPNumber​(java.lang.String value, java.lang.String minMantissa, java.lang.String maxMantissa, java.lang.String minExponent, java.lang.String maxExponent)
      Normalizes a floating point lexical value to its canonical representation.
      static java.lang.String normalizeInt​(java.lang.String value)
      Normalizes an xsd:int.
      static java.lang.String normalizeInteger​(java.lang.String value)
      Normalizes an integer to its canonical representation.
      private static java.lang.String normalizeIntegerValue​(java.lang.String integer, java.lang.String minValue, java.lang.String maxValue)
      Normalizes an integer to its canonical representation and checks that the value is in the range [minValue, maxValue].
      static java.lang.String normalizeLong​(java.lang.String value)
      Normalizes an xsd:long.
      static java.lang.String normalizeNegativeInteger​(java.lang.String value)
      Normalizes an xsd:negativeInteger.
      static java.lang.String normalizeNonNegativeInteger​(java.lang.String value)
      Normalizes an xsd:nonNegativeInteger.
      static java.lang.String normalizeNonPositiveInteger​(java.lang.String value)
      Normalizes an xsd:nonPositiveInteger.
      static java.lang.String normalizePositiveInteger​(java.lang.String value)
      Normalizes an xsd:positiveInteger.
      static java.lang.String normalizeShort​(java.lang.String value)
      Normalizes an xsd:short.
      static java.lang.String normalizeUnsignedByte​(java.lang.String value)
      Normalizes an xsd:unsignedByte.
      static java.lang.String normalizeUnsignedInt​(java.lang.String value)
      Normalizes an xsd:unsignedInt.
      static java.lang.String normalizeUnsignedLong​(java.lang.String value)
      Normalizes an xsd:unsignedLong.
      static java.lang.String normalizeUnsignedShort​(java.lang.String value)
      Normalizes an xsd:unsignedShort.
      static boolean parseBoolean​(java.lang.String s)
      Parses the supplied xsd:boolean string and returns its value.
      static byte parseByte​(java.lang.String s)
      Parses the supplied xsd:byte string and returns its value.
      static javax.xml.datatype.XMLGregorianCalendar parseCalendar​(java.lang.String s)
      Parses the supplied calendar value string and returns its value.
      static java.math.BigDecimal parseDecimal​(java.lang.String s)
      Parses the supplied decimal/floating point string and returns its value.
      static double parseDouble​(java.lang.String s)
      Parses the supplied xsd:double string and returns its value.
      static javax.xml.datatype.Duration parseDuration​(java.lang.String s)
      Parses the supplied xsd:duration value string and returns its value.
      static float parseFloat​(java.lang.String s)
      Parses the supplied xsd:float string and returns its value.
      static int parseInt​(java.lang.String s)
      Parses the supplied xsd:int strings and returns its value.
      static java.math.BigInteger parseInteger​(java.lang.String s)
      Parses the supplied xsd:integer string and returns its value.
      static long parseLong​(java.lang.String s)
      Parses the supplied xsd:long string and returns its value.
      static short parseShort​(java.lang.String s)
      Parses the supplied xsd:short string and returns its value.
      static CoreDatatype.XSD qnameToCoreDatatype​(javax.xml.namespace.QName qname)  
      static IRI qnameToURI​(javax.xml.namespace.QName qname)
      Maps a datatype QName from the javax.xml.namespace package to an XML Schema 1.0 URI for the corresponding datatype.
      static java.lang.String toString​(java.lang.Number value)  
      private static java.lang.String trimPlusSign​(java.lang.String s)
      Removes the first character from the supplied string if this is a plus sign ('+').
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • POSITIVE_INFINITY

        public static final java.lang.String POSITIVE_INFINITY
        See Also:
        Constant Field Values
      • NEGATIVE_INFINITY

        public static final java.lang.String NEGATIVE_INFINITY
        See Also:
        Constant Field Values
      • dtFactory

        private static final javax.xml.datatype.DatatypeFactory dtFactory
      • P_DURATION

        private static final java.util.regex.Pattern P_DURATION
      • P_DAYTIMEDURATION

        private static final java.util.regex.Pattern P_DAYTIMEDURATION
      • P_YEARMONTHDURATION

        private static final java.util.regex.Pattern P_YEARMONTHDURATION
      • P_TIMEZONE

        private static final java.util.regex.Pattern P_TIMEZONE
      • P_DATE

        private static final java.util.regex.Pattern P_DATE
      • P_TIME

        private static final java.util.regex.Pattern P_TIME
      • P_GDAY

        private static final java.util.regex.Pattern P_GDAY
      • P_GMONTH

        private static final java.util.regex.Pattern P_GMONTH
      • P_GMONTHDAY

        private static final java.util.regex.Pattern P_GMONTHDAY
      • P_GYEAR

        private static final java.util.regex.Pattern P_GYEAR
      • P_GYEARMONTH

        private static final java.util.regex.Pattern P_GYEARMONTH
      • primitiveDatatypes

        private static final java.util.Set<IRI> primitiveDatatypes
      • derivedDatatypes

        private static final java.util.Set<IRI> derivedDatatypes
      • integerDatatypes

        private static final java.util.Set<IRI> integerDatatypes
      • calendarDatatypes

        private static final java.util.Set<IRI> calendarDatatypes
      • durationDatatypes

        private static final java.util.Set<IRI> durationDatatypes
    • Constructor Detail

      • XMLDatatypeUtil

        public XMLDatatypeUtil()
    • Method Detail

      • isPrimitiveDatatype

        public static boolean isPrimitiveDatatype​(IRI datatype)
        Checks whether the supplied datatype is a primitive XML Schema datatype.
        Parameters:
        datatype -
        Returns:
        true if the datatype is a primitive type
      • isDerivedDatatype

        public static boolean isDerivedDatatype​(IRI datatype)
        Checks whether the supplied datatype is a derived XML Schema datatype.
        Parameters:
        datatype -
        Returns:
        true if the datatype is a derived type
      • isBuiltInDatatype

        public static boolean isBuiltInDatatype​(IRI datatype)
        Checks whether the supplied datatype is a built-in XML Schema datatype.
        Parameters:
        datatype -
        Returns:
        true if it is a primitive or derived XML Schema type
      • isNumericDatatype

        public static boolean isNumericDatatype​(IRI datatype)
        Checks whether the supplied datatype is a numeric datatype, i.e.if it is equal to xsd:float, xsd:double, xsd:decimal or one of the datatypes derived from xsd:decimal.
        Parameters:
        datatype -
        Returns:
        true of it is a decimal or floating point type
      • isDecimalDatatype

        public static boolean isDecimalDatatype​(IRI datatype)
        Checks whether the supplied datatype is equal to xsd:decimal or one of the built-in datatypes that is derived from xsd:decimal.
        Parameters:
        datatype -
        Returns:
        true if it is a decimal datatype
      • isIntegerDatatype

        public static boolean isIntegerDatatype​(IRI datatype)
        Checks whether the supplied datatype is equal to xsd:integer or one of the built-in datatypes that is derived from xsd:integer.
        Parameters:
        datatype -
        Returns:
        true if it is an integer type
      • isFloatingPointDatatype

        public static boolean isFloatingPointDatatype​(IRI datatype)
        Checks whether the supplied datatype is equal to xsd:float or xsd:double.
        Parameters:
        datatype -
        Returns:
        true if it is a floating point type
      • isCalendarDatatype

        public static boolean isCalendarDatatype​(IRI datatype)
        Checks whether the supplied datatype is equal to xsd:dateTime, xsd:date, xsd:time, xsd:gYearMonth, xsd:gMonthDay, xsd:gYear, xsd:gMonth or xsd:gDay.These are the primitive datatypes that represent dates and/or times.
        Parameters:
        datatype -
        Returns:
        true if it is a calendar type
        See Also:
        XMLGregorianCalendar
      • isDurationDatatype

        public static boolean isDurationDatatype​(IRI datatype)
        Checks whether the supplied datatype is equal to xsd:duration, xsd:dayTimeDuration, xsd:yearMonthDuration. These are the datatypes that represents durations.
        Parameters:
        datatype -
        Returns:
        true if it is a duration type
        See Also:
        Duration
      • isOrderedDatatype

        public static boolean isOrderedDatatype​(IRI datatype)
        Checks whether the supplied datatype is ordered.The values of an ordered datatype can be compared to each other using operators like < and >.
        Parameters:
        datatype -
        Returns:
        true if the datatype is ordered
      • isValidValue

        public static boolean isValidValue​(java.lang.String value,
                                           IRI datatype)
        Verifies if the supplied lexical value is valid for the given datatype.
        Parameters:
        value - a lexical value
        datatype - an XML Schema datatatype.
        Returns:
        true if the supplied lexical value is valid, false otherwise.
      • isValidValue

        public static boolean isValidValue​(java.lang.String value,
                                           CoreDatatype datatype)
      • isValidValue

        public static boolean isValidValue​(java.lang.String value,
                                           CoreDatatype.XSD datatype)
      • isValidDecimal

        public static boolean isValidDecimal​(java.lang.String value)
        Verifies if the supplied lexical value is a valid decimal or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidInteger

        public static boolean isValidInteger​(java.lang.String value)
        Verifies if the supplied lexical value is a valid integer or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidNegativeInteger

        public static boolean isValidNegativeInteger​(java.lang.String value)
        Verifies if the supplied lexical value is a valid negative integer or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidNonPositiveInteger

        public static boolean isValidNonPositiveInteger​(java.lang.String value)
        Verifies if the supplied lexical value is a valid non-positive integer or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidNonNegativeInteger

        public static boolean isValidNonNegativeInteger​(java.lang.String value)
        Verifies if the supplied lexical value is a valid non-negative integer or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidPositiveInteger

        public static boolean isValidPositiveInteger​(java.lang.String value)
        Verifies if the supplied lexical value is a valid positive integer or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidLong

        public static boolean isValidLong​(java.lang.String value)
        Verifies if the supplied lexical value is a valid long or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidInt

        public static boolean isValidInt​(java.lang.String value)
        Verifies if the supplied lexical value is a valid integer or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidShort

        public static boolean isValidShort​(java.lang.String value)
        Verifies if the supplied lexical value is a valid short or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidByte

        public static boolean isValidByte​(java.lang.String value)
        Verifies if the supplied lexical value is a valid byte or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidUnsignedLong

        public static boolean isValidUnsignedLong​(java.lang.String value)
        Verifies if the supplied lexical value is a valid unsigned long or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidUnsignedInt

        public static boolean isValidUnsignedInt​(java.lang.String value)
        Verifies if the supplied lexical value is a valid unsigned int.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidUnsignedShort

        public static boolean isValidUnsignedShort​(java.lang.String value)
        Verifies if the supplied lexical value is a valid unsigned short or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidUnsignedByte

        public static boolean isValidUnsignedByte​(java.lang.String value)
        Verifies if the supplied lexical value is a valid unsigned byte or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidFloat

        public static boolean isValidFloat​(java.lang.String value)
        Verifies if the supplied lexical value is a valid float or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidDouble

        public static boolean isValidDouble​(java.lang.String value)
        Verifies if the supplied lexical value is a valid double or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidBoolean

        public static boolean isValidBoolean​(java.lang.String value)
        Verifies if the supplied lexical value is a valid boolean or not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidDuration

        public static boolean isValidDuration​(java.lang.String value)
        Verifies if the supplied lexical value is a valid duration.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidDayTimeDuration

        public static boolean isValidDayTimeDuration​(java.lang.String value)
        Verifies if the supplied lexical value is a valid day-time duration ot not.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidYearMonthDuration

        public static boolean isValidYearMonthDuration​(java.lang.String value)
        Verifies if the supplied lexical value is a valid year-month duration.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidDateTime

        public static boolean isValidDateTime​(java.lang.String value)
        Verifies if the supplied lexical value is a valid date-time.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidDateTimeStamp

        public static boolean isValidDateTimeStamp​(java.lang.String value)
        Verifies if the supplied lexical value is a valid date-timestamp.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidDate

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

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

        public static boolean isValidGDay​(java.lang.String value)
        Determines if the supplied value is a valid xsd:gDay string.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidGMonth

        public static boolean isValidGMonth​(java.lang.String value)
        Determines if the supplied value is a valid xsd:gMonth string.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidGMonthDay

        public static boolean isValidGMonthDay​(java.lang.String value)
        Determines if the supplied value is a valid xsd:gMonthDay string.
        Parameters:
        value -
        Returns:
        true if valid, false otherwise
      • isValidGYear

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

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

        public static boolean isValidQName​(java.lang.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 -
        Returns:
        true if valid, false otherwise
      • isValidAnyURI

        public static boolean isValidAnyURI​(java.lang.String value)
        Determines if the supplied value is an Internationalized Resource Identifier Reference (IRI). An anyURI value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be an IRI Reference). This type should be used when the value fulfills the role of an IRI, as defined in [RFC 3987] or its successor(s) in the IETF Standards Track.
        Parameters:
        value -
        Returns:
        true if a valid IRI, false otherwise
      • isNotPrefixStartChar

        private static boolean isNotPrefixStartChar​(int c)
      • isNotNameStartChar

        private static boolean isNotNameStartChar​(int c)
      • isNotNameChar

        private static boolean isNotNameChar​(int c)
      • isValidCalendarValue

        private static boolean isValidCalendarValue​(java.lang.String value)
        Determines if the supplied string can be parsed to a valid XMLGregorianCalendar value.
        Parameters:
        value -
        Returns:
        true if the supplied string is a parsable calendar value, false otherwise.
      • normalize

        public static java.lang.String normalize​(java.lang.String value,
                                                 IRI 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:
        java.lang.IllegalArgumentException - If the supplied value is illegal considering the supplied datatype.
      • normalize

        public static java.lang.String normalize​(java.lang.String value,
                                                 CoreDatatype.XSD datatype)
      • normalizeBoolean

        public static java.lang.String normalizeBoolean​(java.lang.String value)
        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:
        value - The boolean value to normalize.
        Returns:
        The normalized value.
        Throws:
        java.lang.IllegalArgumentException - If the supplied value is not a legal boolean.
      • normalizeDecimal

        public static java.lang.String normalizeDecimal​(java.lang.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:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal decimal.
      • normalizeInteger

        public static java.lang.String normalizeInteger​(java.lang.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:
        java.lang.IllegalArgumentException - If the supplied value is not a legal integer.
      • normalizeNegativeInteger

        public static java.lang.String normalizeNegativeInteger​(java.lang.String value)
        Normalizes an xsd:negativeInteger.
      • normalizeNonPositiveInteger

        public static java.lang.String normalizeNonPositiveInteger​(java.lang.String value)
        Normalizes an xsd:nonPositiveInteger.
      • normalizeNonNegativeInteger

        public static java.lang.String normalizeNonNegativeInteger​(java.lang.String value)
        Normalizes an xsd:nonNegativeInteger.
      • normalizePositiveInteger

        public static java.lang.String normalizePositiveInteger​(java.lang.String value)
        Normalizes an xsd:positiveInteger.
      • normalizeLong

        public static java.lang.String normalizeLong​(java.lang.String value)
        Normalizes an xsd:long.
      • normalizeInt

        public static java.lang.String normalizeInt​(java.lang.String value)
        Normalizes an xsd:int.
      • normalizeShort

        public static java.lang.String normalizeShort​(java.lang.String value)
        Normalizes an xsd:short.
      • normalizeByte

        public static java.lang.String normalizeByte​(java.lang.String value)
        Normalizes an xsd:byte.
      • normalizeUnsignedLong

        public static java.lang.String normalizeUnsignedLong​(java.lang.String value)
        Normalizes an xsd:unsignedLong.
      • normalizeUnsignedInt

        public static java.lang.String normalizeUnsignedInt​(java.lang.String value)
        Normalizes an xsd:unsignedInt.
      • normalizeUnsignedShort

        public static java.lang.String normalizeUnsignedShort​(java.lang.String value)
        Normalizes an xsd:unsignedShort.
      • normalizeUnsignedByte

        public static java.lang.String normalizeUnsignedByte​(java.lang.String value)
        Normalizes an xsd:unsignedByte.
      • normalizeIntegerValue

        private static java.lang.String normalizeIntegerValue​(java.lang.String integer,
                                                              java.lang.String minValue,
                                                              java.lang.String maxValue)
        Normalizes an integer to its canonical representation and checks that the value is in the range [minValue, maxValue].
      • normalizeFloat

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

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

        public static java.lang.String normalizeFPNumber​(java.lang.String value)
        Normalizes a floating point number to its canonical representation.
        Parameters:
        value - The value to normalize.
        Returns:
        The canonical representation of value.
        Throws:
        java.lang.IllegalArgumentException - If the supplied value is not a legal floating point number.
      • normalizeFPNumber

        private static java.lang.String normalizeFPNumber​(java.lang.String value,
                                                          java.lang.String minMantissa,
                                                          java.lang.String maxMantissa,
                                                          java.lang.String minExponent,
                                                          java.lang.String maxExponent)
        Normalizes a floating point lexical value to its canonical representation.
        Parameters:
        value - The lexical value to normalize.
        minMantissa - A normalized decimal indicating the lowest value that the mantissa may have.
        maxMantissa - A normalized decimal indicating the highest value that the mantissa may have.
        minExponent - A normalized integer indicating the lowest value that the exponent may have.
        maxExponent - A normalized integer indicating the highest value that the exponent may have.
        Returns:
        The canonical representation of value.
        Throws:
        java.lang.IllegalArgumentException - If the supplied value is not a legal floating point lexical value.
      • normalizeDateTime

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

        public static java.lang.String collapseWhiteSpace​(java.lang.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.
        Parameters:
        s -
        Returns:
        new string
      • compare

        public static int compare​(java.lang.String value1,
                                  java.lang.String value2,
                                  IRI datatype)
      • compareDecimals

        public static int compareDecimals​(java.lang.String dec1,
                                          java.lang.String dec2)
        Compares two decimals to eachother.
        Parameters:
        dec1 -
        dec2 -
        Returns:
        A negative number if dec1 is smaller than dec2, 0 if they are equal, or positive (>0) if dec1 is larger than dec2.
        Throws:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal decimal.
      • compareCanonicalDecimals

        public static int compareCanonicalDecimals​(java.lang.String dec1,
                                                   java.lang.String dec2)
        Compares two canonical decimals to each other.
        Parameters:
        dec1 -
        dec2 -
        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:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal decimal.
      • compareIntegers

        public static int compareIntegers​(java.lang.String int1,
                                          java.lang.String int2)
        Compares two integers to each other.
        Parameters:
        int1 -
        int2 -
        Returns:
        A negative number if int1 is smaller than int2, 0 if they are equal, or positive (>0) if int1 is larger than int2.
        Throws:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal integer.
      • compareCanonicalIntegers

        public static int compareCanonicalIntegers​(java.lang.String int1,
                                                   java.lang.String int2)
        Compares two canonical integers to each other.
        Parameters:
        int1 -
        int2 -
        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:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal integer.
      • compareNegativeIntegers

        public static int compareNegativeIntegers​(java.lang.String int1,
                                                  java.lang.String int2)
      • compareNonPositiveIntegers

        public static int compareNonPositiveIntegers​(java.lang.String int1,
                                                     java.lang.String int2)
      • compareNonNegativeIntegers

        public static int compareNonNegativeIntegers​(java.lang.String int1,
                                                     java.lang.String int2)
      • comparePositiveIntegers

        public static int comparePositiveIntegers​(java.lang.String int1,
                                                  java.lang.String int2)
      • compareLongs

        public static int compareLongs​(java.lang.String int1,
                                       java.lang.String int2)
      • compareInts

        public static int compareInts​(java.lang.String int1,
                                      java.lang.String int2)
      • compareShorts

        public static int compareShorts​(java.lang.String int1,
                                        java.lang.String int2)
      • compareBytes

        public static int compareBytes​(java.lang.String int1,
                                       java.lang.String int2)
      • compareUnsignedLongs

        public static int compareUnsignedLongs​(java.lang.String int1,
                                               java.lang.String int2)
      • compareUnsignedInts

        public static int compareUnsignedInts​(java.lang.String int1,
                                              java.lang.String int2)
      • compareUnsignedShorts

        public static int compareUnsignedShorts​(java.lang.String int1,
                                                java.lang.String int2)
      • compareUnsignedBytes

        public static int compareUnsignedBytes​(java.lang.String int1,
                                               java.lang.String int2)
      • compareFloats

        public static int compareFloats​(java.lang.String float1,
                                        java.lang.String float2)
        Compares two floats to each other.
        Parameters:
        float1 -
        float2 -
        Returns:
        A negative number if float1 is smaller than float2, 0 if they are equal, or positive (>0) if float1 is larger than float2.
        Throws:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal float or if NaN is compared to a float other than NaN.
      • compareCanonicalFloats

        public static int compareCanonicalFloats​(java.lang.String float1,
                                                 java.lang.String float2)
        Compares two canonical floats to each other.
        Parameters:
        float1 -
        float2 -
        Returns:
        A negative number if float1 is smaller than float2, 0 if they are equal, or positive (>0) if float1 is larger than float2. The result is undefined when one or both of the arguments is not a canonical float.
        Throws:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal float or if NaN is compared to a float other than NaN.
      • compareDoubles

        public static int compareDoubles​(java.lang.String double1,
                                         java.lang.String double2)
        Compares two doubles to each other.
        Parameters:
        double1 -
        double2 -
        Returns:
        A negative number if double1 is smaller than double2, 0 if they are equal, or positive (>0) if double1 is larger than double2.
        Throws:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal double or if NaN is compared to a double other than NaN.
      • compareCanonicalDoubles

        public static int compareCanonicalDoubles​(java.lang.String double1,
                                                  java.lang.String double2)
        Compares two canonical doubles to eachother.
        Parameters:
        double1 -
        double2 -
        Returns:
        A negative number if double1 is smaller than double2, 0 if they are equal, or positive (>0) if double1 is larger than double2. The result is undefined when one or both of the arguments is not a canonical double.
        Throws:
        java.lang.IllegalArgumentException - If one of the supplied strings is not a legal double or if NaN is compared to a double other than NaN.
      • compareFPNumbers

        public static int compareFPNumbers​(java.lang.String fp1,
                                           java.lang.String fp2)
        Compares two floating point numbers to eachother.
        Parameters:
        fp1 -
        fp2 -
        Returns:
        A negative number if float1 is smaller than float2, 0 if they are equal, or positive (>0) if float1 is larger than float2. @throws IllegalArgumentException If one of the supplied strings is not a legal floating point number or if NaN is compared to a floating point number other than NaN.
      • compareCanonicalFPNumbers

        public static int compareCanonicalFPNumbers​(java.lang.String float1,
                                                    java.lang.String float2)
        Compares two canonical floating point numbers to each other.
        Parameters:
        float1 -
        float2 -
        Returns:
        A negative number if float1 is smaller than float2, 0 if they are equal, or positive (>0) if float1 is larger than float2. The result is undefined when one or both of the arguments is not a canonical floating point number. @throws IllegalArgumentException If one of the supplied strings is not a legal floating point number or if NaN is compared to a floating point number other than NaN.
      • compareDateTime

        public static int compareDateTime​(java.lang.String value1,
                                          java.lang.String value2)
        Compares two dateTime objects. Important: The comparison only works if both values have, or both values don't have specified a valid value for the timezone.
        Parameters:
        value1 - An xsd:dateTime value.
        value2 - An xsd:dateTime value.
        Returns:
        -1 if value1 is before value2 (i.e. if the dateTime object represented by value1 is before the dateTime object represented by value2), 0 if both are equal and 1 if value2 is before value1
        .
      • parseBoolean

        public static boolean parseBoolean​(java.lang.String s)
        Parses the supplied xsd:boolean string and returns its value.
        Parameters:
        s - A string representation of an xsd:boolean value.
        Returns:
        The boolean value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:boolean value.
      • parseByte

        public static byte parseByte​(java.lang.String s)
        Parses the supplied xsd:byte string and returns its value.
        Parameters:
        s - A string representation of an xsd:byte value.
        Returns:
        The byte value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:byte value.
      • parseShort

        public static short parseShort​(java.lang.String s)
        Parses the supplied xsd:short string and returns its value.
        Parameters:
        s - A string representation of an xsd:short value.
        Returns:
        The short value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:short value.
      • parseInt

        public static int parseInt​(java.lang.String s)
        Parses the supplied xsd:int strings and returns its value.
        Parameters:
        s - A string representation of an xsd:int value.
        Returns:
        The int value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:int value.
      • parseLong

        public static long parseLong​(java.lang.String s)
        Parses the supplied xsd:long string and returns its value.
        Parameters:
        s - A string representation of an xsd:long value.
        Returns:
        The long value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:long value.
      • parseFloat

        public static float parseFloat​(java.lang.String s)
        Parses the supplied xsd:float string and returns its value.
        Parameters:
        s - A string representation of an xsd:float value.
        Returns:
        The float value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:float value.
      • parseDouble

        public static double parseDouble​(java.lang.String s)
        Parses the supplied xsd:double string and returns its value.
        Parameters:
        s - A string representation of an xsd:double value.
        Returns:
        The double value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:double value.
      • parseInteger

        public static java.math.BigInteger parseInteger​(java.lang.String s)
        Parses the supplied xsd:integer string and returns its value.
        Parameters:
        s - A string representation of an xsd:integer value.
        Returns:
        The integer value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:integer value.
      • parseDecimal

        public static java.math.BigDecimal parseDecimal​(java.lang.String s)
        Parses the supplied decimal/floating point string and returns its value.
        Parameters:
        s - A string representation of an xsd:decimal or xsd:double value.
        Returns:
        The decimal/floating point value represented by the supplied string argument.
        Throws:
        java.lang.NumberFormatException - If the supplied string is not a valid xsd:decimal or xsd:double value.
      • parseCalendar

        public static javax.xml.datatype.XMLGregorianCalendar parseCalendar​(java.lang.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:
        java.lang.IllegalArgumentException - If the supplied string is not a valid calendar value.
      • parseDuration

        public static javax.xml.datatype.Duration parseDuration​(java.lang.String s)
        Parses the supplied xsd:duration value string and returns its value.
        Parameters:
        s - A string representation of an xsd:duration value.
        Returns:
        The Duration value represented by the supplied string argument.
        Throws:
        java.lang.IllegalArgumentException - If the supplied string is not a valid xsd:duration value.
        java.lang.UnsupportedOperationException - If implementation cannot support requested values. The XML Schema specification states that values can be of an arbitrary size. Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values. An UnsupportedOperationException will be thrown with a message indicating implementation limits if implementation capacities are exceeded.
      • trimPlusSign

        private static java.lang.String trimPlusSign​(java.lang.String s)
        Removes the first character from the supplied string if this is a plus sign ('+'). Number strings with leading plus signs cannot be parsed by methods such as Integer.parseInt(String).
      • qnameToURI

        public static IRI qnameToURI​(javax.xml.namespace.QName qname)
        Maps a datatype QName from the javax.xml.namespace package to an XML Schema 1.0 URI for the corresponding datatype. This method recognizes the XML Schema qname mentioned in DatatypeConstants.

        Note that Java 8 / 11 do not have constants for XML Schema 1.1 datatypes like xsd:dateTimeStamp.

        Parameters:
        qname - One of the XML Schema qnames from DatatypeConstants.
        Returns:
        A URI for the specified datatype.
        Throws:
        java.lang.IllegalArgumentException - If the supplied qname was not recognized by this method.
        See Also:
        DatatypeConstants
      • qnameToCoreDatatype

        public static CoreDatatype.XSD qnameToCoreDatatype​(javax.xml.namespace.QName qname)
      • toString

        public static java.lang.String toString​(java.lang.Number value)
      • isNotDigit

        private static boolean isNotDigit​(char c)
        Checks whether the supplied character is a digit.