Package net.shibboleth.shared.xml
Class DOMTypeSupport
java.lang.Object
net.shibboleth.shared.xml.DOMTypeSupport
Set of helper methods for working with DOM data types.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final CalendarBaseline for duration calculations (comes from XML Schema standard).private static final DatatypeFactoryJAXP DatatypeFactory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdurationToString(Duration duration) Converts aDurationto a lexical duration, as defined by XML Schema 1.0.static DatatypeFactoryGets a static instance of a JAXP DatatypeFactory.static QNameGets the XSI type for a given element if it has one.static booleanChecks if the given element has an xsi:type defined for it.static StringinstantToString(Instant dateTime) Converts a numerical date/time, given as anInstant, to a lexical dateTime defined by XML Schema 1.0.static DurationstringToDuration(String duration) Converts a lexical duration, as defined by XML Schema 1.0, into aDuration.static InstantstringToInstant(String dateTime) Converts a lexical dateTime, as defined by XML Schema 1.0, into anInstant.
-
Field Details
-
DATA_TYPE_FACTORY
JAXP DatatypeFactory. -
BASELINE
Baseline for duration calculations (comes from XML Schema standard).
-
-
Constructor Details
-
DOMTypeSupport
private DOMTypeSupport()Constructor.
-
-
Method Details
-
stringToInstant
Converts a lexical dateTime, as defined by XML Schema 1.0, into anInstant.- Parameters:
dateTime- lexical date/time, may not be null- Returns:
- the date/time expressed as an
Instant
-
stringToDuration
Converts a lexical duration, as defined by XML Schema 1.0, into aDuration.- Parameters:
duration- lexical duration representation- Returns:
- duration in Java form
-
getDataTypeFactory
Gets a static instance of a JAXP DatatypeFactory.- Returns:
- the factory or null if the factory could not be created
-
getXSIType
Gets the XSI type for a given element if it has one.- Parameters:
e- the element- Returns:
- the type or null
-
hasXSIType
Checks if the given element has an xsi:type defined for it.- Parameters:
e- the DOM element- Returns:
- true if there is a type, false if not
-
instantToString
Converts a numerical date/time, given as anInstant, to a lexical dateTime defined by XML Schema 1.0. Note that simply usinginstant.toString()is equivalent for many use cases, but the result will be different on a system with a higher-resolution clock, as the resulting string value may have sub-millisecond precision. This method always works to millisecond precision.- Parameters:
dateTime- the date time to be converted- Returns:
- the lexical representation of the date/time
-
durationToString
Converts aDurationto a lexical duration, as defined by XML Schema 1.0.- Parameters:
duration- the duration- Returns:
- the lexical representation
-