MetaDone
|
Classes | |
class | Abstract |
interface | ScriptResult |
Public Member Functions | |
void | declareVariable (String name, Object value) |
void | clearVariables () |
Properties | properties () |
ScriptResult | evaluate (String script) |
ProgLanguage | getLanguage () |
ScriptResult | initScriptEvaluate () |
void | reset () |
Evaluates a script with a given context.
Once an evaluator is created, it has its own context. This context may be changed by the calls to the set methods. From there, evaluate(String) works as a REPL (read-evaluate-print-loop).
A simple usage example:
ScriptResult r; ScriptEvaluator ev = ...; r = ev.evaluate("function abc(arg) { return arg + self; }"); if (r.isException()) throw new RuntimeException(r.getException()); r = ev.evaluate("a = 5 + 3"); System.out.println(r.getNumber()); // 8 ev.setSelf(1); r = ev.evaluate("abc(a)"); System.out.println(r.getNumber()); // 9
void metadone.metabusiness.script.ScriptEvaluator.clearVariables | ( | ) |
Removes all the previously declared variables.
Implemented in metadone.metabusiness.script.groovy.GroovyEvaluator, metadone.metabusiness.script.java.JavaScriptingEngine, metadone.metabusiness.script.js.JSEvaluator, and metadone.metabusiness.script.plugin.EventScriptEvaluator.
Referenced by metadone.client.grasyla2.GrasylaContext.initScriptEvaluator().
void metadone.metabusiness.script.ScriptEvaluator.declareVariable | ( | String | name, |
Object | value | ||
) |
Declares a new variable called name and sets it to value.
updateContext() should be called afterwards.
name | The name of the variable |
value | The new value |
NullPointerException | when name is null |
Implemented in metadone.metabusiness.script.groovy.GroovyEvaluator, metadone.metabusiness.script.java.JavaScriptingEngine, metadone.metabusiness.script.js.JSEvaluator, and metadone.metabusiness.script.plugin.EventScriptEvaluator.
Referenced by metadone.metabusiness.impl.ConcreteObject_impl.evaluateFormula(), metadone.client.grasyla2.GrasylaContext.initScriptEvaluator(), metadone.client.grasyla2.visuallibrary.GraphEngine.GrasylaContextGraph.initScriptEvaluatorGlobal(), and metadone.client.grasyla2.actions.GrasylaActionEngine.ActionContext.initScriptEvaluatorGlobal().
ScriptResult metadone.metabusiness.script.ScriptEvaluator.evaluate | ( | String | script | ) |
Evaluates a script and returns a result.
script | The script to evaluate |
NullPointerException | when script is null |
Implemented in metadone.metabusiness.script.java.JavaScriptingEngine, metadone.metabusiness.script.js.JSEvaluator, and metadone.metabusiness.script.plugin.EventScriptEvaluator.
Referenced by metadone.client.grasyla2.value.ValueScriptEngine.evaluateComponent(), metadone.metabusiness.impl.ConcreteObject_impl.evaluateFormula(), and metadone.client.grasyla2.GrasylaInterpreter.runInitScript().
ProgLanguage metadone.metabusiness.script.ScriptEvaluator.getLanguage | ( | ) |
Gets the evaluated language.
Implemented in metadone.metabusiness.script.java.JavaScriptingEngine, metadone.metabusiness.script.js.JSEvaluator, and metadone.metabusiness.script.plugin.EventScriptEvaluator.
Referenced by metadone.metabusiness.impl.ConcreteObject_impl.evaluateFormula().
ScriptResult metadone.metabusiness.script.ScriptEvaluator.initScriptEvaluate | ( | ) |
Evaluates the initialization script.
Implemented in metadone.metabusiness.script.groovy.GroovyEvaluator, and metadone.metabusiness.script.ScriptEvaluator.Abstract.
Referenced by metadone.client.grasyla2.GrasylaInterpreter.runInitScript().
Properties metadone.metabusiness.script.ScriptEvaluator.properties | ( | ) |
Gets the properties (modifications performed on the returned properties are reflected in this class).
Implemented in metadone.metabusiness.script.ScriptEvaluator.Abstract.
void metadone.metabusiness.script.ScriptEvaluator.reset | ( | ) |
Resets the script evaluator.
Implemented in metadone.metabusiness.script.java.JavaScriptingEngine, metadone.metabusiness.script.js.JSEvaluator, and metadone.metabusiness.script.plugin.EventScriptEvaluator.