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

java.lang.Object
  extended by org.inria.ns.reflex.xml.xpath.EvaluableExpression
All Implemented Interfaces:
Computable

public class EvaluableExpression
extends Object
implements Computable

Reflect a typed data that can be either a hard-coded value or an expression.

A EvaluableExpression wraps an expression that supplies a typed data ; if the underlying expression is a string, the typed data will be computed once, otherwise, it will be evaluated each time the typed data is requested.

Exemples

We want an integer as the value for "max" (which is an attribute) :

We want the content of a file as a string :

In this last case, it might be convenient to have both the string content of the file and its URI. This can be performed by creating an evaluable expression with a dual evaluable. The result will be a list of items.

The evaluable interface supplies some convenient implementations (string loader, URI getter, etc).

Author:
Philippe Poulard

Constructor Summary
EvaluableExpression(Expression expression, Evaluable postProcess)
          Create a new evaluable expression.
 
Method Summary
 Object getComputedValue(DataSet dataSet)
          Return the evaluated expression.
 boolean isStatic()
          Indicates if the underlying expression is static or dynamic.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EvaluableExpression

public EvaluableExpression(Expression expression,
                           Evaluable postProcess)
Create a new evaluable expression.

Parameters:
expression - The expression to evaluate.
postProcess - What to do with the result of the expression.
Method Detail

getComputedValue

public Object getComputedValue(DataSet dataSet)
                        throws ExecutionException,
                               XPathException
Return the evaluated expression.

Specified by:
getComputedValue in interface Computable
Parameters:
dataSet - The set of datas used for the computation.
Returns:
The evaluated expression.
Throws:
ExecutionException - If the computation can't be performed.
XPathException
See Also:
Computable.getComputedValue(org.inria.ns.reflex.processor.DataSet)

toString

public String toString()
Overrides:
toString in class Object

isStatic

public boolean isStatic()
Indicates if the underlying expression is static or dynamic.

Returns:
true if the expression is a string, false if it is an XPath expression.