|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.logikdev.jsftools.StaticXmlTool
public class StaticXmlTool
Tool for reading/navigating XML files. This uses dom4j under the covers to provide complete XPath support for traversing XML files.
| Constructor Summary | |
|---|---|
StaticXmlTool()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
attr(org.dom4j.Node node,
java.lang.Object o)
Returns the value of the specified attribute for the specified Node, if that Node is an Element. |
static java.util.Map<java.lang.String,java.lang.String> |
attributes(org.dom4j.Node node)
Returns a Map of all attributes for the specified Node. |
static org.dom4j.Node |
children(org.dom4j.Node node)
Returns a new Node instance that wraps all the child Elements of the specified Node. |
static org.dom4j.Node |
find(org.dom4j.Node node,
java.lang.Object o)
Converts the specified object to a String and calls find(org.dom4j.Node, java.lang.String) with that. |
static org.dom4j.Node |
find(org.dom4j.Node node,
java.lang.String xpath)
Performs an XPath selection on the specified Node and returns a new Node instance that wraps those results. |
static org.dom4j.Node |
get(org.dom4j.Node node,
java.lang.Number n)
Returns a Node that wraps the specified Node. |
static java.lang.Object |
get(org.dom4j.Node node,
java.lang.Object o)
This will first attempt to find an attribute with the specified name and return its value. |
static org.dom4j.Node |
getFirst(org.dom4j.Node node)
Returns a Node that wraps only the first Node from the specified Node. |
static org.dom4j.Node |
getLast(org.dom4j.Node node)
Returns a Node that wraps only the last Node from the specified Node. |
static java.lang.Object |
getName(org.dom4j.Node node)
Asks get(org.dom4j.Node, java.lang.Object) for a "name" result. |
static java.lang.String |
getNodeName(org.dom4j.Node node)
Returns the name of the root node. |
static org.dom4j.Node |
getParent(org.dom4j.Node node)
Returns a new Node instance that wraps the parent Element of the specified Node. |
static java.lang.String |
getPath(org.dom4j.Node node)
Returns the XPath that identifies the specified Node. |
static java.lang.String |
getText(org.dom4j.Node node)
Returns the concatenated text content of the specified Node. |
static org.dom4j.Node |
parents(org.dom4j.Node node)
Returns a new Node instance that wraps the parent Elements of the specified Node. |
static org.dom4j.Node |
parse(java.lang.Object o)
This accepts XML in form. |
static org.dom4j.Node |
read(java.lang.Object o)
If valid, it will return a new Node instance with that document as the root Node. |
static java.util.List<org.dom4j.Node> |
selectNodes(org.dom4j.Node node,
java.lang.String xpath)
Evaluates an XPath expression and returns the result as a List of Node instances or String instances depending on the XPath expression. |
static org.dom4j.Node |
selectSingleNode(org.dom4j.Node node,
java.lang.String xpath)
Evaluates an XPath expression and returns the result as a single Node instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StaticXmlTool()
| Method Detail |
|---|
public static final java.lang.String attr(org.dom4j.Node node,
java.lang.Object o)
Node, if that Node is an Element.
If it is a non-Element node type or there is no value for that attribute in this element, then this will return null.
node - The nodeo - The attribute
Nodepublic static final java.util.Map<java.lang.String,java.lang.String> attributes(org.dom4j.Node node)
Map of all attributes for the specified Node.
If that Node is not an Element, this will return null.
node - The node
Map of all attributes for the specified Nodepublic static final org.dom4j.Node children(org.dom4j.Node node)
Node instance that wraps all the child Elements of the specified Node.
node - The node
Node instance that wraps all the child Elements of the specified Node
public static final org.dom4j.Node find(org.dom4j.Node node,
java.lang.Object o)
node - The nodeo - The object
Node instance that wraps those results
public static final org.dom4j.Node find(org.dom4j.Node node,
java.lang.String xpath)
Node and returns a new Node instance that wraps those results.
If the specified values are null, then this will return null.
If the specified value, when converted to a string, does not contain a '/' character, then it has "//" prepended to it.
This means that a call to find(node, "a") is equivalent to calling find(node, "//a").
The full range of XPath selectors is supported here.
node - The nodexpath - The XPath
Node instance that wraps those results
public static final org.dom4j.Node get(org.dom4j.Node node,
java.lang.Number n)
Node that wraps the specified Node.
node - The noden - The number
Node that wraps the specified Node
public static final java.lang.Object get(org.dom4j.Node node,
java.lang.Object o)
null, this will attempt to convert the given value
to a Number and get the result of get(org.dom4j.Node, java.lang.Number).
If the number conversion fails, then this will convert the object to a string.
If that string does not contain a '/', it appends the result of getPath(org.dom4j.Node)
and a '/' to the front of it.
Finally, it delegates the string to the find(org.dom4j.Node, java.lang.String)
method and returns the result of that.
node - The nodeo - The object
public static final org.dom4j.Node getFirst(org.dom4j.Node node)
Node that wraps only the first Node from the specified Node.
node - The node
Node that wraps only the first Node from the specified Nodepublic static final org.dom4j.Node getLast(org.dom4j.Node node)
Node that wraps only the last Node from the specified Node.
node - The node
Node that wraps only the last Node from the specified Nodepublic static final java.lang.Object getName(org.dom4j.Node node)
node - The node
get(org.dom4j.Node, java.lang.Object) for a "name" resultpublic static final java.lang.String getNodeName(org.dom4j.Node node)
node - The node
public static final org.dom4j.Node getParent(org.dom4j.Node node)
Node instance that wraps the parent Element of the specified Node.
node - The node
Node instance that wraps the parent Element of the specified Nodepublic static final java.lang.String getPath(org.dom4j.Node node)
Node.
node - The node
Nodepublic static final java.lang.String getText(org.dom4j.Node node)
Node.
node - The node
Nodepublic static final org.dom4j.Node parents(org.dom4j.Node node)
Node instance that wraps the parent Elements of the specified Node.
This does not return all ancestors, just the immediate parents.
node - The node
Node instance that wraps the parent Elements of the specified Nodepublic static final org.dom4j.Node parse(java.lang.Object o)
Node instance with the resulting XML document as the root Node.
If parsing the content fails, this will return null.
o - The object
Node instance with the resulting XML document as the root Nodepublic static final org.dom4j.Node read(java.lang.Object o)
Node instance with that document as the root Node.
If reading the URL or parsing its content fails, this will return null.
o - The object
Node instance with that document as the root Node
public static final java.util.List<org.dom4j.Node> selectNodes(org.dom4j.Node node,
java.lang.String xpath)
List of Node instances or String instances depending on the XPath expression.
node - The nodexpath - The XPath expression
List of Node instances or String instances depending on the XPath expression
public static final org.dom4j.Node selectSingleNode(org.dom4j.Node node,
java.lang.String xpath)
Node instance.
node - The nodexpath - The XPath expression
Node instance
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||