groovy.lang
Class GroovyShell

java.lang.Object
  |
  +--groovy.lang.GroovyObjectSupport
        |
        +--groovy.lang.GroovyShell
All Implemented Interfaces:
GroovyObject

public class GroovyShell
extends GroovyObjectSupport

Represents a groovy shell capable of running arbitrary groovy scripts

Version:
$Revision: 1.11 $
Author:
James Strachan

Field Summary
static String[] EMPTY_ARGS
           
 
Constructor Summary
GroovyShell()
           
GroovyShell(ClassLoader parent, groovy.lang.ScriptContext binding)
           
GroovyShell(groovy.lang.ScriptContext binding)
           
 
Method Summary
 Object evaluate(InputStream in, String fileName)
          Evaluates some script against the current ScriptContext and returns the result
 Object evaluate(String fileName)
          Evaluates some script against the current ScriptContext and returns the result
 Object evaluate(String scriptText, String fileName)
          Evaluates some script against the current ScriptContext and returns the result
 groovy.lang.ScriptContext getContext()
           
 Object getProperty(String property)
           
 Object getVariable(String name)
           
static void main(String[] args)
           
 void run(File scriptFile, List list)
          A helper method which runs the given script file with the given command line arguments
 Object run(InputStream in, String fileName, String[] args)
          Runs the given script with command line arguments
 void run(String scriptFile, String[] args)
          Runs the given script file name with the given command line arguments
 void 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)
           
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, invokeMethod, setMetaClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARGS

public static final String[] EMPTY_ARGS
Constructor Detail

GroovyShell

public GroovyShell()

GroovyShell

public GroovyShell(groovy.lang.ScriptContext binding)

GroovyShell

public GroovyShell(ClassLoader parent,
                   groovy.lang.ScriptContext binding)
Method Detail

main

public static void main(String[] args)

getContext

public groovy.lang.ScriptContext getContext()

getProperty

public Object getProperty(String property)
Specified by:
getProperty in interface GroovyObject
Overrides:
getProperty in class GroovyObjectSupport
Returns:
the given property

setProperty

public void setProperty(String property,
                        Object newValue)
Description copied from interface: GroovyObject
Sets the given property to the new value

Specified by:
setProperty in interface GroovyObject
Overrides:
setProperty in class GroovyObjectSupport

run

public void run(File scriptFile,
                List list)
         throws ClassNotFoundException,
                SyntaxException,
                IOException
A helper method which runs the given script file with the given command line arguments

Parameters:
scriptFile - the file of the script to run
ClassNotFoundException
SyntaxException
IOException

run

public void run(String scriptFile,
                String[] args)
         throws ClassNotFoundException,
                SyntaxException,
                IOException
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
ClassNotFoundException
SyntaxException
IOException

run

public void run(String scriptText,
                String fileName,
                String[] args)
         throws ClassNotFoundException,
                SyntaxException,
                IOException
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
ClassNotFoundException
SyntaxException
IOException

run

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

getVariable

public Object getVariable(String name)

setVariable

public void setVariable(String name,
                        Object value)

evaluate

public Object evaluate(String scriptText,
                       String fileName)
                throws SyntaxException,
                       ClassNotFoundException,
                       IOException
Evaluates some script against the current ScriptContext and returns the result

Parameters:
fileName - is the logical file name of the script (which is used to create the class name of the script)
SyntaxException
ClassNotFoundException
IOException

evaluate

public Object evaluate(String fileName)
                throws SyntaxException,
                       ClassNotFoundException,
                       IOException
Evaluates some script against the current ScriptContext and returns the result

Parameters:
fileName - is the logical file name of the script (which is used to create the class name of the script)
SyntaxException
ClassNotFoundException
IOException

evaluate

public Object evaluate(InputStream in,
                       String fileName)
                throws SyntaxException,
                       ClassNotFoundException,
                       IOException
Evaluates some script against the current ScriptContext 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)
SyntaxException
ClassNotFoundException
IOException


Copyright © 2003 The Codehaus. All Rights Reserved.