Top Description Fields Constructors Methods
groovy.lang

public abstract Class Script

extends GroovyObjectSupport
Class Inheritance
Known Direct Subclasses
groovy.util.DelegatingScript, org.codehaus.groovy.runtime.InvokerHelper.NullScript, org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingDSL
Imports
org.codehaus.groovy.ast.expr.ArgumentListExpression, org.codehaus.groovy.ast.tools.GeneralUtils, org.codehaus.groovy.control.CompilationFailedException, org.codehaus.groovy.runtime.DefaultGroovyMethods, .InvokerHelper, java.io.File, .IOException, java.lang.reflect.Method

This object represents a Groovy script

Field Summary

Modifier and TypeField and Description
private Binding

Constructor Summary

AccessConstructor and Description
protected
protected
Script(Binding binding)

Method Summary

Modifier and TypeMethod and Description
public Object
evaluate(String
is the Groovy script expression to evaluate
expression
)

A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

public Object
evaluate(File
is the Groovy script to evaluate
file
)

A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

public Binding
public Object
getProperty(String
the name of the property of interest
property
)

Overrides default groovy.lang.GroovyObject.getProperty.

Retrieves a property value.
private boolean
public Object

Returns:

value
invokeMethod
(String
method to call
name
,
Object
arguments to pass to the method
args
)

Overrides default groovy.lang.GroovyObject.invokeMethod.

Invoke a method (or closure in the binding) defined.
public void
printf(String
the format to follow
format
,
Object
the value to be formatted
value
)

Prints a formatted string using the specified format string and argument.

public void
printf(String
the format to follow
format
,
Object[]
an array of values to be formatted
values
)

Prints a formatted string using the specified format string and arguments.

public void
println()

Prints a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it.

public void
println(Object value)

Prints the value and a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it.

public abstract Object
run()

The main instance method of a script which has variables in scope as defined by the current Binding instance.

public void
run(File file, String[] arguments)

A helper method to allow scripts to be run taking command line arguments

public void
public void
setProperty(String
the name of the property of interest
property
,
Object
the new value for the property
newValue
)

Overrides default groovy.lang.GroovyObject.setProperty.

Sets the given property to the new value.
Inherited from groovy.lang.GroovyObjectSupport:
getMetaClasssetMetaClass

Field Detail

bindingback to summary
private Binding binding

Constructor Detail

Scriptback to summary
protected Script()
Scriptback to summary
protected Script(Binding binding)

Method Detail

evaluateback to summary
public Object evaluate(String expression) throws CompilationFailedException

A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

Parameters
expression:String

is the Groovy script expression to evaluate

evaluateback to summary
public Object evaluate(File file) throws CompilationFailedException, IOException

A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

Parameters
file:File

is the Groovy script to evaluate

getBindingback to summary
public Binding getBinding()
getPropertyback to summary
public Object getProperty(String property)

Overrides default groovy.lang.GroovyObject.getProperty.

Doc from groovy.lang.GroovyObject.getProperty.

Retrieves a property value.

Parameters
property:String

the name of the property of interest

Returns:Object

the given property

hasSetterMethodForback to summary
private boolean hasSetterMethodFor(String property)
invokeMethodback to summary
public Object invokeMethod(String name, Object args)

Overrides default groovy.lang.GroovyObject.invokeMethod.

Invoke a method (or closure in the binding) defined.

Parameters
name:String

method to call

args:Object

arguments to pass to the method

Returns:Object

value

printfback to summary
public void printf(String format, Object value)

Prints a formatted string using the specified format string and argument.

Parameters
format:String

the format to follow

value:Object

the value to be formatted

printfback to summary
public void printf(String format, Object[] values)

Prints a formatted string using the specified format string and arguments.

Parameters
format:String

the format to follow

values:Object[]

an array of values to be formatted

printlnback to summary
public void println()

Prints a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it. If there is no 'out' property then print to standard out.

printlnback to summary
public void println(Object value)

Prints the value and a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it. If there is no 'out' property then print to standard out.

runback to summary
public abstract Object run()

The main instance method of a script which has variables in scope as defined by the current Binding instance.

runback to summary
public void run(File file, String[] arguments) throws CompilationFailedException, IOException

A helper method to allow scripts to be run taking command line arguments

setBindingback to summary
public void setBinding(Binding binding)
setPropertyback to summary
public void setProperty(String property, Object newValue)

Overrides default groovy.lang.GroovyObject.setProperty.

Doc from groovy.lang.GroovyObject.setProperty.

Sets the given property to the new value.

Parameters
property:String

the name of the property of interest

newValue:Object

the new value for the property