Groovy Documentation

## groovy.lang
[Java] Class GroovyShell

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          groovy.lang.GroovyShell

    public class GroovyShell
    extends GroovyObjectSupport

Represents a groovy shell capable of running arbitrary groovy scripts

Authors:
  James Strachan
  Guillaume Laforge
  Paul King

Version:
  \$Revision\$

Field Summary
`static java.lang.String` | `DEFAULT_CODE_BASE`

Constructor Summary
`GroovyShell()`
`GroovyShell(Binding binding)`
`GroovyShell(CompilerConfiguration config)`
`GroovyShell(Binding binding, CompilerConfiguration config)`
`GroovyShell(java.lang.ClassLoader parent, Binding binding)`
`GroovyShell(java.lang.ClassLoader parent)`
`GroovyShell(java.lang.ClassLoader parent, Binding binding, CompilerConfiguration config)`
`GroovyShell(GroovyShell shell)` Creates a child shell using a new ClassLoader which uses the parent shell's class loader as its parent

Method Summary
`java.lang.Object` | `evaluate(GroovyCodeSource codeSource)`
`java.lang.Object` | `evaluate(java.lang.String scriptText)`
`java.lang.Object` | `evaluate(java.lang.String scriptText, java.lang.String fileName)`
`java.lang.Object` | `evaluate(java.lang.String scriptText, java.lang.String fileName, java.lang.String codeBase)`
`java.lang.Object` | `evaluate(java.io.File file)`
`java.lang.Object` | `evaluate(java.io.Reader in)`
`java.lang.Object` | `evaluate(java.io.Reader in, java.lang.String fileName)`
`protected java.lang.String` | `generateScriptName()`
`GroovyClassLoader` | `getClassLoader()`
`Binding` | `getContext()`
`java.lang.Object` | `getProperty(java.lang.String property)`
`java.lang.Object` | `getVariable(java.lang.String name)` Evaluates some script against the current Binding and returns the result
`static void` | `main(java.lang.String[] args)`
`Script` | `parse(java.io.Reader reader, java.lang.String fileName)` 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.File file)`
`Script` | `parse(java.lang.String scriptText)`
`Script` | `parse(java.lang.String scriptText, java.lang.String fileName)`
`Script` | `parse(java.io.Reader in)`
`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.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.io.File scriptFile, java.lang.String[] args)` Runs the given script file name 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 with command line arguments
`java.lang.Object` | `run(java.io.Reader in, java.lang.String fileName, java.lang.String[] args)` Evaluates some script against the current Binding and returns the result
`void` | `setProperty(java.lang.String property, java.lang.Object newValue)`
`void` | `setVariable(java.lang.String name, java.lang.Object value)`

Methods inherited from class GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### DEFAULT_CODE_BASE

    public static final java.lang.String DEFAULT_CODE_BASE

Constructor Detail

### GroovyShell

    public GroovyShell()

### GroovyShell

    public GroovyShell(Binding binding)

### GroovyShell

    public GroovyShell(CompilerConfiguration config)

### GroovyShell

    public GroovyShell(Binding binding, CompilerConfiguration config)

### GroovyShell

    public GroovyShell(java.lang.ClassLoader parent, Binding binding)

### GroovyShell

    public GroovyShell(java.lang.ClassLoader parent)

### GroovyShell

    public GroovyShell(java.lang.ClassLoader parent, Binding binding, CompilerConfiguration config)

### GroovyShell

    public GroovyShell(GroovyShell shell)

  Creates a child shell using a new ClassLoader which uses the parent shell's class loader as its parent
  Parameters:
    `shell` - is the parent shell used for the variable bindings and the parent class loader

Method Detail

### evaluate

    public java.lang.Object evaluate(GroovyCodeSource codeSource)

### evaluate

    public java.lang.Object evaluate(java.lang.String scriptText)

### evaluate

    public java.lang.Object evaluate(java.lang.String scriptText, java.lang.String fileName)

### evaluate

    public java.lang.Object evaluate(java.lang.String scriptText, java.lang.String fileName, java.lang.String codeBase)

### evaluate

    public java.lang.Object evaluate(java.io.File file)

### evaluate

    public java.lang.Object evaluate(java.io.Reader in)

### evaluate

    public java.lang.Object evaluate(java.io.Reader in, java.lang.String fileName)

### generateScriptName

    protected java.lang.String generateScriptName()

### getClassLoader

    public GroovyClassLoader getClassLoader()

### getContext

    public Binding getContext()

### getProperty

    public java.lang.Object getProperty(java.lang.String property)

### getVariable

    public java.lang.Object getVariable(java.lang.String name)

  Evaluates some script against the current Binding and returns the result
  Parameters:
    `scriptText` - the text of the script
    `fileName` - is the logical file name of the script (which is used to create the class name of the script)

### main

    public static void main(java.lang.String[] args)

### parse

    public Script parse(java.io.Reader reader, java.lang.String fileName)

  Parses the given script and returns it ready to be run
  Parameters:
    `file` - is the file of the script (which is used to create the class name of the script)

### parse

    public Script parse(GroovyCodeSource codeSource)

  Parses the given script and returns it ready to be run
  Parameters:
    `in` - the stream reading the script

### parse

    public Script parse(java.io.File file)

### parse

    public Script parse(java.lang.String scriptText)

### parse

    public Script parse(java.lang.String scriptText, java.lang.String fileName)

### parse

    public Script parse(java.io.Reader in)

### resetLoadedClasses

    public void resetLoadedClasses()

### run

    public 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
  Parameters:
    `scriptFile` - the file of the script to run
    `list` - the command line arguments to pass in

### run

    public 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
  Parameters:
    `scriptText` - is the text content of the script
    `fileName` - 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 in

### run

    public java.lang.Object run(java.io.File scriptFile, java.lang.String[] args)

  Runs the given script file name with the given command line arguments
  Parameters:
    `scriptFile` - the file name of the script to run
    `args` - the command line arguments to pass in

### run

    public java.lang.Object run(java.lang.String scriptText, java.lang.String fileName, java.lang.String[] args)

  Runs the given script with command line arguments
  Parameters:
    `in` - the stream reading the script
    `fileName` - 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 in

### run

    public java.lang.Object run(java.io.Reader in, java.lang.String fileName, java.lang.String[] args)

  Evaluates some script against the current Binding and returns the result
  Parameters:
    `scriptText` - the text of the script

### setProperty

    public void setProperty(java.lang.String property, java.lang.Object newValue)

### setVariable

    public void setVariable(java.lang.String name, java.lang.Object value)

Groovy Documentation