|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dom4j.DocumentHelper
DocumentHelper
is a collection of helper methods
for using DOM4J.
Constructor Summary | |
DocumentHelper()
|
Method Summary | |
static Attribute |
createAttribute(Element owner,
QName qname,
java.lang.String value)
|
static Attribute |
createAttribute(Element owner,
java.lang.String name,
java.lang.String value)
|
static CDATA |
createCDATA(java.lang.String text)
|
static Comment |
createComment(java.lang.String text)
|
static Document |
createDocument()
|
static Document |
createDocument(Element rootElement)
|
static Element |
createElement(QName qname)
|
static Element |
createElement(java.lang.String name)
|
static Entity |
createEntity(java.lang.String name,
java.lang.String text)
|
static Namespace |
createNamespace(java.lang.String prefix,
java.lang.String uri)
|
static Pattern |
createPattern(java.lang.String xpathPattern)
createPattern parses the given
XPath expression to create an XSLT style Pattern instance
which can then be used in an XSLT processing model. |
static ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.util.Map data)
|
static ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
|
static QName |
createQName(java.lang.String localName)
|
static QName |
createQName(java.lang.String localName,
Namespace namespace)
|
static Text |
createText(java.lang.String text)
|
static XPath |
createXPath(java.lang.String xpathExpression)
createXPath parses an XPath expression
and creates a new XPath XPath instance
using the singleton DocumentFactory . |
static XPath |
createXPath(java.lang.String xpathExpression,
org.jaxen.VariableContext variableContext)
createXPath parses an XPath expression
and creates a new XPath XPath instance
using the singleton DocumentFactory . |
static NodeFilter |
createXPathFilter(java.lang.String xpathFilterExpression)
createXPathFilter parses a NodeFilter
from the given XPath filter expression using the singleton
DocumentFactory . |
static Element |
makeElement(Branch source,
java.lang.String path)
makeElement |
static Document |
parseText(java.lang.String text)
parseText parses the given text as an XML document
and returns the newly created Document. |
static java.util.List |
selectNodes(java.lang.String xpathFilterExpression,
java.util.List nodes)
selectNodes performs the given XPath
expression on the List of Node instances appending
all the results together into a single list. |
static java.util.List |
selectNodes(java.lang.String xpathFilterExpression,
Node node)
selectNodes performs the given XPath
expression on the List of Node instances appending
all the results together into a single list. |
static void |
sort(java.util.List list,
java.lang.String xpathExpression)
sort sorts the given List of Nodes
using an XPath expression as a Comparator . |
static void |
sort(java.util.List list,
java.lang.String xpathExpression,
boolean distinct)
sort sorts the given List of Nodes
using an XPath expression as a Comparator
and optionally removing duplicates. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DocumentHelper()
Method Detail |
public static Document createDocument()
public static Document createDocument(Element rootElement)
public static Element createElement(QName qname)
public static Element createElement(java.lang.String name)
public static Attribute createAttribute(Element owner, QName qname, java.lang.String value)
public static Attribute createAttribute(Element owner, java.lang.String name, java.lang.String value)
public static CDATA createCDATA(java.lang.String text)
public static Comment createComment(java.lang.String text)
public static Text createText(java.lang.String text)
public static Entity createEntity(java.lang.String name, java.lang.String text)
public static Namespace createNamespace(java.lang.String prefix, java.lang.String uri)
public static ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
public static ProcessingInstruction createProcessingInstruction(java.lang.String target, java.util.Map data)
public static QName createQName(java.lang.String localName, Namespace namespace)
public static QName createQName(java.lang.String localName)
public static XPath createXPath(java.lang.String xpathExpression) throws InvalidXPathException
createXPath
parses an XPath expression
and creates a new XPath XPath
instance
using the singleton DocumentFactory
.
xpathExpression
- is the XPath expression to create
XPath
instance
InvalidXPathException
- if the XPath expression is invalidpublic static XPath createXPath(java.lang.String xpathExpression, org.jaxen.VariableContext variableContext) throws InvalidXPathException
createXPath
parses an XPath expression
and creates a new XPath XPath
instance
using the singleton DocumentFactory
.
xpathExpression
- is the XPath expression to createvariableContext
- is the variable context to use when evaluating the XPath
XPath
instance
InvalidXPathException
- if the XPath expression is invalidpublic static NodeFilter createXPathFilter(java.lang.String xpathFilterExpression)
createXPathFilter
parses a NodeFilter
from the given XPath filter expression using the singleton
DocumentFactory
.
XPath filter expressions occur within XPath expressions such as
self::node()[ filterExpression ]
xpathFilterExpression
- is the XPath filter expression
to create
NodeFilter
instancepublic static Pattern createPattern(java.lang.String xpathPattern)
createPattern
parses the given
XPath expression to create an XSLT style Pattern
instance
which can then be used in an XSLT processing model.
xpathPattern
- is the XPath pattern expression
to create
Pattern
instancepublic static java.util.List selectNodes(java.lang.String xpathFilterExpression, java.util.List nodes)
selectNodes
performs the given XPath
expression on the List
of Node
instances appending
all the results together into a single list.
xpathFilterExpression
- is the XPath filter expression
to evaluatenodes
- is the list of nodes on which to evalute the XPath
public static java.util.List selectNodes(java.lang.String xpathFilterExpression, Node node)
selectNodes
performs the given XPath
expression on the List
of Node
instances appending
all the results together into a single list.
xpathFilterExpression
- is the XPath filter expression
to evaluatenode
- is the Node on which to evalute the XPath
public static void sort(java.util.List list, java.lang.String xpathExpression)
sort
sorts the given List of Nodes
using an XPath expression as a Comparator
.
list
- is the list of Nodes to sortxpathExpression
- is the XPath expression used for comparisonpublic static void sort(java.util.List list, java.lang.String xpathExpression, boolean distinct)
sort
sorts the given List of Nodes
using an XPath expression as a Comparator
and optionally removing duplicates.
list
- is the list of Nodes to sortxpathExpression
- is the XPath expression used for comparisondistinct
- if true then duplicate values (using the sortXPath for
comparisions) will be removed from the Listpublic static Document parseText(java.lang.String text) throws DocumentException
parseText
parses the given text as an XML document
and returns the newly created Document.
text
- is the XML text to be parsed
DocumentException
- if the document could not be parsedpublic static Element makeElement(Branch source, java.lang.String path)
makeElement
a helper method which navigates from the given Document or Element node to some Element using the path expression, creating any necessary elements along the way. For example the patha/b/c
would get the first
child <a> element, which would be created if it did not
exist, then the next child <b> and so on until finally a
<c> element is returned.
source
- is the Element or Document to start navigating from
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |