Package net.shibboleth.shared.xml

# Class DOMTypeSupport

java.lang.Object
net.shibboleth.shared.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 final Calendar`
`BASELINE`
Baseline for duration calculations (comes from XML Schema standard).
`private static final DatatypeFactory`
`DATA_TYPE_FACTORY`
JAXP DatatypeFactory.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`DOMTypeSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static String`
`durationToString(Duration duration)`
Converts a `Duration` to a lexical duration, as defined by XML Schema 1.0.
`static DatatypeFactory`
`getDataTypeFactory()`
Gets a static instance of a JAXP DatatypeFactory.
`static QName`
`getXSIType(Element e)`
Gets the XSI type for a given element if it has one.
`static boolean`
`hasXSIType(Element e)`
Checks if the given element has an xsi:type defined for it.
`static String`
`instantToString(Instant dateTime)`
Converts a numerical date/time, given as an `Instant`, to a lexical dateTime defined by XML Schema 1.0.
`static Duration`
`stringToDuration(String duration)`
Converts a lexical duration, as defined by XML Schema 1.0, into a `Duration`.
`static Instant`
`stringToInstant(String dateTime)`
Converts a lexical dateTime, as defined by XML Schema 1.0, into an `Instant`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DATA_TYPE_FACTORY

@Nonnull private static final DatatypeFactory DATA_TYPE_FACTORY
JAXP DatatypeFactory.

### BASELINE

@Nonnull private static final Calendar BASELINE
Baseline for duration calculations (comes from XML Schema standard).

## Constructor Details

### DOMTypeSupport

private DOMTypeSupport()
Constructor.

## Method Details

### stringToInstant

public static Instant stringToInstant(@Nonnull String dateTime)
Converts a lexical dateTime, as defined by XML Schema 1.0, into an `Instant`.

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 a `Duration`.

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(@Nonnull 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(@Nonnull 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 an `Instant`, to a lexical dateTime defined by XML Schema 1.0. Note that simply using `instant.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

@Nonnull public static String durationToString(@Nonnull Duration duration)
Converts a `Duration` to a lexical duration, as defined by XML Schema 1.0.

Parameters:
  `duration` - the duration
Returns:
  the lexical representation