org.jaxen

Class Context

Implemented Interfaces:
Serializable

public class Context
extends java.lang.Object
implements Serializable

Wrapper around implementation-specific objects used as the context of an expression evaluation.

NOTE: This class is not typically used directly, but is exposed for writers of implementation-specific XPath packages.

The Context bundles utilities together for evaluation of the expression. It wraps the provided objects for ease-of-passage through the expression AST.

Author:
bob mcwhirter
See Also:
ContextSupport, BaseXPath, XPath for dom4j, XPath for JDOM, XPath for W3C DOM

Field Summary

private ContextSupport
contextSupport
Context-support
private List
nodeSet
Context node-set
private int
position
Current context position
private static long
serialVersionUID
private int
size
Current context size

Constructor Summary

Context(ContextSupport contextSupport)
Create a new context.

Method Summary

Context
duplicate()
Create a type-safe shallow copy.
ContextSupport
getContextSupport()
Retrieve the ContextSupport.
Function
getFunction(String namespaceURI, String prefix, String localName)
Retrieve a Function.
Navigator
getNavigator()
Retrieve the current Navigator.
List
getNodeSet()
Retrieve the context node-set.
int
getPosition()
Retrieve current position in the context node-set.
int
getSize()
Retrieve the size of the current context node-set.
Object
getVariableValue(String namespaceURI, String prefix, String localName)
Retrieve a variable value.
void
setContextSupport(ContextSupport contextSupport)
Set the ContextSupport.
void
setNodeSet(List nodeSet)
Set the context node-set, and sets the current context size to the size of this node-set.
void
setPosition(int position)
Set the current position in the context node-set.
void
setSize(int size)
Set the current size in the context node-set.
String
translateNamespacePrefixToUri(String prefix)
Translate a namespace prefix to its URI.

Field Details

contextSupport

private ContextSupport contextSupport
Context-support

nodeSet

private List nodeSet
Context node-set

position

private int position
Current context position

serialVersionUID

private static final long serialVersionUID
Field Value:
2315979994685591055L

size

private int size
Current context size

Constructor Details

Context

public Context(ContextSupport contextSupport)
Create a new context.
Parameters:
contextSupport - the context-support

Method Details

duplicate

public Context duplicate()
Create a type-safe shallow copy.
Returns:
the duplicate

getContextSupport

public ContextSupport getContextSupport()
Retrieve the ContextSupport.
Returns:
the context-support

getFunction

public Function getFunction(String namespaceURI,
                            String prefix,
                            String localName)
            throws UnresolvableException
Retrieve a Function.
Parameters:
namespaceURI - the function namespace URI
prefix - the function prefix
localName - the function name
Returns:
the function object
Throws:
UnresolvableException - if unable to locate a bound function

getNavigator

public Navigator getNavigator()
Retrieve the current Navigator.
Returns:
the navigator

getNodeSet

public List getNodeSet()
Retrieve the context node-set. This is a live list. It is not a copy.
Returns:
the context node-set

getPosition

public int getPosition()
Retrieve current position in the context node-set.
Returns:
the current position

getSize

public int getSize()
Retrieve the size of the current context node-set.
Returns:
the size

getVariableValue

public Object getVariableValue(String namespaceURI,
                               String prefix,
                               String localName)
            throws UnresolvableException
Retrieve a variable value.
Parameters:
namespaceURI - the function namespace URI
prefix - the function prefix
localName - the function name
Returns:
the variable value
Throws:
UnresolvableException - if unable to locate a bound variable

setContextSupport

public void setContextSupport(ContextSupport contextSupport)
Set the ContextSupport.
Parameters:
contextSupport - the context-support

setNodeSet

public void setNodeSet(List nodeSet)
Set the context node-set, and sets the current context size to the size of this node-set. The actual list is stored in this object. A copy is not made.
Parameters:
nodeSet - the context node-set

setPosition

public void setPosition(int position)
Set the current position in the context node-set.
Parameters:
position - the position

setSize

public void setSize(int size)
Set the current size in the context node-set.
Parameters:
size - the size

translateNamespacePrefixToUri

public String translateNamespacePrefixToUri(String prefix)
Translate a namespace prefix to its URI.
Parameters:
prefix - the prefix
Returns:
the namespace URI mapped to the prefix