Class DOMTypeSupport
- java.lang.Object
-
- net.shibboleth.utilities.java.support.xml.DOMTypeSupport
-
public final class DOMTypeSupport extends Object
Set of helper methods for working with DOM data types.
-
-
Field Summary
Fields Modifier and Type Field Description private static CalendarbaselineBaseline for duration calculations (comes from XML Schema standard).private static DatatypeFactorydataTypeFactoryJAXP DatatypeFactory.
-
Constructor Summary
Constructors Modifier Constructor Description privateDOMTypeSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdurationToString(Duration duration)Converts aDurationto a lexical duration, as defined by XML Schema 1.0.static DatatypeFactorygetDataTypeFactory()Gets a static instance of a JAXP DatatypeFactory.static QNamegetXSIType(Element e)Gets the XSI type for a given element if it has one.static booleanhasXSIType(Element e)Checks 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 Detail
-
dataTypeFactory
private static DatatypeFactory dataTypeFactory
JAXP DatatypeFactory.
-
baseline
private static Calendar baseline
Baseline for duration calculations (comes from XML Schema standard).
-
-
Method Detail
-
stringToInstant
public static Instant stringToInstant(@Nonnull String dateTime)
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
public static Duration stringToDuration(@Nonnull String duration)
Converts a lexical duration, as defined by XML Schema 1.0, into aDuration.- Parameters:
duration- lexical duration representation- Returns:
- duration in Java form
-
getDataTypeFactory
public static DatatypeFactory getDataTypeFactory()
Gets a static instance of a JAXP DatatypeFactory.- Returns:
- the factory or null if the factory could not be created
-
getXSIType
@Nullable public static QName getXSIType(@Nullable Element e)
Gets the XSI type for a given element if it has one.- Parameters:
e- the element- Returns:
- the type or null
-
hasXSIType
public static boolean hasXSIType(@Nullable Element e)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
@Nonnull public static String instantToString(@Nonnull Instant dateTime)
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
-
-