org.jaxen
Class SimpleVariableContext

java.lang.Object
  extended by org.jaxen.SimpleVariableContext
All Implemented Interfaces:
Serializable, VariableContext

public class SimpleVariableContext
extends Object
implements VariableContext, Serializable

Simple default implementation for VariableContext.

This is a simple table-based key-lookup implementation for VariableContext which can be programmatically extended by setting additional variables.

Author:
bob mcwhirter
See Also:
Serialized Form

Constructor Summary
SimpleVariableContext()
          Construct.
 
Method Summary
 Object getVariableValue(String namespaceURI, String prefix, String localName)
          An implementation should return the value of an XPath variable based on the namespace URI and local name of the variable-reference expression.
 void setVariableValue(String localName, Object value)
          Set the value associated with a variable.
 void setVariableValue(String namespaceURI, String localName, Object value)
          Set the value associated with a variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleVariableContext

public SimpleVariableContext()
Construct.

Create a new empty variable context.

Method Detail

setVariableValue

public void setVariableValue(String namespaceURI,
                             String localName,
                             Object value)
Set the value associated with a variable.

This method sets a variable that is associated with a particular namespace. These variables appear such as $prefix:foo in an XPath expression. Prefix to URI resolution is the responsibility of a NamespaceContext. Variables within a VariableContext are referred to purely based upon their namespace URI, if any.

Parameters:
namespaceURI - the namespace URI of the variable
localName - the local name of the variable
value - The value to be bound to the variable

setVariableValue

public void setVariableValue(String localName,
                             Object value)
Set the value associated with a variable.

This method sets a variable that is not associated with any particular namespace. These variables look like $foo in an XPath expression.

Parameters:
localName - the local name of the variable
value - the value to be bound to the variable

getVariableValue

public Object getVariableValue(String namespaceURI,
                               String prefix,
                               String localName)
                        throws UnresolvableException
Description copied from interface: VariableContext
An implementation should return the value of an XPath variable based on the namespace URI and local name of the variable-reference expression.

It must not use the prefix parameter to select a variable, because a prefix could be bound to any namespace; the prefix parameter could be used in debugging output or other generated information. The prefix may otherwise be ignored.

Specified by:
getVariableValue in interface VariableContext
Parameters:
namespaceURI - the namespace URI to which the prefix parameter is bound in the XPath expression. If the variable reference expression had no prefix, the namespace URI is null.
prefix - the prefix that was used in the variable reference expression; this value is ignored and has no effect
localName - the local name of the variable-reference expression. If there is no prefix, then this is the whole name of the variable.
Returns:
the variable's value (which can be null)
Throws:
UnresolvableException - when the variable cannot be resolved


Copyright © 2001-2008 Codehaus. All Rights Reserved.