public class GroovyShell extends GroovyObjectSupport
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CODE_BASE |
Constructor and Description |
---|
GroovyShell() |
GroovyShell(Binding binding) |
GroovyShell(Binding binding,
CompilerConfiguration config) |
GroovyShell(ClassLoader parent) |
GroovyShell(ClassLoader parent,
Binding binding) |
GroovyShell(ClassLoader parent,
Binding binding,
CompilerConfiguration config) |
GroovyShell(CompilerConfiguration config) |
GroovyShell(GroovyShell shell)
Creates a child shell using a new ClassLoader which uses the parent shell's
class loader as its parent
|
Modifier and Type | Method and Description |
---|---|
Object |
evaluate(File file)
Evaluates some script against the current Binding and returns the result
|
Object |
evaluate(GroovyCodeSource codeSource)
Evaluates some script against the current Binding and returns the result
|
Object |
evaluate(Reader in)
Evaluates some script against the current Binding and returns the result
|
Object |
evaluate(Reader in,
String fileName)
Evaluates some script against the current Binding and returns the result
|
Object |
evaluate(String scriptText)
Evaluates some script against the current Binding and returns the result
|
Object |
evaluate(String scriptText,
String fileName)
Evaluates some script against the current Binding and returns the result
|
Object |
evaluate(String scriptText,
String fileName,
String codeBase)
Evaluates some script against the current Binding and returns the result.
|
protected String |
generateScriptName() |
GroovyClassLoader |
getClassLoader() |
Binding |
getContext() |
Object |
getProperty(String property)
Retrieves a property value.
|
Object |
getVariable(String name) |
static void |
main(String[] args) |
Script |
parse(File file)
Parses the given script and returns it ready to be run
|
Script |
parse(GroovyCodeSource codeSource)
Parses the given script and returns it ready to be run.
|
Script |
parse(Reader in)
Parses the given script and returns it ready to be run
|
Script |
parse(Reader reader,
String fileName)
Parses the given script and returns it ready to be run
|
Script |
parse(String scriptText)
Parses the given script and returns it ready to be run
|
Script |
parse(String scriptText,
String fileName) |
void |
resetLoadedClasses() |
Object |
run(File scriptFile,
List list)
A helper method which runs the given script file with the given command line arguments
|
Object |
run(File scriptFile,
String[] args)
Runs the given script file name with the given command line arguments
|
Object |
run(Reader in,
String fileName,
String[] args)
Runs the given script with command line arguments
|
Object |
run(String scriptText,
String fileName,
List list)
A helper method which runs the given cl script with the given command line arguments
|
Object |
run(String scriptText,
String fileName,
String[] args)
Runs the given script text with command line arguments
|
void |
setProperty(String property,
Object newValue)
Sets the given property to the new value.
|
void |
setVariable(String name,
Object value) |
getMetaClass, invokeMethod, setMetaClass
public static final String DEFAULT_CODE_BASE
public GroovyShell()
public GroovyShell(Binding binding)
public GroovyShell(CompilerConfiguration config)
public GroovyShell(Binding binding, CompilerConfiguration config)
public GroovyShell(ClassLoader parent, Binding binding)
public GroovyShell(ClassLoader parent)
public GroovyShell(ClassLoader parent, Binding binding, CompilerConfiguration config)
public GroovyShell(GroovyShell shell)
shell
- is the parent shell used for the variable bindings and the parent class loaderpublic static void main(String[] args)
public void resetLoadedClasses()
public Binding getContext()
public GroovyClassLoader getClassLoader()
public Object getProperty(String property)
GroovyObject
getProperty
in interface GroovyObject
getProperty
in class GroovyObjectSupport
property
- the name of the property of interestpublic void setProperty(String property, Object newValue)
GroovyObject
setProperty
in interface GroovyObject
setProperty
in class GroovyObjectSupport
property
- the name of the property of interestnewValue
- the new value for the propertypublic Object run(File scriptFile, List list) throws CompilationFailedException, IOException
scriptFile
- the file of the script to runlist
- the command line arguments to pass inCompilationFailedException
IOException
public Object run(String scriptText, String fileName, List list) throws CompilationFailedException
scriptText
- is the text content of the scriptfileName
- is the logical file name of the script (which is used to create the class name of the script)list
- the command line arguments to pass inCompilationFailedException
public Object run(File scriptFile, String[] args) throws CompilationFailedException, IOException
scriptFile
- the file name of the script to runargs
- the command line arguments to pass inCompilationFailedException
IOException
public Object run(String scriptText, String fileName, String[] args) throws CompilationFailedException
scriptText
- is the text content of the scriptfileName
- is the logical file name of the script (which is used to create the class name of the script)args
- the command line arguments to pass inCompilationFailedException
public Object run(Reader in, String fileName, String[] args) throws CompilationFailedException
in
- the stream reading the scriptfileName
- is the logical file name of the script (which is used to create the class name of the script)args
- the command line arguments to pass inCompilationFailedException
public Object evaluate(GroovyCodeSource codeSource) throws CompilationFailedException
codeSource
- CompilationFailedException
public Object evaluate(String scriptText) throws CompilationFailedException
scriptText
- the text of the scriptCompilationFailedException
public Object evaluate(String scriptText, String fileName) throws CompilationFailedException
scriptText
- the text of the scriptfileName
- is the logical file name of the script (which is used to create the class name of the script)CompilationFailedException
public Object evaluate(String scriptText, String fileName, String codeBase) throws CompilationFailedException
CompilationFailedException
public Object evaluate(File file) throws CompilationFailedException, IOException
file
- is the file of the script (which is used to create the class name of the script)CompilationFailedException
IOException
public Object evaluate(Reader in) throws CompilationFailedException
in
- the stream reading the scriptCompilationFailedException
public Object evaluate(Reader in, String fileName) throws CompilationFailedException
in
- the stream reading the scriptfileName
- is the logical file name of the script (which is used to create the class name of the script)CompilationFailedException
public Script parse(Reader reader, String fileName) throws CompilationFailedException
reader
- the stream reading the scriptfileName
- is the logical file name of the script (which is used to create the class name of the script)Script.run()
CompilationFailedException
public Script parse(GroovyCodeSource codeSource) throws CompilationFailedException
codeSource
- CompilationFailedException
public Script parse(File file) throws CompilationFailedException, IOException
file
- is the file of the script (which is used to create the class name of the script)CompilationFailedException
IOException
public Script parse(String scriptText) throws CompilationFailedException
scriptText
- the text of the scriptCompilationFailedException
public Script parse(String scriptText, String fileName) throws CompilationFailedException
CompilationFailedException
public Script parse(Reader in) throws CompilationFailedException
in
- the stream reading the scriptCompilationFailedException
protected String generateScriptName()