public class XMLUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static char |
SPACE_CHAR
A space char for append
|
static String |
XML_PROLOG
the usual preamble
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendAttribute(Appendable appendable,
CharSequence attrName,
AttributeValue attrValue)
Append a space, then a new element to the appendable element, the name of the element is
attrName and the value is attrValue.
|
void |
appendAttribute(Appendable appendable,
CharSequence attrName,
boolean attrValue)
Append a new element to the appendable element, the name of the element is
attrName and the value is the boolean attrValue.
|
void |
appendAttribute(Appendable appendable,
CharSequence attrName,
CharSequence attrValue)
Append a space, then a new element to the appendable element, the name of the element is
attrName and the value is attrValue.
|
void |
appendAttribute(Appendable appendable,
CharSequence attrName,
int attrValue)
Append a new element to the appendable element, the name of the element is
attrName and the value is attrValue.
|
void |
appendAttribute(Appendable appendable,
CharSequence attrName,
List<?> attrs,
String sep)
Append a space, then a new element to the appendable element, the name of the element is
attrName and the value is a list.
|
void |
appendEAttribute(Appendable appendable,
CharSequence attrName,
String attrRawValue)
Escape then append.
|
void |
appendTag(Appendable appendable,
CharSequence tagName,
String content)
Append a content inside a tag
|
static XMLUtil |
create() |
String |
escapeXMLAttribute(String s)
Escape an XML attribute
|
String |
escapeXMLContent(String s)
Escape an XML content
|
String |
formatNegTimeInterval(long years,
long months,
long days,
long hours,
long minutes,
double seconds)
XML Schema Part 2, 3.2.6 duration
"'P'yyyy'Y'MM'M'dd'DT'HH'H'mm'M'ss.SSS'S'"
All parameters must be positive
|
String |
formatTimeInterval(long milliseconds)
XML Schema Part 2, 3.2.6 duration
"'P'yyyy'Y'MM'M'dd'DT'HH'H'mm'M'ss.SSS'S'"
|
String |
formatTimeInterval(long years,
long months,
long days,
long hours,
long minutes,
double seconds)
XML Schema Part 2, 3.2.6 duration
"'P'yyyy'Y'MM'M'dd'DT'HH'H'mm'M'ss.SSS'S'"
All parameters must be positive
|
public static final String XML_PROLOG
public static final char SPACE_CHAR
public static XMLUtil create()
public void appendEAttribute(Appendable appendable, CharSequence attrName, String attrRawValue) throws IOException
Append a space and new element to the appendable element, the name of the element is attrName and the value is attrRawValue. The will be escaped if necessary
appendable - The StringBuilder to which the new element should be added.attrName - The new element nameattrRawValue - The value of the elementIOException - If an I/O error occurspublic void appendAttribute(Appendable appendable, CharSequence attrName, boolean attrValue) throws IOException
appendable - The StringBuilder to which the new element should be added.attrName - The new element nameattrValue - The value of the elementIOException - If an I/O error occurspublic void appendAttribute(Appendable appendable, CharSequence attrName, int attrValue) throws IOException
appendable - The StringBuilder to which the new element should be added.attrName - The new element nameattrValue - The value of the elementIOException - If an I/O error occurspublic void appendAttribute(Appendable appendable, CharSequence attrName, CharSequence attrValue) throws IOException
appendable - where to writeattrName - the name of the attributeattrValue - escaped attributeIOException - If an I/O error occurspublic void appendAttribute(Appendable appendable, CharSequence attrName, AttributeValue attrValue) throws IOException
appendable - where to writeattrName - the name of the attributeattrValue - escaped attributeIOException - If an I/O error occurspublic void appendAttribute(Appendable appendable, CharSequence attrName, List<?> attrs, String sep) throws IOException
appendable - where to writeattrName - the name of the attributeattrs - list of attributessep - the separatorIOException - If an I/O error occurspublic void appendTag(Appendable appendable, CharSequence tagName, String content) throws IOException
appendable - the destinationtagName - the tag namecontent - the contentIOException - if an I/O error occurspublic String escapeXMLAttribute(String s)
s - the attributepublic String escapeXMLContent(String s)
s - the contentpublic String formatTimeInterval(long milliseconds)
milliseconds - the interval to format in millisecondspublic String formatTimeInterval(long years, long months, long days, long hours, long minutes, double seconds)
All parameters must be positive
years - number of yearsmonths - number of monthsdays - number of dayshours - number of hoursminutes - number of minutesseconds - number of secondspublic String formatNegTimeInterval(long years, long months, long days, long hours, long minutes, double seconds)
All parameters must be positive
years - number of yearsmonths - number of monthsdays - number of dayshours - number of hoursminutes - number of minutesseconds - number of secondsCopyright © 2016–2021. All rights reserved.