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 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