org.inria.ns.reflex.xml.xpath
Class StringExpression

java.lang.Object
  extended by org.inria.ns.reflex.xml.xpath.Expression
      extended by org.inria.ns.reflex.xml.xpath.StringExpression

public class StringExpression
extends Expression

A StringExpression is used when an expression contains only a simple string, that stands for a litteral string value.

The static method parseValueTemplate will compile such an expression string in a StringExpression object.

At runtime, the compute method will return the expression as a string (the same that was used to build the expression).

Author:
Philippe Poulard

Constructor Summary
StringExpression(String expression)
          Creates a new instance of StringExpression
StringExpression(String expression, XFactory factory)
          Creates a new instance of StringExpression
 
Method Summary
 Object compute(XPathContext context)
          Provides a runtime computation of the compiled expression using the given dataset.
 Object compute(XPathVariableResolver variableResolver)
          Provides a runtime computation of the compiled expression with the dataset.
 Object compute(XPathVariableResolver variableResolver, Object contextNode)
          Provides a runtime computation of the compiled expression with the dataset.
 
Methods inherited from class org.inria.ns.reflex.xml.xpath.Expression
equals, getExpression, hashCode, parseValueTemplate, parseValueTemplate, parseValueTemplate, parseValueTemplate, parseValueTemplate, parseValueTemplate, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringExpression

public StringExpression(String expression)
Creates a new instance of StringExpression

Parameters:
expression - The string used to compile the Expression.

StringExpression

public StringExpression(String expression,
                        XFactory factory)
Creates a new instance of StringExpression

Parameters:
expression - The string used to compile the Expression.
Method Detail

compute

public Object compute(XPathVariableResolver variableResolver)
               throws XPathException
Provides a runtime computation of the compiled expression with the dataset.

Overrides:
compute in class Expression
Parameters:
variableResolver - The resolver used to retrieve the variables used for the computation.
Returns:
The result of the evaluated expression, as a String .
Throws:
TransformerException - When the expression rises an XPath error at runtime.
XPathException - When the expression rises an XPath error at runtime.

compute

public Object compute(XPathVariableResolver variableResolver,
                      Object contextNode)
               throws XPathException
Provides a runtime computation of the compiled expression with the dataset.

Overrides:
compute in class Expression
Parameters:
variableResolver - The resolver used to retrieve the variables used for the computation.
Returns:
The result of the evaluated expression, as a String .
Throws:
TransformerException - When the expression rises an XPath error at runtime.
XPathException - When the expression rises an XPath error at runtime.

compute

public Object compute(XPathContext context)
               throws XPathException
Provides a runtime computation of the compiled expression using the given dataset.

Specified by:
compute in class Expression
Parameters:
variableResolver - The resolver used to retrieve the variables used for the computation.
Returns:
The result of the evaluated expression.
Throws:
XPathException - When the expression rises an XPath error at runtime.