Class XMLUtils

java.lang.Object
com.highdeal.hci.XMLUtils

public class XMLUtils extends Object
This Java class provides a collection Java methods for XML utilities.
  • Constructor Details

    • XMLUtils

      public XMLUtils()
  • Method Details

    • formatDate

      public static String formatDate(Date date)
      Formats a date in ISO 8601 date format.
      Parameters:
      date - The date to format
      Returns:
      The ISO 8601 representation of the date
    • formatDateTime

      public static String formatDateTime(Date date)
      Formats a date and a time in ISO 8601 date time format.
      Parameters:
      date - The date to format
      Returns:
      The date time in ISO 8601 format or null if the date parameter is null
    • escapeEntities

      public static String escapeEntities(String s)
      Escapes characters <, >, ', " and &, replacing them by &lt;, &gt;, &apos;, &quot;, and &amp;.
      Parameters:
      s - The string to escape
      Returns:
      The string with escaped entities
    • parseDate

      public static Date parseDate(String date)
      Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.
      Parameters:
      date - The string to parse
      Returns:
      The date
    • parseAndValidateDate

      public static Date parseAndValidateDate(String date, boolean onlyISO8601) throws IllegalArgumentException, NullPointerException, RuntimeException
      Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.
      Parameters:
      date - The string to parse
      onlyISO8601 - true if the parsing must accept only the ISO 8601 format
      Returns:
      The date
      Throws:
      IllegalArgumentException - when the argument does not validate the ISO 8601
      NullPointerException - when the argument is null
      RuntimeException - can be thrown by the Java API
    • parseAndValidateDate

      public static Date parseAndValidateDate(String date) throws IllegalArgumentException, NullPointerException, RuntimeException
      Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.
      Parameters:
      date - The string to parse
      Returns:
      The date
      Throws:
      IllegalArgumentException - when the argument does not validate the ISO 8601
      NullPointerException - when the argument is null
      RuntimeException - can be thrown by the Java API
    • toString

      public static final String toString(String tagName, IXMLMarshallable model)
      Returns the XML representation of the specified model as a string with the specified root element name.
      Parameters:
      tagName - the name of the root element
      model - the model to marshal
      Returns:
      a string containing the XML representation of the specified model
    • toString

      public static final String toString(XMLMarshallable model)
      Returns the XML representation of the specified model as a string.
      Parameters:
      model - the model to marshal
      Returns:
      a string containing the XML representation of the specified model
    • toString

      public static final String toString(XMLMarshallable model, int indentLevel)
      Returns the XML representation of the specified model as a string with the specified indentation level.
      Parameters:
      model - the model to marshal
      indentLevel - the indentation level
      Returns:
      a string containing the XML representation of the specified model
    • toXMLNode

      public static final XMLNode toXMLNode(XMLMarshallable model)