Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.10
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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: 21030 \$

Field Summary
`static String` | `DEFAULT_CODE_BASE`
`static String[]` | `EMPTY_ARGS`

Constructor Summary
`GroovyShell()`
`GroovyShell(Binding binding)`
`GroovyShell(CompilerConfiguration config)`
`GroovyShell(Binding binding, CompilerConfiguration config)`
`GroovyShell(ClassLoader parent, Binding binding)`
`GroovyShell(ClassLoader parent)`
`GroovyShell(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
`Object` | `evaluate(GroovyCodeSource codeSource)` 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.
`Object` | `evaluate(File file)` 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(InputStream in)` Evaluates some script against the current Binding and returns the result
`Object` | `evaluate(InputStream in, String fileName)` Evaluates some script against the current Binding and returns the result
`protected String` | `generateScriptName()`
`GroovyClassLoader` | `getClassLoader()`
`Binding` | `getContext()`
`Object` | `getProperty(String property)`
`Object` | `getVariable(String name)`
`void` | `initializeBinding()`
`static void` | `main(String[] args)`
`Script` | `parse(Reader reader, String fileName)` Parses the given script and returns it ready to be run
`Script` | `parse(InputStream in, 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(File file)` 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)`
`Script` | `parse(Reader in)` Parses the given script and returns it ready to be run
`Script` | `parse(InputStream in)` Parses the given script and returns it ready to be run
`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(String scriptText, String fileName, List list)` A helper method which runs the given cl script 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(String scriptText, String fileName, String[] args)` Runs the given script text with command line arguments
`Object` | `run(Reader in, String fileName, String[] args)` Runs the given script with command line arguments
`Object` | `run(InputStream in, String fileName, String[] args)` Runs the given script with command line arguments
`void` | `setProperty(String property, Object newValue)`
`void` | `setVariable(String name, Object value)`

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

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Field Detail

### DEFAULT_CODE_BASE

    public static final String DEFAULT_CODE_BASE

### EMPTY_ARGS

    @Deprecated
    public static final String[] EMPTY_ARGS

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(ClassLoader parent, Binding binding)

### GroovyShell

    public GroovyShell(ClassLoader parent)

### GroovyShell

    public GroovyShell(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 Object evaluate(GroovyCodeSource codeSource)

  Evaluates some script against the current Binding and returns the result
  throws:
    CompilationFailedException
  Parameters:
    codeSource

### evaluate

    public Object evaluate(String scriptText)

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

### evaluate

    public Object evaluate(String scriptText, String fileName)

  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)

### evaluate

    public Object evaluate(String scriptText, String fileName, String codeBase)

  Evaluates some script against the current Binding and returns the result. The .class file created from the script is given the supplied codeBase

### evaluate

    public Object evaluate(File file)

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

### evaluate

    public Object evaluate(Reader in)

  Evaluates some script against the current Binding and returns the result
  Parameters:
    `in` - the stream reading the script

### evaluate

    public Object evaluate(Reader in, String fileName)

  Evaluates some script against the current Binding and returns the result
  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)

### evaluate

    public Object evaluate(InputStream in)

  Evaluates some script against the current Binding and returns the result
  deprecated:
    Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues.
  Parameters:
    `in` - the stream reading the script

### evaluate

    public Object evaluate(InputStream in, String fileName)

  Evaluates some script against the current Binding and returns the result
  deprecated:
    Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues.
  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)

### generateScriptName

    protected String generateScriptName()

### getClassLoader

    public GroovyClassLoader getClassLoader()

### getContext

    public Binding getContext()

### getProperty

    public Object getProperty(String property)

### getVariable

    public Object getVariable(String name)

### initializeBinding

    @Deprecated
    public void initializeBinding()

### main

    public static void main(String[] args)

### parse

    public Script parse(Reader reader, String fileName)

  Parses the given script and returns it ready to be run
  link:
    Script.run()
  Parameters:
    `reader` - 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)
  Returns:
    the parsed script which is ready to be run via

### parse

    public Script parse(InputStream in, String fileName)

  Parses the given script and returns it ready to be run
  link:
    Script.run()
  deprecated:
    Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues.
  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)
  Returns:
    the parsed script which is ready to be run via

### parse

    public Script parse(GroovyCodeSource codeSource)

  Parses the given script and returns it ready to be run. When running in a secure environment (-Djava.security.manager) codeSource.getCodeSource() determines what policy grants should be given to the script.
  Parameters:
    codeSource
  Returns:
    ready to run script

### parse

    public Script parse(File file)

  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(String scriptText)

  Parses the given script and returns it ready to be run
  Parameters:
    `scriptText` - the text of the script

### parse

    public Script parse(String scriptText, String fileName)

### parse

    public Script parse(Reader in)

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

### parse

    public Script parse(InputStream in)

  Parses the given script and returns it ready to be run
  deprecated:
    Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues.
  Parameters:
    `in` - the stream reading the script

### resetLoadedClasses

    public void resetLoadedClasses()

### run

    public Object run(File scriptFile, 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 Object run(String scriptText, String fileName, 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 Object run(File scriptFile, 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 Object run(String scriptText, String fileName, String[] args)

  Runs the given script text with 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)
    `args` - the command line arguments to pass in

### run

    public Object run(Reader in, String fileName, 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 Object run(InputStream in, String fileName, String[] args)

  Runs the given script with command line arguments
  deprecated:
    Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues.
  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

### setProperty

    public void setProperty(String property, Object newValue)

### setVariable

    public void setVariable(String name, Object value)

Copyright © 2003-2010 The Codehaus. All rights reserved.