fmpp.tdd
Interface EvaluationEnvironment

All Known Implementing Classes:
DataLoaderEvaluationEnvironment

public interface EvaluationEnvironment

Callbacks that let you control the behaviour of TDD expression evaluation.


Field Summary
static int EVENT_ENTER_FUNCTION_PARAMS
          The code of event that indicates that we have started to evaluate the parameter list in a function call.
static int EVENT_ENTER_HASH
          The code of event that indicates that we have started to evaluate the items in a hash.
static int EVENT_ENTER_HASH_KEY
          The code of event that indicates that we have started to evaluate the value in a key:value pair.
static int EVENT_ENTER_SEQUENCE
          The code of event that indicates that we have started to evaluate the items in a sequence.
static int EVENT_LEAVE_FUNCTION_PARAMS
          The code of event that indicates that we have finished to evaluate the parameter list in a function call.
static int EVENT_LEAVE_HASH
          The code of event that indicates that we have finished to evaluate the items in a sequence.
static int EVENT_LEAVE_HASH_KEY
          The code of event that indicates that we have finished to evaluate the value in a key:value pair.
static int EVENT_LEAVE_SEQUENCE
          The code of event that indicates that we have finished to evaluate the items in a sequence.
static java.lang.Object RETURN_FRAGMENT
           
static java.lang.Object RETURN_SKIP
           
 
Method Summary
 java.lang.Object evalFunctionCall(FunctionCall fc, Interpreter ip)
          Evaluates the function call.
 java.lang.Object notify(int event, Interpreter ip, java.lang.String name, java.lang.Object extra)
          Notifies about an event during expression evaluation.
 

Field Detail

EVENT_ENTER_HASH_KEY

static final int EVENT_ENTER_HASH_KEY
The code of event that indicates that we have started to evaluate the value in a key:value pair.

See Also:
Constant Field Values

EVENT_LEAVE_HASH_KEY

static final int EVENT_LEAVE_HASH_KEY
The code of event that indicates that we have finished to evaluate the value in a key:value pair.

See Also:
Constant Field Values

EVENT_ENTER_FUNCTION_PARAMS

static final int EVENT_ENTER_FUNCTION_PARAMS
The code of event that indicates that we have started to evaluate the parameter list in a function call.

See Also:
Constant Field Values

EVENT_LEAVE_FUNCTION_PARAMS

static final int EVENT_LEAVE_FUNCTION_PARAMS
The code of event that indicates that we have finished to evaluate the parameter list in a function call.

See Also:
Constant Field Values

EVENT_ENTER_SEQUENCE

static final int EVENT_ENTER_SEQUENCE
The code of event that indicates that we have started to evaluate the items in a sequence. This does not include function call parameter lists.

See Also:
Constant Field Values

EVENT_LEAVE_SEQUENCE

static final int EVENT_LEAVE_SEQUENCE
The code of event that indicates that we have finished to evaluate the items in a sequence.

See Also:
Constant Field Values

EVENT_ENTER_HASH

static final int EVENT_ENTER_HASH
The code of event that indicates that we have started to evaluate the items in a hash.

See Also:
Constant Field Values

EVENT_LEAVE_HASH

static final int EVENT_LEAVE_HASH
The code of event that indicates that we have finished to evaluate the items in a sequence.

See Also:
Constant Field Values

RETURN_SKIP

static final java.lang.Object RETURN_SKIP

RETURN_FRAGMENT

static final java.lang.Object RETURN_FRAGMENT
Method Detail

evalFunctionCall

java.lang.Object evalFunctionCall(FunctionCall fc,
                                  Interpreter ip)
                                  throws java.lang.Exception
Evaluates the function call. This method may simply returns its parameter, which means that the function was not resolved, and thus the function call will be availble for further interpretation in the result of the TDD expression evaluation.

Parameters:
fc - the function call to evaluate.
Returns:
the return value of the function call. During the evaluation of a TDD expression, function calls will be replaced with their return values. If the return value is a FunctionCall object, it will not be evaluated again. This way, the final result of a TDD expression evaluation can contain FunctionCall objects.
Throws:
java.lang.Exception

notify

java.lang.Object notify(int event,
                        Interpreter ip,
                        java.lang.String name,
                        java.lang.Object extra)
                        throws java.lang.Exception
Notifies about an event during expression evaluation.

Parameters:
event - An EVENT_... constant. Further events may will be added later, so the implementation must silently ignore events that it does not know. It is guaranteed that for each EVENT_ENTER_... event there will be an EVENT_LEAVE_... event later, except if notifyContextChange has thrown exception during handling EVENT_ENTER_..., in which case it is guaranteed that there will be no corresponding EVENT_LEAVE_... event.
ip - the Interpreter instance that evaluates the text. The value returned by Interpreter.getPosition() will be the position in the text where the this even has been created:
name - For EVENT_ENTER_HASH_KEY and EVENT_ENTER_FUNCTION_PARAMS, the name of the hash key or function. It is null otherwise.
extra - Even specific extra information.
Returns:
return The allowed return values and their meaning depends on the event. But return value null always means "do nothing special". The currently defiend non-null return values for the events:
  • EVENT_ENTER_HASH_KEY:
    • RETURN_SKIP: Skip the key:value pair. That is, the key:value pair will not be added to the map. The value expression will not be evaluated.
    • RETURN_FRAGMENT: The value of the key:value pair will be the Fragment that stores the value expression. The value expression will not be evaluated. However, if the value is implicit boolean true, (i.e. you omit the value) then RETURN_FRAGMENT has no effect.
  • EVENT_ENTER_HASH if the hash uses { and }):
    • RETURN_FRAGMENT: The value of the hash will be the Fragment that stores the hash expression. The hash expression will not be evaluated.
Throws:
java.lang.Exception