|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.portal.common.xml.XMLTools
public class XMLTools
Utilities for dealing with XML.
Nested Class Summary | |
---|---|
static interface |
XMLTools.Filter<N extends org.w3c.dom.Node>
|
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
. |
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
. |
static java.lang.String |
XML_LANG_NAMESPACE_URI
Namespace URI for XML lang. |
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. |
|
static XMLTools.Filter<org.w3c.dom.Element> |
byName(java.lang.String uri,
java.util.Set<java.lang.String> names)
|
|
static XMLTools.Filter<org.w3c.dom.Element> |
byName(java.lang.String uri,
java.lang.String name)
|
|
static java.util.List<org.w3c.dom.Element> |
getChildren(org.w3c.dom.Element element)
Return all the children of the given element. |
|
static java.util.List<org.w3c.dom.Element> |
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.List<org.w3c.dom.Element> |
getChildren(org.w3c.dom.Element element,
java.lang.String uri,
java.lang.String name)
Return all the children of the given element having the optionally specified name and the namespace URI. |
|
static
|
getChildren(org.w3c.dom.Node node,
XMLTools.Filter<T> filter)
Return all the children of the given node that match the provided filter. |
|
static java.util.Iterator<org.w3c.dom.Element> |
getChildrenIterator(org.w3c.dom.Element element)
Return an iterator for all the children of the given element. |
|
static java.util.Iterator<org.w3c.dom.Element> |
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 java.util.Iterator<org.w3c.dom.Element> |
getChildrenIterator(org.w3c.dom.Element element,
java.lang.String uri,
java.lang.String name)
Return an iterator for all the children of the given element having the specified name and the optionally specified namesspace uri. |
|
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.Element |
getUniqueChild(org.w3c.dom.Element element,
java.lang.String uri,
java.lang.String name,
boolean strict)
Return an optional child of an element with the specified name and the optionally specified namespace uri. |
|
static java.util.Properties |
loadXMLProperties(org.w3c.dom.Document doc)
|
|
static java.util.Properties |
loadXMLProperties(org.w3c.dom.Element propertiesElt)
|
|
static org.w3c.dom.Document |
toDocument(org.w3c.dom.Element element)
|
|
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)
|
|
static java.lang.String |
toString(org.w3c.dom.Element element)
|
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
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
Method Detail |
---|
public static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
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)
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 org.w3c.dom.Document toDocument(org.w3c.dom.Element element) 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 org.w3c.dom.Element getUniqueChild(org.w3c.dom.Element element, java.lang.String uri, java.lang.String name, boolean strict) throws java.lang.IllegalArgumentException, NoSuchElementException, TooManyElementException
element
- the parent elementname
- the child nameuri
- the child uristrict
- 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<org.w3c.dom.Element> getChildrenIterator(org.w3c.dom.Element element) throws java.lang.IllegalArgumentException
element
- the parent element
java.lang.IllegalArgumentException
- if the element is null or the name is nullpublic static java.util.Iterator<org.w3c.dom.Element> 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.Iterator<org.w3c.dom.Element> getChildrenIterator(org.w3c.dom.Element element, java.lang.String uri, java.lang.String name) throws java.lang.IllegalArgumentException
element
- the parent elementuri
- the children uriname
- the children name
java.lang.IllegalArgumentException
- if the element is null or the name is nullpublic static java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element element) throws java.lang.IllegalArgumentException
element
- the parent element
java.lang.IllegalArgumentException
- if the element is null or the name is nullpublic static java.util.List<org.w3c.dom.Element> 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 nullpublic static java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element element, java.lang.String uri, java.lang.String name) throws java.lang.IllegalArgumentException
Return all the children of the given element having the optionally specified name and the namespace URI.
If the URI is specified then the element must have the same URI namespace in order to be included otherwise it will be included. If the URI is specified the name matching will be done against the element local name otherwise it will be done against the element tag name.
If the name is specified then the element must have the same tag name or the same local name to be retained otherwise it will be included.
The resulting element collection can be safely modified.
element
- the parent elementuri
- the children uriname
- the children name
java.lang.IllegalArgumentException
- if the element is nullpublic static <T extends org.w3c.dom.Node> java.util.List<T> getChildren(org.w3c.dom.Node node, XMLTools.Filter<T> filter) throws java.lang.IllegalArgumentException
Return all the children of the given node that match the provided filter.
The resulting element collection can be safely modified.
node
- the parent elementfilter
- the filter
java.lang.IllegalArgumentException
- if the element is nullpublic static XMLTools.Filter<org.w3c.dom.Element> byName(java.lang.String uri, java.util.Set<java.lang.String> names)
public static XMLTools.Filter<org.w3c.dom.Element> byName(java.lang.String uri, java.lang.String name)
public static java.util.Properties loadXMLProperties(org.w3c.dom.Element propertiesElt)
public static java.util.Properties loadXMLProperties(org.w3c.dom.Document doc)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |