net.sf.saxon.xpath
Class Variable

java.lang.Object
  |
  +--net.sf.saxon.xpath.Variable
All Implemented Interfaces:
Binding, VariableDeclaration

public final class Variable
extends java.lang.Object
implements VariableDeclaration, Binding

An object representing an XPath variable for use in the standalone XPath API. The object can only be created by calling the declareVariable method of class StandaloneContext.


Method Summary
 Value evaluateVariable(XPathContext context)
          Get the value of the variable.
 SequenceType getRequiredType()
          Get the SequenceType of the variable.
 int getVariableFingerprint()
          Establish the fingerprint of the name of this variable.
 java.lang.String getVariableName()
          Get the name of the variable.
protected static Variable make(java.lang.String name)
          Protected factory method, for use by the declareVariable method of class StandaloneContext
 void registerReference(BindingReference ref)
          Method called by the XPath expression parser to register a reference to this variable.
 void setValue(java.lang.Object value)
          Assign a value to the variable.
 void setXPathValue(Value value)
          Assign a value to the variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

make

protected static Variable make(java.lang.String name)
Protected factory method, for use by the declareVariable method of class StandaloneContext


getRequiredType

public SequenceType getRequiredType()
Get the SequenceType of the variable. Free-standing XPath variables allow values of any type.

Returns:
the required type: always item()*

getVariableName

public java.lang.String getVariableName()
Get the name of the variable. Used for diagnostic purposes only.

Specified by:
getVariableName in interface VariableDeclaration
Returns:
the name of the variable, as a string (containing the raw QName)

getVariableFingerprint

public int getVariableFingerprint()
Establish the fingerprint of the name of this variable. Dummy implementation, not used.

Specified by:
getVariableFingerprint in interface VariableDeclaration
Returns:
-1, always

setValue

public void setValue(java.lang.Object value)
              throws XPathException
Assign a value to the variable. This value may be changed between successive evaluations of a compiled XPath expression that references the variable.

Parameters:
value - the value of the variable
Throws:
XPathException - if the Java value cannot be converted to an XPath type

setXPathValue

public void setXPathValue(Value value)
                   throws XPathException
Assign a value to the variable. This value may be changed between successive evaluations of a compiled XPath expression that references the variable.

Parameters:
value - the value of the variable, which must be an instance of a class representing a value in the XPath model.
Throws:
XPathException - if the Java value cannot be converted to an XPath type

registerReference

public void registerReference(BindingReference ref)
Method called by the XPath expression parser to register a reference to this variable. This method should not be called by users of the API.

Specified by:
registerReference in interface VariableDeclaration

evaluateVariable

public Value evaluateVariable(XPathContext context)
Get the value of the variable. This method is used by the XPath execution engine to retrieve the value.

Specified by:
evaluateVariable in interface Binding
Parameters:
context - The dynamic evaluation context
Returns:
The value of the variable