org.apache.cocoon.forms.formmodel
Class ExpressionContextImpl

java.lang.Object
  extended byorg.apache.cocoon.forms.formmodel.ExpressionContextImpl
All Implemented Interfaces:
org.outerj.expression.ExpressionContext

public class ExpressionContextImpl
extends Object
implements org.outerj.expression.ExpressionContext

Implementation of the ExpressionContext required for the evaluation of expressions by xReporter expression interpreter.

Version:
$Id: ExpressionContextImpl.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Constructor Summary
ExpressionContextImpl(Widget widget)
           
ExpressionContextImpl(Widget widget, boolean referenceChildren)
           
 
Method Summary
 Object get(String s)
           
 Object resolveVariable(String name)
          Variables refer to other widgets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionContextImpl

public ExpressionContextImpl(Widget widget)

ExpressionContextImpl

public ExpressionContextImpl(Widget widget,
                             boolean referenceChildren)
Parameters:
referenceChildren - if true, variables will be resolved among the children of the given container widget, rather than among the siblings of the widget.
Method Detail

resolveVariable

public Object resolveVariable(String name)
Variables refer to other widgets.

You can access parent and root widgets (with ../widget and /widget paths respectively), but mind that in xreporter expressions these variables names must be placed in brakets to be correctly parsed. For example "{../widget} + otherWidget".

In case the value of a widget is null but the widget is required or calculated, then a special exception will be thrown, the CannotYetResolveWarning. This is because in that case, you'll probably want to re-evaluate the expression at a later time (since the widget is required, it will eventually get a value).

In case the value of the widget is null but the field is not required, then simply null is returned. (TODO: a function IsNull() will provided in the expression library so that expression writers can check for the likely condition where a non-required field is null).

If the variable name does not refer to an existing widget, null is returned (TODO: this behaviour will probably change in the future)

If the variable name contains the "/./" notation, it will return a Collection of values, using the WidgetFinder utility.

Specified by:
resolveVariable in interface org.outerj.expression.ExpressionContext

get

public Object get(String s)
Specified by:
get in interface org.outerj.expression.ExpressionContext


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.