Class SimpleVariableContext
- java.lang.Object
-
- org.jaxen.SimpleVariableContext
-
- All Implemented Interfaces:
java.io.Serializable,VariableContext
public class SimpleVariableContext extends java.lang.Object implements VariableContext, java.io.Serializable
Simple default implementation forVariableContext.This is a simple table-based key-lookup implementation for
VariableContextwhich can be programmatically extended by setting additional variables.- Author:
- bob mcwhirter
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleVariableContext()Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetVariableValue(java.lang.String namespaceURI, java.lang.String prefix, java.lang.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.voidsetVariableValue(java.lang.String localName, java.lang.Object value)Set the value associated with a variable.voidsetVariableValue(java.lang.String namespaceURI, java.lang.String localName, java.lang.Object value)Set the value associated with a variable.
-
-
-
Method Detail
-
setVariableValue
public void setVariableValue(java.lang.String namespaceURI, java.lang.String localName, java.lang.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:fooin an XPath expression. Prefix to URI resolution is the responsibility of aNamespaceContext. Variables within aVariableContextare referred to purely based upon their namespace URI, if any.- Parameters:
namespaceURI- the namespace URI of the variablelocalName- the local name of the variablevalue- The value to be bound to the variable
-
setVariableValue
public void setVariableValue(java.lang.String localName, java.lang.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
$fooin an XPath expression.- Parameters:
localName- the local name of the variablevalue- the value to be bound to the variable
-
getVariableValue
public java.lang.Object getVariableValue(java.lang.String namespaceURI, java.lang.String prefix, java.lang.String localName) throws UnresolvableExceptionDescription copied from interface:VariableContextAn 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:
getVariableValuein interfaceVariableContext- 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 isnull.prefix- the prefix that was used in the variable reference expression; this value is ignored and has no effectlocalName- 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
-
-