public abstract class GroovyClosureScript
extends groovy.lang.Script
Script that performs method invocations and property access like Closure does.
For example, when the script is:
a = 1;
b(2);
Using GroovyClosureScript as the base class would run it as:
delegate.a = 1;
delegate.b(2);
... whereas in plain Script, this will be run as:
binding.setProperty("a",1);
((Closure)binding.getProperty("b")).call(2);
This is convenient for building DSL as you can use an external object to define
methods and properties.| Modifier | Constructor and Description |
|---|---|
protected |
GroovyClosureScript() |
protected |
GroovyClosureScript(groovy.lang.Binding binding) |
| Modifier and Type | Method and Description |
|---|---|
groovy.lang.GroovyObject |
getDelegate() |
Object |
getProperty(String property) |
Object |
invokeMethod(String name,
Object args) |
void |
setDelegate(groovy.lang.GroovyObject delegate)
Sets the delegation target.
|
void |
setProperty(String property,
Object newValue) |
protected GroovyClosureScript()
protected GroovyClosureScript(groovy.lang.Binding binding)
public void setDelegate(groovy.lang.GroovyObject delegate)
public groovy.lang.GroovyObject getDelegate()
public Object invokeMethod(String name, Object args)
invokeMethod in interface groovy.lang.GroovyObjectinvokeMethod in class groovy.lang.Scriptpublic Object getProperty(String property)
getProperty in interface groovy.lang.GroovyObjectgetProperty in class groovy.lang.ScriptCopyright © 2016. All Rights Reserved.