Package com.highdeal.hci
Class XMLUtils
java.lang.Object
com.highdeal.hci.XMLUtils
This
Java class provides a collection Java methods for XML utilities.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEscapes characters <, >, ', " and &, replacing them by <, >, ', ", and &.static StringformatDate(Date date) Formats a date in ISO 8601 date format.static StringformatDateTime(Date date) Formats a date and a time in ISO 8601 date time format.static DateparseAndValidateDate(String date) Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.static DateparseAndValidateDate(String date, boolean onlyISO8601) Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.static DateParses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.static final StringtoString(XMLMarshallable model) Returns the XML representation of the specified model as a string.static final StringtoString(XMLMarshallable model, int indentLevel) Returns the XML representation of the specified model as a string with the specified indentation level.static final StringtoString(String tagName, IXMLMarshallable model) Returns the XML representation of the specified model as a string with the specified root element name.static final XMLNodetoXMLNode(XMLMarshallable model)
-
Constructor Details
-
XMLUtils
public XMLUtils()
-
-
Method Details
-
formatDate
Formats a date in ISO 8601 date format.- Parameters:
date- The date to format- Returns:
- The ISO 8601 representation of the date
-
formatDateTime
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
Escapes characters <, >, ', " and &, replacing them by <, >, ', ", and &.- Parameters:
s- The string to escape- Returns:
- The string with escaped entities
-
parseDate
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 parseonlyISO8601- true if the parsing must accept only the ISO 8601 format- Returns:
- The date
- Throws:
IllegalArgumentException- when the argument does not validate the ISO 8601NullPointerException- when the argument isnullRuntimeException- 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 8601NullPointerException- when the argument isnullRuntimeException- can be thrown by the Java API
-
toString
Returns the XML representation of the specified model as a string with the specified root element name.- Parameters:
tagName- the name of the root elementmodel- the model to marshal- Returns:
- a string containing the XML representation of the specified model
-
toString
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
Returns the XML representation of the specified model as a string with the specified indentation level.- Parameters:
model- the model to marshalindentLevel- the indentation level- Returns:
- a string containing the XML representation of the specified model
-
toXMLNode
-