|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.xml.XPath
This class is a General Superclass for implementing XPath Expressions. A Subclass is required to implement getChildren, getNodeName and solve for XPath to be able to locate elements based on xpath expressions. XPath expressions are W3C specification related to XML. This implementation supports a subset of W3C's XPATH specification. A description of the support is as follows:
doc/child1/child2
NOTE: does not have the same semantic meaning as the first example
DOMXPath
Nested Class Summary | |
class |
XPath.NullIterator
A convenience class. |
Field Summary | |
protected static int |
OP_FIND
|
protected static int |
OP_NODEPATH
|
protected static int |
OP_VALUE
|
Constructor Summary | |
protected |
XPath(java.lang.String xpath)
Splits the xpath string into terms, one for each node to match, and transforms the strings into Regex Patterns. |
Method Summary | |
java.util.List |
find(java.lang.Object root)
Returns a list of the nodes that are identified by this XPath expression. |
protected abstract java.util.Iterator |
getChildren(java.lang.Object o)
This method is used to get all the child nodes of Object o. |
protected abstract java.lang.String |
getNodeName(java.lang.Object o)
Returns the string which identifies the name. |
java.util.regex.Pattern[] |
getTerms()
Returns all the java.regex.Pattern objects that are used for matching. |
protected abstract boolean |
isLegalNode(java.lang.Object o,
int operation,
boolean isList)
Tests whether the object passed is a legal node element Legal nodes may differ depending on the type of operation being performed. |
protected boolean |
nodeMatch(java.util.regex.Pattern term,
java.lang.Object o)
Checks if the pattern term matches object o's name as returned by the getNodeName() method. |
java.util.List |
nodePaths(java.lang.Object root)
Returns a list of the node paths for all the solutions to the XPath expression In other words all the nodes from the root to the identified node are included in the nodepath If root is a valid object (accepts() returns true) then the object is used as the root and its children are matched against the first term. |
protected abstract java.lang.Object |
solve(java.util.List path)
Given a list of node objects, a value is computed that is the semantic "value" of the path. |
java.lang.String |
toString()
Translates the XPath into string form |
java.util.List |
value(java.lang.Object root)
Returns a list of the values of the nodes that are identified by this XPath expression. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final int OP_FIND
protected static final int OP_VALUE
protected static final int OP_NODEPATH
Constructor Detail |
protected XPath(java.lang.String xpath)
xpath
- the String form of the XPath expressionMethod Detail |
protected abstract boolean isLegalNode(java.lang.Object o, int operation, boolean isList)
o
- Object to testoperation
- one of the OP_XXX constants
protected abstract java.util.Iterator getChildren(java.lang.Object o)
o
- The object that is considered to be the "Parent."
In the case of hierarchical datastructures o will often be a child of another object
previously passed to the getChildren method.
protected abstract java.lang.String getNodeName(java.lang.Object o)
o
- The object being matched to the current term.
protected abstract java.lang.Object solve(java.util.List path)
path
- The list is the path of nodes, in order, that matches the XPath expression.
The first element of the list is the "root" object passed to the value method
protected boolean nodeMatch(java.util.regex.Pattern term, java.lang.Object o)
term
- The pattern to be used to determine a match.o
- The current node being inspected
public java.util.List find(java.lang.Object root)
root
- A Node or a List of Nodes.
If root is a Node the children of root are matched against the first term of the XPath expression
If root is a list then the elements of root are matched against the first term of the XPath expression
public java.util.List value(java.lang.Object root)
root
- A Node or a List of Nodes.
If root is a Node the children of root are matched against the first term of the XPath expression
If root is a list then the elements of root are matched against the first term of the XPath expression
public java.util.List nodePaths(java.lang.Object root)
root
- A Node or a List of Nodes.
If root is a Node the children of root are matched against the first term of the XPath expression
If root is a list then the elements of root are matched against the first term of the XPath expression
public java.util.regex.Pattern[] getTerms()
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |