Class QueryTable
java.lang.Object
|
+--QueryTable
- public class QueryTable
- extends java.lang.Object
Builds a table that maps typical XPTR queries to DOM nodes. Lookup with
this table is much faster than using the regular XPath library, but less
flexible. If lookup fails, we fall back to the XPath library.
- Version:
- $2005-11-01 18:20:58 mdh$
- Author:
- Malcolm D. Hyman
|
Method Summary |
static org.w3c.dom.Node |
getNode(java.lang.String locator,
java.lang.String xpath)
Returns a node from the document referred to by locator that matches
the XPath expression xpath. |
int |
getSequence(org.w3c.dom.Node node)
Returns the linear position for a node |
int[] |
getSequenceArray(org.w3c.dom.Node[] nodes)
Returns an array of integers corresponding to the linear positions
of an array of nodes. |
java.lang.String |
makeXPTR(org.w3c.dom.Node container)
Computes an XPTR expression that locates a container node. |
org.w3c.dom.Node |
query(java.lang.String xpath)
Returns a node that from the document selected by an XPath expression. |
void |
rebuildTable()
Rebuils the query table; should be called if unknown changes have
occurred in the DOM. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
QueryTable
public QueryTable(org.w3c.dom.Node root,
DocSpec spec)
rebuildTable
public void rebuildTable()
- Rebuils the query table; should be called if unknown changes have
occurred in the DOM.
query
public org.w3c.dom.Node query(java.lang.String xpath)
- Returns a node that from the document selected by an XPath expression.
Lookup is done using the query table.
- Parameters:
xpath - XPath expression
makeXPTR
public java.lang.String makeXPTR(org.w3c.dom.Node container)
- Computes an XPTR expression that locates a container node.
- Parameters:
container - container- Returns:
- XPTR expression
getNode
public static org.w3c.dom.Node getNode(java.lang.String locator,
java.lang.String xpath)
- Returns a node from the document referred to by locator that matches
the XPath expression
xpath.
- Parameters:
locator - locatorxpath - XPath expression
getSequenceArray
public int[] getSequenceArray(org.w3c.dom.Node[] nodes)
- Returns an array of integers corresponding to the linear positions
of an array of nodes.
- Parameters:
nodes - node array- Returns:
- sequence array
getSequence
public int getSequence(org.w3c.dom.Node node)
- Returns the linear position for a node
- Parameters:
node - DOM node- Returns:
- linear sequence