Package fmpp.tdd
Class DataLoaderEvaluationEnvironment
java.lang.Object
fmpp.tdd.DataLoaderEvaluationEnvironment
- All Implemented Interfaces:
EvaluationEnvironment
Evaluates function calls as data loader invocations.
-
Field Summary
Fields inherited from interface fmpp.tdd.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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionevalFunctionCall(FunctionCall fc, Interpreter ip) Evaluates the function call.protected ObjectfindTopLevelVariable(String name) Override this to help TDD get function to find top level variables.notify(int event, Interpreter ip, String name, Object extra) Notifies about an event during expression evaluation.
-
Constructor Details
-
DataLoaderEvaluationEnvironment
-
-
Method Details
-
evalFunctionCall
Description copied from interface:EvaluationEnvironmentEvaluates 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.- Specified by:
evalFunctionCallin interfaceEvaluationEnvironment- 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
FunctionCallobject, it will not be evaluated again. This way, the final result of a TDD expression evaluation can containFunctionCallobjects. - Throws:
Exception
-
findTopLevelVariable
Override this to help TDD get function to find top level variables. The default implementation finds top-level variables already created in the executing TDD expression, and then it tries to get the variable withEngine.getData(String).- Returns:
- the value of variable, or
nullif no variable with the given name exists.
-
notify
Description copied from interface:EvaluationEnvironmentNotifies about an event during expression evaluation.- Specified by:
notifyin interfaceEvaluationEnvironment- Parameters:
event- AnEVENT_...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 eachEVENT_ENTER_...event there will be anEVENT_LEAVE_...event later, except ifnotifyContextChangehas thrown exception during handlingEVENT_ENTER_..., in which case it is guaranteed that there will be no correspondingEVENT_LEAVE_...event.ip- theInterpreterinstance that evaluates the text. The value returned byInterpreter.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, andEvaluationEnvironment.EVENT_ENTER_FUNCTION_PARAMS: points the first character after the [ and ( respectively.EvaluationEnvironment.EVENT_LEAVE_SEQUENCE,EvaluationEnvironment.EVENT_LEAVE_HASH, andEvaluationEnvironment.EVENT_LEAVE_FUNCTION_PARAMS: points the terminating character, that is, the ] or ) or the character after the end of the string.
name- ForEvaluationEnvironment.EVENT_ENTER_HASH_KEYandEvaluationEnvironment.EVENT_ENTER_FUNCTION_PARAMS, the name of the hash key or function. It isnullotherwise.extra- Even specific extra information.- For
EvaluationEnvironment.EVENT_ENTER_HASH,EvaluationEnvironment.EVENT_LEAVE_HASH,EvaluationEnvironment.EVENT_ENTER_SEQUENCE,EvaluationEnvironment.EVENT_LEAVE_SEQUENCEit is theMaporListthat is being built by the hash or sequence. It's OK to modify thisMaporList. - For other events it's
value is currently
null.
- For
- Returns:
- return The allowed return values and their meaning depends on
the event. But return value
nullalways means "do nothing special". The currently defiend non-nullreturn 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 theFragmentthat stores the value expression. The value expression will not be evaluated. However, if the value is implicit booleantrue, (i.e. you omit the value) thenEvaluationEnvironment.RETURN_FRAGMENThas no effect.
EvaluationEnvironment.EVENT_ENTER_HASHif the hash uses { and }):EvaluationEnvironment.RETURN_FRAGMENT: The value of the hash will be theFragmentthat stores the hash expression. The hash expression will not be evaluated.
-