|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.adaptx.xpath.XPathContext
public class XPathContext
Base implementation of an XPath context. An XPath context provides a way to manage a stack of node-sets, resolve variable and function names, and return the size and position of the context. This implementation is not thread-safe, care must be taken not to use the same context when evaluating expressions concurrently.
Impelementations may wish to extend this class and provide additional facilities for locating the document order of a node, or providing a function library.
Constructor Summary | |
---|---|
XPathContext(VariableSet variables,
NodeSet nodeSet,
int position)
Constructs a new XPath context. |
|
XPathContext(XPathNode node)
Constructs a new XPath context using the given node as the context node. |
|
XPathContext(XPathNode node,
VariableSet variables)
Constructs a new XPath context using the given node as as the context node. |
Method Summary | |
---|---|
void |
addNamespaceBinding(java.lang.String prefix,
java.lang.String namespace)
Creates a binding within this XPathContext between a given prefix and a namespace URI. |
int[] |
getDocumentOrder(XPathNode node)
Returns the document order of the given node. |
XPathNode |
getElementById(XPathNode root,
java.lang.String id)
Returns the element associated with the given identifier. |
XPathFunction |
getFunction(java.lang.String uri,
java.lang.String name)
Returns the XPath function by the given name, or null if no such function is defined. |
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Returns the namespace associated with the given prefix as defined in this context. |
XPathNode |
getNode()
Returns the context node of this XPathContext |
NodeSet |
getNodeSet()
Returns the current context node-set. |
int |
getPosition()
Returns the position of the context node. |
int |
getSize()
Returns the size of the context. |
XPathResult |
getVariable(java.lang.String name)
Returns the XPath result bound to the given variable name. |
XPathContext |
newContext(NodeSet nodeSet,
int position)
Creates a new XPathContext with this XPathContext as it's parent. |
XPathContext |
newContext(XPathNode node)
Creates a new XPathContext with this XPathContext as it's parent. |
NodeSet |
newNodeSet()
Constructs and returns a new empty node-set. |
NodeSet |
newNodeSet(int size)
Constructs and returns a new node-set with the specified size. |
NodeSet |
newNodeSet(XPathNode node)
Constructs and returns a new node-set with one node. |
void |
setNodeSet(NodeSet nodeSet,
int position)
Sets the given node-set as the context node-set for this XPathContext |
void |
setPosition(int position)
Sets the position of the context node within the context node-set |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XPathContext(XPathNode node)
node
- the context XPathNode.public XPathContext(XPathNode node, VariableSet variables)
node
- the context XPathNode.variable
- Variable bindings, or nullpublic XPathContext(VariableSet variables, NodeSet nodeSet, int position)
variable
- Variable bindings, or nullnodeSet
- the context node-set for this XPathContextposition
- The position of the context node (zero base)Method Detail |
---|
public void addNamespaceBinding(java.lang.String prefix, java.lang.String namespace)
prefix
- the prefix to associate with the namespacenamespace
- the namespace URI.public XPathNode getNode()
public int getPosition()
getSize()
public int getSize()
public XPathContext newContext(XPathNode node)
public XPathContext newContext(NodeSet nodeSet, int position)
public NodeSet newNodeSet(int size)
size
- The size of the node-set
public NodeSet newNodeSet(XPathNode node)
node
- The node to include in the node-set
public NodeSet newNodeSet()
public NodeSet getNodeSet()
public void setNodeSet(NodeSet nodeSet, int position)
nodeSet
- the node-set to use as the context node-set.position
- the position of the context nodepublic int[] getDocumentOrder(XPathNode node)
public XPathNode getElementById(XPathNode root, java.lang.String id)
root
- The root nodeid
- The element's identifier
public XPathResult getVariable(java.lang.String name)
name
- The variable name
public XPathFunction getFunction(java.lang.String uri, java.lang.String name)
uri
- The function's namespace URIname
- The function's name within that URI
public java.lang.String getNamespaceURI(java.lang.String prefix)
prefix
- the namespace prefix
public void setPosition(int position)
the
- position of the context node within the
context node-set
java.lang.IndexOutOfBoundsException
- when the position
is not within the bounds of the context node-set.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |