public class GroovyShell extends GroovyObjectSupport
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CODE_BASE |
Constructor and Description |
---|
GroovyShell() |
GroovyShell(Binding binding) |
GroovyShell(Binding binding,
CompilerConfiguration config) |
GroovyShell(java.lang.ClassLoader parent) |
GroovyShell(java.lang.ClassLoader parent,
Binding binding) |
GroovyShell(java.lang.ClassLoader parent,
Binding binding,
CompilerConfiguration config) |
GroovyShell(java.lang.ClassLoader parent,
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 |
---|---|
java.lang.Object |
evaluate(java.io.File file)
Evaluates some script against the current Binding and returns the result
|
java.lang.Object |
evaluate(GroovyCodeSource codeSource)
Evaluates some script against the current Binding and returns the result
|
java.lang.Object |
evaluate(java.io.Reader in)
Evaluates some script against the current Binding and returns the result
|
java.lang.Object |
evaluate(java.io.Reader in,
java.lang.String fileName)
Evaluates some script against the current Binding and returns the result
|
java.lang.Object |
evaluate(java.lang.String scriptText)
Evaluates some script against the current Binding and returns the result
|
java.lang.Object |
evaluate(java.lang.String scriptText,
java.lang.String fileName)
Evaluates some script against the current Binding and returns the result
|
java.lang.Object |
evaluate(java.lang.String scriptText,
java.lang.String fileName,
java.lang.String codeBase)
Evaluates some script against the current Binding and returns the result.
|
java.lang.Object |
evaluate(java.net.URI uri)
Evaluates some script against the current Binding and returns the result
|
protected java.lang.String |
generateScriptName() |
GroovyClassLoader |
getClassLoader() |
Binding |
getContext() |
java.lang.Object |
getProperty(java.lang.String property)
Retrieves a property value.
|
java.lang.Object |
getVariable(java.lang.String name) |
static void |
main(java.lang.String[] args) |
Script |
parse(java.io.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(java.io.Reader in)
Parses the given script and returns it ready to be run
|
Script |
parse(java.io.Reader reader,
java.lang.String fileName)
Parses the given script and returns it ready to be run
|
Script |
parse(java.lang.String scriptText)
Parses the given script and returns it ready to be run
|
Script |
parse(java.lang.String scriptText,
java.lang.String fileName) |
Script |
parse(java.net.URI uri)
Parses the given script and returns it ready to be run
|
void |
resetLoadedClasses() |
java.lang.Object |
run(java.io.File scriptFile,
java.util.List list)
A helper method which runs the given script file with the given command line arguments
|
java.lang.Object |
run(java.io.File scriptFile,
java.lang.String[] args)
Runs the given script file name with the given command line arguments
|
java.lang.Object |
run(GroovyCodeSource source,
java.util.List args)
Runs the given script source with command line arguments
|
java.lang.Object |
run(GroovyCodeSource source,
java.lang.String[] args)
Runs the given script source with command line arguments
|
java.lang.Object |
run(java.io.Reader in,
java.lang.String fileName,
java.util.List list)
Runs the given script with command line arguments
|
java.lang.Object |
run(java.io.Reader in,
java.lang.String fileName,
java.lang.String[] args)
Runs the given script with command line arguments
|
java.lang.Object |
run(java.lang.String scriptText,
java.lang.String fileName,
java.util.List list)
A helper method which runs the given cl script with the given command line arguments
|
java.lang.Object |
run(java.lang.String scriptText,
java.lang.String fileName,
java.lang.String[] args)
Runs the given script text with command line arguments
|
java.lang.Object |
run(java.net.URI source,
java.util.List args)
Runs the given script source with command line arguments
|
java.lang.Object |
run(java.net.URI source,
java.lang.String[] args)
Runs the given script source with command line arguments
|
void |
setProperty(java.lang.String property,
java.lang.Object newValue)
Sets the given property to the new value.
|
void |
setVariable(java.lang.String name,
java.lang.Object value) |
getMetaClass, invokeMethod, setMetaClass
public static final java.lang.String DEFAULT_CODE_BASE
public GroovyShell()
public GroovyShell(Binding binding)
public GroovyShell(java.lang.ClassLoader parent, CompilerConfiguration config)
public GroovyShell(CompilerConfiguration config)
public GroovyShell(Binding binding, CompilerConfiguration config)
public GroovyShell(java.lang.ClassLoader parent, Binding binding)
public GroovyShell(java.lang.ClassLoader parent)
public GroovyShell(java.lang.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(java.lang.String[] args)
public void resetLoadedClasses()
public Binding getContext()
public GroovyClassLoader getClassLoader()
public java.lang.Object getProperty(java.lang.String property)
GroovyObject
getProperty
in interface GroovyObject
getProperty
in class GroovyObjectSupport
property
- the name of the property of interestpublic void setProperty(java.lang.String property, java.lang.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 java.lang.Object run(java.io.File scriptFile, java.util.List list) throws CompilationFailedException, java.io.IOException
scriptFile
- the file of the script to runlist
- the command line arguments to pass inCompilationFailedException
java.io.IOException
public java.lang.Object run(java.lang.String scriptText, java.lang.String fileName, java.util.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 java.lang.Object run(java.io.File scriptFile, java.lang.String[] args) throws CompilationFailedException, java.io.IOException
scriptFile
- the file name of the script to runargs
- the command line arguments to pass inCompilationFailedException
java.io.IOException
public java.lang.Object run(java.lang.String scriptText, java.lang.String fileName, java.lang.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 java.lang.Object run(GroovyCodeSource source, java.util.List args) throws CompilationFailedException
source
- is the source content of the scriptargs
- the command line arguments to pass inCompilationFailedException
public java.lang.Object run(GroovyCodeSource source, java.lang.String[] args) throws CompilationFailedException
source
- is the source content of the scriptargs
- the command line arguments to pass inCompilationFailedException
public java.lang.Object run(java.net.URI source, java.util.List args) throws CompilationFailedException, java.io.IOException
source
- is the source content of the scriptargs
- the command line arguments to pass inCompilationFailedException
java.io.IOException
public java.lang.Object run(java.net.URI source, java.lang.String[] args) throws CompilationFailedException, java.io.IOException
source
- is the source content of the scriptargs
- the command line arguments to pass inCompilationFailedException
java.io.IOException
public java.lang.Object run(java.io.Reader in, java.lang.String fileName, java.util.List list) 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)list
- the command line arguments to pass inCompilationFailedException
public java.lang.Object run(java.io.Reader in, java.lang.String fileName, java.lang.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 java.lang.Object getVariable(java.lang.String name)
public void setVariable(java.lang.String name, java.lang.Object value)
public java.lang.Object evaluate(GroovyCodeSource codeSource) throws CompilationFailedException
codeSource
- CompilationFailedException
public java.lang.Object evaluate(java.lang.String scriptText) throws CompilationFailedException
scriptText
- the text of the scriptCompilationFailedException
public java.lang.Object evaluate(java.lang.String scriptText, java.lang.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 java.lang.Object evaluate(java.lang.String scriptText, java.lang.String fileName, java.lang.String codeBase) throws CompilationFailedException
CompilationFailedException
public java.lang.Object evaluate(java.io.File file) throws CompilationFailedException, java.io.IOException
file
- is the file of the script (which is used to create the class name of the script)CompilationFailedException
java.io.IOException
public java.lang.Object evaluate(java.net.URI uri) throws CompilationFailedException, java.io.IOException
uri
- is the URI of the script (which is used to create the class name of the script)CompilationFailedException
java.io.IOException
public java.lang.Object evaluate(java.io.Reader in) throws CompilationFailedException
in
- the stream reading the scriptCompilationFailedException
public java.lang.Object evaluate(java.io.Reader in, java.lang.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(java.io.Reader reader, java.lang.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(java.io.File file) throws CompilationFailedException, java.io.IOException
file
- is the file of the script (which is used to create the class name of the script)CompilationFailedException
java.io.IOException
public Script parse(java.net.URI uri) throws CompilationFailedException, java.io.IOException
uri
- is the URI of the script (which is used to create the class name of the script)CompilationFailedException
java.io.IOException
public Script parse(java.lang.String scriptText) throws CompilationFailedException
scriptText
- the text of the scriptCompilationFailedException
public Script parse(java.lang.String scriptText, java.lang.String fileName) throws CompilationFailedException
CompilationFailedException
public Script parse(java.io.Reader in) throws CompilationFailedException
in
- the stream reading the scriptCompilationFailedException
protected java.lang.String generateScriptName()