helper
field in your script. For example:public void apply() { helper.doSomeComputation(); }
CustomContext
class:public class CustomContext extends DefaultScriptContext { private final CustomHelper helper; public CustomContext() { helper = new CustomHelper(this); } public ScriptHelper getHelper() { return helper; } }And for the
CustomHelper
class:public class CustomHelper implements ScriptHelper { private final ScriptContext context; public CustomHelper(ScriptContext context) { this.context = context; } public double doSomeComputation(double angle) { return Math.sin(angle); }We can perform in a Script:
public void apply() { double result = helper.doSomeComputation(1.2d); context.echo(result); }
public class CustomHelper extends DefaultScriptHelper { public double doSomeComputation(double angle) { return Math.sin(angle); } }
public class ScriptHelper |
---|
Modifier and Type | Method and Description |
---|---|
ScriptContext | getContext()
Return the script context
|
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence