Package com.stardog.stark
Class XMLDatatypes
java.lang.Object
com.stardog.stark.XMLDatatypes
Utility for XML schema datatypes
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Arjohn Kampman, Michael Grove
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReplaces 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 intcompareCanonicalDecimals(String dec1, String dec2) Compares two canonical decimals to eachother.static intcompareCanonicalIntegers(String int1, String int2) Compares two canonical integers to eachother.static booleanisBuiltInDatatype(Datatype theDatatype) Return whether or not theDatatypeis a built-in XML schema type.static booleanisBuiltInDatatype(IRI theIRI) Return whether or not theIRIis a built-in XML schema type.static booleanisCalendarDatatype(Datatype theDatatype) Return whether or not theDatatypeis an XML datatype calendar typestatic booleanisDecimalDatatype(Datatype theDatatype) Return whether or not theDatatypeis `xsd:decimal` or derived from itstatic booleanisDurationDatatype(Datatype theDatatype) static booleanisFloatingPointDatatype(Datatype theDatatype) static booleanisIntegerDatatype(Datatype theDatatype) Return whether or not theDatatypeis `xsd:integer` or derived from itstatic booleanisNumericDatatype(Datatype theDatatype) Return whether or not theDatatypeis a numeric datatype such as `xsd:long` or `xsd:decimal`.static booleanisPrimitiveDatatype(Datatype theDatatype) Return whether or not theDatatypeis a primitive XML schema type.static booleanisValidBoolean(String value) static booleanisValidByte(String value) static booleanisValidDate(String value) Determines if the supplied value is a valid xsd:date string.static booleanisValidDateTime(String value) static booleanisValidDayTimeDuration(String value) static booleanisValidDecimal(String value) static booleanisValidDouble(String value) static booleanisValidDuration(String value) static booleanisValidFloat(String value) static booleanisValidGDay(String value) Determines if the supplied value is a valid xsd:gDay string.static booleanisValidGMonth(String value) Determines if the supplied value is a valid xsd:gMonth string.static booleanisValidGMonthDay(String value) Determines if the supplied value is a valid xsd:gMonthDay string.static booleanisValidGYear(String value) Determines if the supplied value is a valid xsd:gYear string.static booleanisValidGYearMonth(String value) Determines if the supplied value is a valid xsd:gYearMonth string.static booleanisValidInt(String value) static booleanisValidInteger(String value) static booleanisValidLong(String value) static booleanisValidNegativeInteger(String value) static booleanisValidNonNegativeInteger(String value) static booleanisValidNonPositiveInteger(String value) static booleanisValidPositiveInteger(String value) static booleanisValidQName(String value) Determines if the supplied value is a valid xsd:QName string.static booleanisValidShort(String value) static booleanisValidTime(String value) Determines if the supplied value is a valid xsd:time string.static booleanisValidUnsignedByte(String value) static booleanisValidUnsignedInt(String value) static booleanisValidUnsignedLong(String value) static booleanisValidUnsignedShort(String value) static booleanisValidValue(Literal theLiteral) Verifies if the supplied lexical value is valid for the given literal.static booleanisValidValue(String theValue, Datatype theDatatype) Verifies if the supplied lexical value is valid for the given datatype.static StringNormalizes the supplied value according to the normalization rules for the supplied datatype.static StringnormalizeBoolean(String theValue) Normalizes a boolean value to its canonical representation.static StringnormalizeByte(String value) Normalizes an xsd:byte.static StringnormalizeDateTime(String value) Normalizes an xsd:dateTime.static StringnormalizeDecimal(String decimal) Normalizes a decimal to its canonical representation.static StringnormalizeDouble(String value) Normalizes a double to its canonical representation.static StringnormalizeFloat(String value) Normalizes a float to its canonical representation.static StringnormalizeInt(String value) Normalizes an xsd:int.static StringnormalizeInteger(String value) Normalizes an integer to its canonical representation.static StringnormalizeLong(String value) Normalizes an xsd:long.static StringnormalizeNegativeInteger(String value) Normalizes an xsd:negativeInteger.static StringNormalizes an xsd:nonNegativeInteger.static StringNormalizes an xsd:nonPositiveInteger.static StringnormalizePositiveInteger(String value) Normalizes an xsd:positiveInteger.static StringnormalizeShort(String value) Normalizes an xsd:short.static StringnormalizeUnsignedByte(String value) Normalizes an xsd:unsignedByte.static StringnormalizeUnsignedInt(String value) Normalizes an xsd:unsignedInt.static StringnormalizeUnsignedLong(String value) Normalizes an xsd:unsignedLong.static StringnormalizeUnsignedShort(String value) Normalizes an xsd:unsignedShort.static XMLGregorianCalendarParses the supplied calendar value string and returns its value.
-
Field Details
-
PRIMITIVES
-
DERIVED
-
INTEGERS
-
FP
-
CALENDAR
-
DURATIONS
-
GYEARMONTH_REGEX
- See Also:
-
GYEAR
- See Also:
-
GMONTHDAY
- See Also:
-
GMONTH
- See Also:
-
GDAY
- See Also:
-
TIME
- See Also:
-
DATE
- See Also:
-
DAY_TIME_DURATION
- See Also:
-
DURATION
- See Also:
-
-
Method Details
-
isPrimitiveDatatype
Return whether or not theDatatypeis a primitive XML schema type.- Parameters:
theDatatype- the datatype- Returns:
- `true` if a built-in type, `false` otherwise
-
isCalendarDatatype
Return whether or not theDatatypeis an XML datatype calendar type- Parameters:
theDatatype- the datatype- Returns:
- `true` if a calendar type, `false` otherwise
-
isBuiltInDatatype
Return whether or not theIRIis a built-in XML schema type.- Parameters:
theIRI- the datatype theIRI- Returns:
- `true` if a built-in type, `false` otherwise
-
isBuiltInDatatype
Return whether or not theDatatypeis a built-in XML schema type.- Parameters:
theDatatype- the datatype- Returns:
- `true` if a built-in type, `false` otherwise
-
isNumericDatatype
Return whether or not theDatatypeis a numeric datatype such as `xsd:long` or `xsd:decimal`.- Parameters:
theDatatype- the datatype- Returns:
- `true` if a numeric type, `false` otherwise
-
isDecimalDatatype
Return whether or not theDatatypeis `xsd:decimal` or derived from it- Parameters:
theDatatype- the datatype- Returns:
- `true` if a decimal type, `false` otherwise
-
isDurationDatatype
-
isIntegerDatatype
Return whether or not theDatatypeis `xsd:integer` or derived from it- Parameters:
theDatatype- the datatype- Returns:
- `true` if a integer type, `false` otherwise
-
isFloatingPointDatatype
-
isValidValue
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
Verifies if the supplied lexical value is valid for the given datatype.- Parameters:
theValue- a lexical valuetheDatatype- an XML Schema datatatype.- Returns:
- `true` if the supplied lexical value is valid, `false` otherwise.
-
isValidDecimal
-
isValidInteger
-
isValidNegativeInteger
-
isValidNonPositiveInteger
-
isValidNonNegativeInteger
-
isValidPositiveInteger
-
isValidLong
-
isValidInt
-
isValidShort
-
isValidByte
-
isValidUnsignedLong
-
isValidUnsignedInt
-
isValidUnsignedShort
-
isValidUnsignedByte
-
isValidFloat
-
isValidDouble
-
isValidBoolean
-
isValidDuration
-
isValidDayTimeDuration
-
isValidDateTime
-
isValidDate
Determines if the supplied value is a valid xsd:date string.- Parameters:
value- the date- Returns:
- `true` if valid, `false` otherwise
-
isValidTime
Determines if the supplied value is a valid xsd:time string.- Parameters:
value- the time- Returns:
- `true` if valid, `false` otherwise
-
isValidGDay
Determines if the supplied value is a valid xsd:gDay string.- Parameters:
value- the gday- Returns:
- `true` if valid, `false` otherwise
-
isValidGMonth
Determines if the supplied value is a valid xsd:gMonth string.- Parameters:
value- the gmonth- Returns:
- `true` if valid, `false` otherwise
-
isValidGMonthDay
Determines if the supplied value is a valid xsd:gMonthDay string.- Parameters:
value- the gmonthday- Returns:
- `true` if valid, `false` otherwise
-
isValidGYear
Determines if the supplied value is a valid xsd:gYear string.- Parameters:
value- the value- Returns:
- `true` if valid, `false` otherwise
-
isValidGYearMonth
Determines if the supplied value is a valid xsd:gYearMonth string.- Parameters:
value- the value- Returns:
- `true` if valid, `false` otherwise
-
isValidQName
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
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
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
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
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
Normalizes an xsd:negativeInteger. -
normalizeNonPositiveInteger
Normalizes an xsd:nonPositiveInteger. -
normalizeNonNegativeInteger
Normalizes an xsd:nonNegativeInteger. -
normalizePositiveInteger
Normalizes an xsd:positiveInteger. -
normalizeLong
Normalizes an xsd:long. -
normalizeInt
Normalizes an xsd:int. -
normalizeShort
Normalizes an xsd:short. -
normalizeByte
Normalizes an xsd:byte. -
normalizeUnsignedLong
Normalizes an xsd:unsignedLong. -
normalizeUnsignedInt
Normalizes an xsd:unsignedInt. -
normalizeUnsignedShort
Normalizes an xsd:unsignedShort. -
normalizeUnsignedByte
Normalizes an xsd:unsignedByte. -
normalizeFloat
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
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
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
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
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
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
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.
-