|
|
|
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.torweg.pulse.util.xml.XMLConverter
public final class XMLConverter
a utility for different XML conversion scenarios.
| Method Summary | |
|---|---|
static org.jdom.Element |
cleanHTML(java.io.Reader input)
cleans up faulty XHTML and returns a complete Document allowing unknown elements. |
static org.jdom.Element |
cleanHTML(java.io.Reader input,
boolean ignoreUnknownElements)
leans up faulty XHTML and returns a complete Document. |
static org.jdom.Element |
cleanHTML(java.lang.String input)
cleans up faulty XHTML and returns a complete Document allowing unknown elements. |
static org.jdom.Element |
cleanHTML(java.lang.String input,
boolean ignoreUnknownElements)
cleans up faulty XHTML and returns a complete Document allowing unknown elements. |
static java.util.Date |
fromDateTime(java.lang.String dt)
converts an RFC 3339 compliant date-time string to a Date. |
static org.jdom.Document |
getCleanedXHTML(java.io.InputStream xhtmlInput)
returns a cleaned Document for the given XHTML input. |
static org.jdom.Document |
getCleanedXHTML(java.io.Reader xhtmlInput)
returns a cleaned Document for the given XHTML input. |
static org.jdom.Document |
getCleanedXHTML(java.lang.String xhtmlInput)
returns a cleaned Document for the given XHTML input. |
static java.lang.String |
getCompactString(org.jdom.Document d,
boolean omitDecl)
returns a compact XML string for the given Document. |
static java.lang.String |
getCompactString(org.jdom.Element e,
boolean omitDecl)
returns a compact XML string for the given Element. |
static org.jdom.Document |
getFilteredXML(org.jdom.Document xml, XSLHandle filter)
uses the given XSLHandle to filter XML input. |
static org.jdom.Document |
getFilteredXML(org.jdom.Element xml, XSLHandle filter)
uses the given XSLHandle to filter XML input. |
static org.jdom.Document |
getFilteredXML(java.lang.String xml, XSLHandle filter)
uses the given XSLHandle to filter XML input. |
static java.lang.String |
getFormattedXHTML(java.lang.String xhtmlInput)
returns a formatted version of the given XHTML input. |
static java.lang.String |
getHTMLText(org.jdom.Document html)
extracts the textual content of a Document representing HTML
code. |
static java.lang.String |
getHTMLText(org.jdom.Element html)
extracts the textual content of an Element representing HTML
code. |
static java.lang.String |
getPrettyString(org.jdom.Document d,
boolean omitDecl)
returns a pretty indented, human readable XML string for the given Document. |
static java.lang.String |
getPrettyString(org.jdom.Element e,
boolean omitDecl)
returns a pretty indented, human readable for the given Element. |
static java.lang.String |
getRawString(org.jdom.Document d,
boolean omitDecl)
returns a pretty indented, human readable XML string for the given Document. |
static java.lang.String |
getRawString(org.jdom.Element e,
boolean omitDecl)
returns a raw XML string for the given Element. |
static org.w3c.dom.Document |
getW3CDocument(org.jdom.Document d)
converts the given JDOM document to a W3C document. |
static org.w3c.dom.Document |
getW3CDocument(org.jdom.Element e)
converts the given JDOM element to a W3C document. |
static java.lang.String |
marshal(java.lang.Object o)
utility method to do marshaling of a JAXB object. |
static org.jdom.Document |
resolveRelativeLinks(org.jdom.Document html,
java.net.URI baseURI)
resolves all href and src attributes to the given base
URI. |
static java.lang.String |
toDateTime(java.util.Date d)
converts the given Date to a RFC 3339 compliant date-time string. |
static java.lang.String |
toDateTime(long ts)
converts the given time-stamp to a RFC 3339 compliant date-time string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static org.jdom.Element cleanHTML(java.io.Reader input)
throws org.jdom.JDOMException,
java.io.IOException
input - a reader for reading the XHTML
Document within a root node
<html/>.
java.io.IOException - on i/o errors
org.jdom.JDOMException - if the parsing of the HTML fails
public static org.jdom.Element cleanHTML(java.io.Reader input,
boolean ignoreUnknownElements)
throws org.jdom.JDOMException,
java.io.IOException
input - a reader for reading the XHTMLignoreUnknownElements - flag, indicating whether to ignore unknown elements
Document within a root node
<html/>.
java.io.IOException - on i/o errors
org.jdom.JDOMException - if the parsing of the HTML fails
public static org.jdom.Element cleanHTML(java.lang.String input)
throws org.jdom.JDOMException,
java.io.IOException
input - a String containing the XHTML
Document within a root node
<html/>.
java.io.IOException - on i/o errors
org.jdom.JDOMException - if the parsing of the HTML fails
public static org.jdom.Element cleanHTML(java.lang.String input,
boolean ignoreUnknownElements)
throws org.jdom.JDOMException,
java.io.IOException
input - a String containing the XHTMLignoreUnknownElements - flag, indicating whether to ignore unknown elements
Document within a root node
<html/>.
java.io.IOException - on i/o errors
org.jdom.JDOMException - if the parsing of the HTML fails
public static java.lang.String getCompactString(org.jdom.Element e,
boolean omitDecl)
Element.
e - the elementomitDecl - true, if the XML declaration shall be omitted
public static java.lang.String getCompactString(org.jdom.Document d,
boolean omitDecl)
Document.
d - the documentomitDecl - true, if the XML declaration shall be omitted
public static java.lang.String getPrettyString(org.jdom.Element e,
boolean omitDecl)
Element.
e - the elementomitDecl - true, if the XML declaration shall be omitted
public static java.lang.String getPrettyString(org.jdom.Document d,
boolean omitDecl)
Document.
d - the documentomitDecl - true, if the XML declaration shall be omitted
public static java.lang.String getRawString(org.jdom.Element e,
boolean omitDecl)
Element.
e - the elementomitDecl - true, if the XML declaration shall be omitted
public static java.lang.String getRawString(org.jdom.Document d,
boolean omitDecl)
Document.
d - the documentomitDecl - true, if the XML declaration shall be omitted
public static org.jdom.Document getCleanedXHTML(java.lang.String xhtmlInput)
Document for the given XHTML input.
Underneath tagsoup is used to auto-correct the input.
xhtmlInput - the XHTML to be converted to a Document
Document within a root node
<body/>.
IllegalXHTMLException - on errors cleaning the XHTMLpublic static org.jdom.Document getCleanedXHTML(java.io.Reader xhtmlInput)
Document for the given XHTML input.
Underneath tagsoup is used to auto-correct the input.
xhtmlInput - the XHTML to be converted to a Document
Document within a root node
<body/>.
IllegalXHTMLException - on errors cleaning the XHTMLpublic static org.jdom.Document getCleanedXHTML(java.io.InputStream xhtmlInput)
Document for the given XHTML input.
Underneath tagsoup is used to auto-correct the input.
xhtmlInput - the XHTML to be converted to a Document
Document within a root node
<body/>.
IllegalXHTMLException - on errors cleaning the XHTML
public static org.jdom.Document resolveRelativeLinks(org.jdom.Document html,
java.net.URI baseURI)
href and src attributes to the given base
URI.
html - the HTML to be processedbaseURI - the base URI for resolving
public static java.lang.String getFormattedXHTML(java.lang.String xhtmlInput)
xhtmlInput - the XHTML to be formatted
IllegalXHTMLException - on errors cleaning the XHTMLpublic static org.jdom.Document getFilteredXML(org.jdom.Document xml, XSLHandle filter)
XSLHandle to filter XML input.
The given XSL in the XSLHandle can be used to check user input
for illegal or unwanted code and remove it automatically by transforming
the input with the given XSL.
xml - the xml inputfilter - the xsl filter
public static org.jdom.Document getFilteredXML(org.jdom.Element xml, XSLHandle filter)
XSLHandle to filter XML input.
The given XSL in the XSLHandle can be used to check user input
for illegal or unwanted code and remove it automatically by transforming
the input with the given XSL.
xml - the xml inputfilter - the xsl filter
public static org.jdom.Document getFilteredXML(java.lang.String xml, XSLHandle filter)
XSLHandle to filter XML input.
The given XSL in the XSLHandle can be used to check user input
for illegal or unwanted code and remove it automatically by transforming
the input with the given XSL.
xml - the xml inputfilter - the xsl filter
public static java.lang.String getHTMLText(org.jdom.Element html)
Element representing HTML
code.
html - the HTML
public static java.lang.String getHTMLText(org.jdom.Document html)
Document representing HTML
code.
html - the HTML
public static org.w3c.dom.Document getW3CDocument(org.jdom.Document d)
d - the JDOM document
public static org.w3c.dom.Document getW3CDocument(org.jdom.Element e)
e - the JDOM element
public static java.lang.String marshal(java.lang.Object o)
throws javax.xml.bind.JAXBException
o - the object to be marshaled
javax.xml.bind.JAXBException - on errorspublic static java.lang.String toDateTime(java.util.Date d)
Date to a RFC 3339 compliant date-time string.
d - the date to be converted
public static java.lang.String toDateTime(long ts)
ts - the time-stamp
public static java.util.Date fromDateTime(java.lang.String dt)
Date.
dt - the RFC 3339 compliant date-time string
Date or null, if the date-time could
not be parsed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||