|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.portal.common.util.XML
Utilities for dealing with XML.
Field Summary | |
static java.lang.String |
ATTRIB_CDATA_SECTION_ELEMENTS
. |
static java.lang.String |
ATTRIB_HREF
. |
static java.lang.String |
ATTRIB_INDENT
. |
static java.lang.String |
ATTRIB_METHOD
. |
static java.lang.String |
ATTRIB_OMIT_XML_DECLARATION
. |
private static javax.xml.parsers.DocumentBuilderFactory |
buildFactory
Document builder factory. |
private static java.util.Properties |
DEFAULT_FORMAT
Default output format which is : no xml declaration, no document type, indent. |
static boolean |
DEFAULT_NAMESPACE_AWARE
. |
static boolean |
DEFAULT_VALIDATION
. |
static java.lang.String |
DIRECTIVE_IMPORT
. |
static java.lang.String |
DIRECTIVE_INCLUDE
. |
static java.lang.String |
PARAM_NO
. |
static java.lang.String |
PARAM_YES
. |
private static javax.xml.transform.TransformerFactory |
transformerFactory
Transformer factory. |
static java.lang.String |
XML_LANG_NAMESPACE_URI
Namespace URI for XML lang. |
Constructor Summary | |
private |
XML()
prevent instantiation |
Method Summary | |
static java.lang.String |
asString(org.w3c.dom.Element element)
Perform trimming by default |
static java.lang.String |
asString(org.w3c.dom.Element element,
boolean trim)
Get the element's content as a string. |
private static java.util.Properties |
createFormat(boolean omitXMLDeclaration,
boolean standalone,
boolean indented,
java.lang.String encoding)
|
static java.util.List |
getChildren(org.w3c.dom.Element element,
java.lang.String name)
Return all the children of the given element having the specified name. |
static java.util.Iterator |
getChildrenIterator(org.w3c.dom.Element element,
java.lang.String name)
Return an iterator for all the children of the given element having the specified name. |
static javax.xml.parsers.DocumentBuilderFactory |
getDocumentBuilderFactory()
Return the builder factory. |
static org.w3c.dom.Element |
getUniqueChild(org.w3c.dom.Element element,
boolean strict)
Return the optional unique child of an element. |
static org.w3c.dom.Element |
getUniqueChild(org.w3c.dom.Element element,
java.lang.String name,
boolean strict)
Return an optional child of an element with the specified name. |
static org.w3c.dom.Document |
toDocument(java.lang.String text)
Parse a string into a document. |
static org.w3c.dom.Element |
toElement(java.lang.String text)
Parse a string into an element. |
static java.lang.String |
toString(org.w3c.dom.Document doc)
Serialize the document with the default format : - No XML declaration - Indented - Encoding is UTF-8 |
static java.lang.String |
toString(org.w3c.dom.Document doc,
boolean omitXMLDeclaration,
boolean standalone,
boolean indented,
java.lang.String encoding)
|
private static java.lang.String |
toString(org.w3c.dom.Document doc,
java.util.Properties format)
Converts an document to a String representation. |
static java.lang.String |
toString(org.w3c.dom.Element element)
|
private static java.lang.String |
toString(org.w3c.dom.Element element,
java.util.Properties properties)
Converts an element to a String representation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String XML_LANG_NAMESPACE_URI
private static final javax.xml.parsers.DocumentBuilderFactory buildFactory
private static final javax.xml.transform.TransformerFactory transformerFactory
private static java.util.Properties DEFAULT_FORMAT
public static final java.lang.String PARAM_YES
public static final java.lang.String PARAM_NO
public static final java.lang.String ATTRIB_OMIT_XML_DECLARATION
public static final java.lang.String ATTRIB_CDATA_SECTION_ELEMENTS
public static final java.lang.String ATTRIB_METHOD
public static final java.lang.String ATTRIB_INDENT
public static final java.lang.String ATTRIB_HREF
public static final java.lang.String DIRECTIVE_IMPORT
public static final java.lang.String DIRECTIVE_INCLUDE
public static final boolean DEFAULT_NAMESPACE_AWARE
public static final boolean DEFAULT_VALIDATION
Constructor Detail |
private XML()
Method Detail |
public static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
private static java.util.Properties createFormat(boolean omitXMLDeclaration, boolean standalone, boolean indented, java.lang.String encoding)
public static java.lang.String toString(org.w3c.dom.Document doc, boolean omitXMLDeclaration, boolean standalone, boolean indented, java.lang.String encoding) throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
public static java.lang.String toString(org.w3c.dom.Document doc) throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
toString(Document,Properties)
public static java.lang.String toString(org.w3c.dom.Element element) throws javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.transform.TransformerException
toString(Document)
private static java.lang.String toString(org.w3c.dom.Element element, java.util.Properties properties) throws javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.transform.TransformerException
private static java.lang.String toString(org.w3c.dom.Document doc, java.util.Properties format) throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
public static org.w3c.dom.Document toDocument(java.lang.String text) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static org.w3c.dom.Element toElement(java.lang.String text) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public static java.lang.String asString(org.w3c.dom.Element element) throws java.lang.IllegalArgumentException
element
-
java.lang.IllegalArgumentException
asString(org.w3c.dom.Element,boolean)
public static java.lang.String asString(org.w3c.dom.Element element, boolean trim) throws java.lang.IllegalArgumentException
element
- the containertrim
- true if text should be trimmed before returning result
java.lang.IllegalArgumentException
- if the element content is mixed or nullpublic static org.w3c.dom.Element getUniqueChild(org.w3c.dom.Element element, boolean strict) throws java.lang.IllegalArgumentException, NoSuchElementException, TooManyElementException
element
- the parent elementstrict
- true if the element must be present
java.lang.IllegalArgumentException
- if an argument is null
NoSuchElementException
- if strict is true and the element is not present
TooManyElementException
- if more than one element is foundpublic static org.w3c.dom.Element getUniqueChild(org.w3c.dom.Element element, java.lang.String name, boolean strict) throws java.lang.IllegalArgumentException, NoSuchElementException, TooManyElementException
element
- the parent elementname
- the child namestrict
- if the child must be present
java.lang.IllegalArgumentException
- if an argument is null
NoSuchElementException
- if strict is true and the element is not present
TooManyElementException
- if more than one element is foundpublic static java.util.Iterator getChildrenIterator(org.w3c.dom.Element element, java.lang.String name) throws java.lang.IllegalArgumentException
element
- the parent elementname
- the child names
java.lang.IllegalArgumentException
- if the element is null or the name is nullpublic static java.util.List getChildren(org.w3c.dom.Element element, java.lang.String name) throws java.lang.IllegalArgumentException
element
- the parent elementname
- the child names
java.lang.IllegalArgumentException
- if the element is null or the name is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |