public class DataLoaderEvaluationEnvironment extends java.lang.Object implements EvaluationEnvironment
EVENT_ENTER_FUNCTION_PARAMS, EVENT_ENTER_HASH, EVENT_ENTER_HASH_KEY, EVENT_ENTER_SEQUENCE, EVENT_LEAVE_FUNCTION_PARAMS, EVENT_LEAVE_HASH, EVENT_LEAVE_HASH_KEY, EVENT_LEAVE_SEQUENCE, RETURN_FRAGMENT, RETURN_SKIP
Constructor and Description |
---|
DataLoaderEvaluationEnvironment(Engine eng) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
evalFunctionCall(FunctionCall fc,
Interpreter ip)
Evaluates the function call.
|
protected java.lang.Object |
findTopLevelVariable(java.lang.String name)
Override this to help TDD get function to find top level
variables.
|
java.lang.Object |
notify(int event,
Interpreter ip,
java.lang.String name,
java.lang.Object extra)
Notifies about an event during expression evaluation.
|
public DataLoaderEvaluationEnvironment(Engine eng)
public java.lang.Object evalFunctionCall(FunctionCall fc, Interpreter ip) throws java.lang.Exception
EvaluationEnvironment
evalFunctionCall
in interface EvaluationEnvironment
fc
- the function call to evaluate.FunctionCall
object, it will not be
evaluated again. This way, the final result of a TDD expression
evaluation can contain FunctionCall
objects.java.lang.Exception
protected java.lang.Object findTopLevelVariable(java.lang.String name)
Engine.getData(String)
.null
if no variable
with the given name exists.public java.lang.Object notify(int event, Interpreter ip, java.lang.String name, java.lang.Object extra)
EvaluationEnvironment
notify
in interface EvaluationEnvironment
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:
EvaluationEnvironment.EVENT_ENTER_HASH_KEY
: points the first character
of the value of the key:value pair.
EvaluationEnvironment.EVENT_ENTER_SEQUENCE
, EvaluationEnvironment.EVENT_ENTER_HASH
, and
EvaluationEnvironment.EVENT_ENTER_FUNCTION_PARAMS
: points the first
character after the [ and ( respectively.
EvaluationEnvironment.EVENT_LEAVE_SEQUENCE
, EvaluationEnvironment.EVENT_LEAVE_HASH
, and
EvaluationEnvironment.EVENT_LEAVE_FUNCTION_PARAMS
: points the
terminating character, that is, the ] or )
or the character after the end of the string.
name
- For EvaluationEnvironment.EVENT_ENTER_HASH_KEY
and
EvaluationEnvironment.EVENT_ENTER_FUNCTION_PARAMS
, the name of the hash key or
function. It is null
otherwise.extra
- Even specific extra information.
EvaluationEnvironment.EVENT_ENTER_HASH
, EvaluationEnvironment.EVENT_LEAVE_HASH
,
EvaluationEnvironment.EVENT_ENTER_SEQUENCE
, EvaluationEnvironment.EVENT_LEAVE_SEQUENCE
it
is the Map
or List
that is being
built by the hash or sequence. It's OK to modify this
Map
or List
.
null
.
null
always means
"do nothing special". The currently defiend non-null
return values for the events:
EvaluationEnvironment.EVENT_ENTER_HASH_KEY
:
EvaluationEnvironment.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.
EvaluationEnvironment.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
EvaluationEnvironment.RETURN_FRAGMENT
has no effect.
EvaluationEnvironment.EVENT_ENTER_HASH
if the hash uses { and
}):
EvaluationEnvironment.RETURN_FRAGMENT
: The value of the hash will be
the Fragment
that stores the hash expression.
The hash expression will not be evaluated.