public class XMLDatatypeUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
NaN |
static String |
NEGATIVE_INFINITY |
static String |
POSITIVE_INFINITY |
Constructor and Description |
---|
XMLDatatypeUtil() |
Modifier and Type | Method and 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 |
compare(String value1,
String value2,
IRI datatype) |
static int |
compareBytes(String int1,
String int2) |
static int |
compareCanonicalDecimals(String dec1,
String dec2)
Compares two canonical decimals to eachother.
|
static int |
compareCanonicalDoubles(String double1,
String double2)
Compares two canonical doubles to eachother.
|
static int |
compareCanonicalFloats(String float1,
String float2)
Compares two canonical floats to eachother.
|
static int |
compareCanonicalFPNumbers(String float1,
String float2)
Compares two canonical floating point numbers to eachother.
|
static int |
compareCanonicalIntegers(String int1,
String int2)
Compares two canonical integers to eachother.
|
static int |
compareDateTime(String value1,
String value2)
Compares two dateTime objects.
|
static int |
compareDecimals(String dec1,
String dec2)
Compares two decimals to eachother.
|
static int |
compareDoubles(String double1,
String double2)
Compares two doubles to eachother.
|
static int |
compareFloats(String float1,
String float2)
Compares two floats to eachother.
|
static int |
compareFPNumbers(String fp1,
String fp2)
Compares two floating point numbers to eachother.
|
static int |
compareIntegers(String int1,
String int2)
Compares two integers to eachother.
|
static int |
compareInts(String int1,
String int2) |
static int |
compareLongs(String int1,
String int2) |
static int |
compareNegativeIntegers(String int1,
String int2) |
static int |
compareNonNegativeIntegers(String int1,
String int2) |
static int |
compareNonPositiveIntegers(String int1,
String int2) |
static int |
comparePositiveIntegers(String int1,
String int2) |
static int |
compareShorts(String int1,
String int2) |
static int |
compareUnsignedBytes(String int1,
String int2) |
static int |
compareUnsignedInts(String int1,
String int2) |
static int |
compareUnsignedLongs(String int1,
String int2) |
static int |
compareUnsignedShorts(String int1,
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.
|
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.
|
static boolean |
isNumericDatatype(IRI datatype)
Checks whether the supplied datatype is a numeric datatype, i.e.
|
static boolean |
isOrderedDatatype(IRI datatype)
Checks whether the supplied datatype is ordered.
|
static boolean |
isPrimitiveDatatype(IRI datatype)
Checks whether the supplied datatype is a primitive XML Schema datatype.
|
static boolean |
isValidAnyURI(String value)
Determines if the supplied value is an Internationalized Resource Identifier Reference (IRI).
|
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(String value,
IRI datatype)
Verifies if the supplied lexical value is valid for the given datatype.
|
static boolean |
isValidYearMonthDuration(String value) |
static String |
normalize(String value,
IRI datatype)
Normalizes the supplied value according to the normalization rules for the supplied datatype.
|
static String |
normalizeBoolean(String value)
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 |
normalizeFPNumber(String value)
Normalizes a floating point number 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 boolean |
parseBoolean(String s)
Parses the supplied xsd:boolean string and returns its value.
|
static byte |
parseByte(String s)
Parses the supplied xsd:byte string and returns its value.
|
static XMLGregorianCalendar |
parseCalendar(String s)
Parses the supplied calendar value string and returns its value.
|
static BigDecimal |
parseDecimal(String s)
Parses the supplied decimal/floating point string and returns its value.
|
static double |
parseDouble(String s)
Parses the supplied xsd:double string and returns its value.
|
static Duration |
parseDuration(String s)
Parses the supplied xsd:duration value string and returns its value.
|
static float |
parseFloat(String s)
Parses the supplied xsd:float string and returns its value.
|
static int |
parseInt(String s)
Parses the supplied xsd:int strings and returns its value.
|
static BigInteger |
parseInteger(String s)
Parses the supplied xsd:integer string and returns its value.
|
static long |
parseLong(String s)
Parses the supplied xsd:long string and returns its value.
|
static short |
parseShort(String s)
Parses the supplied xsd:short string and returns its value.
|
static IRI |
qnameToURI(QName qname)
Maps a datatype QName from the javax.xml.namespace package to an XML Schema URI for the corresponding datatype.
|
static String |
toString(Number value) |
public static final String POSITIVE_INFINITY
public static final String NEGATIVE_INFINITY
public static final String NaN
public static boolean isPrimitiveDatatype(IRI datatype)
public static boolean isDerivedDatatype(IRI datatype)
public static boolean isBuiltInDatatype(IRI datatype)
public static boolean isNumericDatatype(IRI datatype)
public static boolean isDecimalDatatype(IRI datatype)
public static boolean isIntegerDatatype(IRI datatype)
public static boolean isFloatingPointDatatype(IRI datatype)
public static boolean isCalendarDatatype(IRI datatype)
XMLGregorianCalendar
public static boolean isDurationDatatype(IRI datatype)
Duration
public static boolean isOrderedDatatype(IRI datatype)
public static boolean isValidValue(String value, IRI datatype)
value
- a lexical valuedatatype
- an XML Schema datatatype.public static boolean isValidDecimal(String value)
public static boolean isValidInteger(String value)
public static boolean isValidNegativeInteger(String value)
public static boolean isValidNonPositiveInteger(String value)
public static boolean isValidNonNegativeInteger(String value)
public static boolean isValidPositiveInteger(String value)
public static boolean isValidLong(String value)
public static boolean isValidInt(String value)
public static boolean isValidShort(String value)
public static boolean isValidByte(String value)
public static boolean isValidUnsignedLong(String value)
public static boolean isValidUnsignedInt(String value)
public static boolean isValidUnsignedShort(String value)
public static boolean isValidUnsignedByte(String value)
public static boolean isValidFloat(String value)
public static boolean isValidDouble(String value)
public static boolean isValidBoolean(String value)
public static boolean isValidDuration(String value)
public static boolean isValidDayTimeDuration(String value)
public static boolean isValidYearMonthDuration(String value)
public static boolean isValidDateTime(String value)
public static boolean isValidDate(String value)
value
- public static boolean isValidTime(String value)
value
- public static boolean isValidGDay(String value)
value
- public static boolean isValidGMonth(String value)
value
- public static boolean isValidGMonthDay(String value)
value
- public static boolean isValidGYear(String value)
value
- public static boolean isValidGYearMonth(String value)
value
- public static boolean isValidQName(String value)
value
- public static boolean isValidAnyURI(String value)
value
- public static String normalize(String value, IRI datatype)
value
- The value to normalize.datatype
- The value's datatype.IllegalArgumentException
- If the supplied value is illegal considering the supplied datatype.public static String normalizeBoolean(String value)
value
- The boolean value to normalize.IllegalArgumentException
- If the supplied value is not a legal boolean.public static String normalizeDecimal(String decimal)
decimal
- The decimal to normalize.IllegalArgumentException
- If one of the supplied strings is not a legal decimal.public static String normalizeInteger(String value)
value
- The value to normalize.IllegalArgumentException
- If the supplied value is not a legal integer.public static String normalizeNegativeInteger(String value)
public static String normalizeNonPositiveInteger(String value)
public static String normalizeNonNegativeInteger(String value)
public static String normalizePositiveInteger(String value)
public static String normalizeUnsignedLong(String value)
public static String normalizeUnsignedInt(String value)
public static String normalizeUnsignedShort(String value)
public static String normalizeUnsignedByte(String value)
public static String normalizeFloat(String value)
value
- The value to normalize.IllegalArgumentException
- If the supplied value is not a legal float.public static String normalizeDouble(String value)
value
- The value to normalize.IllegalArgumentException
- If the supplied value is not a legal double.public static String normalizeFPNumber(String value)
value
- The value to normalize.IllegalArgumentException
- If the supplied value is not a legal floating point number.public static String normalizeDateTime(String value)
value
- The value to normalize.IllegalArgumentException
- If the supplied value is not a legal xsd:dateTime value.public static String collapseWhiteSpace(String s)
public static int compareDecimals(String dec1, String dec2)
IllegalArgumentException
- If one of the supplied strings is not a legal decimal.public static int compareCanonicalDecimals(String dec1, String dec2)
IllegalArgumentException
- If one of the supplied strings is not a legal decimal.public static int compareIntegers(String int1, String int2)
IllegalArgumentException
- If one of the supplied strings is not a legal integer.public static int compareCanonicalIntegers(String int1, String int2)
IllegalArgumentException
- If one of the supplied strings is not a legal integer.public static int compareFloats(String float1, String float2)
IllegalArgumentException
- If one of the supplied strings is not a legal float or if NaN is
compared to a float other than NaN.public static int compareCanonicalFloats(String float1, String float2)
IllegalArgumentException
- If one of the supplied strings is not a legal float or if NaN is
compared to a float other than NaN.public static int compareDoubles(String double1, String double2)
IllegalArgumentException
- If one of the supplied strings is not a legal double or if NaN is
compared to a double other than NaN.public static int compareCanonicalDoubles(String double1, String double2)
IllegalArgumentException
- If one of the supplied strings is not a legal double or if NaN is
compared to a double other than NaN.public static int compareFPNumbers(String fp1, String fp2)
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.public static int compareCanonicalFPNumbers(String float1, String float2)
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.public static int compareDateTime(String value1, String value2)
value1
- An xsd:dateTime value.value2
- An xsd:dateTime value.public static boolean parseBoolean(String s)
s
- A string representation of an xsd:boolean value.NumberFormatException
- If the supplied string is not a valid xsd:boolean value.public static byte parseByte(String s)
s
- A string representation of an xsd:byte value.NumberFormatException
- If the supplied string is not a valid xsd:byte value.public static short parseShort(String s)
s
- A string representation of an xsd:short value.NumberFormatException
- If the supplied string is not a valid xsd:short value.public static int parseInt(String s)
s
- A string representation of an xsd:int value.NumberFormatException
- If the supplied string is not a valid xsd:int value.public static long parseLong(String s)
s
- A string representation of an xsd:long value.NumberFormatException
- If the supplied string is not a valid xsd:long value.public static float parseFloat(String s)
s
- A string representation of an xsd:float value.NumberFormatException
- If the supplied string is not a valid xsd:float value.public static double parseDouble(String s)
s
- A string representation of an xsd:double value.NumberFormatException
- If the supplied string is not a valid xsd:double value.public static BigInteger parseInteger(String s)
s
- A string representation of an xsd:integer value.NumberFormatException
- If the supplied string is not a valid xsd:integer value.public static BigDecimal parseDecimal(String s)
s
- A string representation of an xsd:decimal or xsd:double value.NumberFormatException
- If the supplied string is not a valid xsd:decimal or xsd:double value.public static XMLGregorianCalendar parseCalendar(String s)
s
- A string representation of an xsd:dateTime, xsd:time, xsd:date, xsd:gYearMonth, xsd:gMonthDay,
xsd:gYear, xsd:gMonth or xsd:gDay value.IllegalArgumentException
- If the supplied string is not a valid calendar value.public static Duration parseDuration(String s)
s
- A string representation of an xsd:duration value.Duration
value represented by the supplied string argument.IllegalArgumentException
- If the supplied string is not a valid xsd:duration value.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.public static IRI qnameToURI(QName qname)
DatatypeConstants
.qname
- One of the XML Schema qnames from DatatypeConstants
.IllegalArgumentException
- If the supplied qname was not recognized by this method.DatatypeConstants
Copyright © 2015-2019 Eclipse Foundation. All Rights Reserved.