org.base.apps.beans.util
Class Evaluator

java.lang.Object
  extended by org.base.apps.beans.util.Evaluator
All Implemented Interfaces:
BeanContainer<Object>

public class Evaluator
extends Object
implements BeanContainer<Object>

A utility to evaluate an Expr against a bean. This class is used to filter rows in or add dynamic columns to a BoundTable.

Author:
Kevan Simpson

Field Summary
 JXPathContext mCtx
           
 
Constructor Summary
  Evaluator()
           
protected Evaluator(Object bean)
          Constructs an Expr visitor.
 
Method Summary
 boolean assignValue(CharSequence expr, Object value)
           
 boolean assignValue(CharSequence expr, Object value, Object bean)
           
 void compileExpr(CharSequence expr)
           
static Object eval(Object bean, Expr expr)
          Evaluates an Expr against a bean.
 Object evaluate(Expr expr)
          Evaluates the given Expr.
 Object evaluate(Expr expr, Object bean)
          Evaluates the given Expr.
 Object getBean()
          Returns this container's data bean, which may be null.
protected  Map<String,CompiledExpression> getCompiledExprCache()
           
protected  JXPathContext getCtx()
           
protected static org.apache.commons.logging.Log log()
           
 void setBean(Object bean)
          Sets this container's data bean.
protected  void setCompiledExprCache(Map<String,CompiledExpression> compiledExprCache)
           
protected  void setCtx(JXPathContext ctx)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mCtx

public JXPathContext mCtx
Constructor Detail

Evaluator

public Evaluator()

Evaluator

protected Evaluator(Object bean)
Constructs an Expr visitor.

Parameters:
bean - The bean to evaluate.
Method Detail

eval

public static Object eval(Object bean,
                          Expr expr)
Evaluates an Expr against a bean.

Parameters:
bean - A bean object.
expr - An Expr.
Returns:
true if the bean's properties match the Expr.

evaluate

public Object evaluate(Expr expr)
Evaluates the given Expr.

Parameters:
expr - The given Expr.
Returns:
The result of applying the Expr against a bean.

evaluate

public Object evaluate(Expr expr,
                       Object bean)
Evaluates the given Expr.

Parameters:
expr - The given Expr.
Returns:
The result of applying the Expr against a bean.

assignValue

public boolean assignValue(CharSequence expr,
                           Object value)

assignValue

public boolean assignValue(CharSequence expr,
                           Object value,
                           Object bean)

getBean

public Object getBean()
Description copied from interface: BeanContainer
Returns this container's data bean, which may be null.

Specified by:
getBean in interface BeanContainer<Object>
Returns:
this container's data bean or null.
See Also:
BeanContainer.getBean()

setBean

public void setBean(Object bean)
Description copied from interface: BeanContainer
Sets this container's data bean.

Specified by:
setBean in interface BeanContainer<Object>
Parameters:
bean - this container's data bean.
See Also:
BeanContainer.setBean(java.lang.Object)

compileExpr

public void compileExpr(CharSequence expr)

getCtx

protected JXPathContext getCtx()
Returns:
the ctx

setCtx

protected void setCtx(JXPathContext ctx)
Parameters:
ctx - the ctx to set

getCompiledExprCache

protected Map<String,CompiledExpression> getCompiledExprCache()
Returns:
the compiledExprCache

setCompiledExprCache

protected void setCompiledExprCache(Map<String,CompiledExpression> compiledExprCache)
Parameters:
compiledExprCache - the compiledExprCache to set

log

protected static org.apache.commons.logging.Log log()

Please visit Base Apps, hosted on Sourceforge.net.

Copyright 2011, Blue Agate Software Entity (BASE)