groovy.lang
Class Script

java.lang.Object
  extended bygroovy.lang.GroovyObjectSupport
      extended bygroovy.lang.Script
All Implemented Interfaces:
GroovyObject

public abstract class Script
extends GroovyObjectSupport

This object represents a Groovy script

Version:
$Revision: 4262 $
Author:
James Strachan, Guillaume Laforge

Constructor Summary
protected Script()
           
protected Script(Binding binding)
           
 
Method Summary
 Object evaluate(File file)
          A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope
 Object evaluate(String expression)
          A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope
 Binding getBinding()
           
 Object getProperty(String property)
           
 Object invokeMethod(String name, Object args)
          Invoke a method (or closure in the binding) defined.
 void print(Object value)
          Prints the value to the current 'out' variable which should be a PrintWriter or at least have a print() method defined on it.
 void println()
          Prints a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it.
 void println(Object value)
          Prints the value and a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it.
abstract  Object run()
          The main instance method of a script which has variables in scope as defined by the current Binding instance.
 void run(File file, String[] arguments)
          A helper method to allow scripts to be run taking command line arguments
 void setBinding(Binding binding)
           
 void setProperty(String property, Object newValue)
          Sets the given property to the new value
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Script

protected Script()

Script

protected Script(Binding binding)
Method Detail

getBinding

public Binding getBinding()

setBinding

public void setBinding(Binding binding)

getProperty

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

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

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Invoke a method (or closure in the binding) defined.

Specified by:
invokeMethod in interface GroovyObject
Overrides:
invokeMethod in class GroovyObjectSupport
Parameters:
name - method to call
args - arguments to pass to the method
Returns:
value

run

public abstract Object run()
The main instance method of a script which has variables in scope as defined by the current Binding instance.


println

public void println()
Prints a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it. If there is no 'out' property then print to standard out.


print

public void print(Object value)
Prints the value to the current 'out' variable which should be a PrintWriter or at least have a print() method defined on it. If there is no 'out' property then print to standard out.


println

public void println(Object value)
Prints the value and a newline to the current 'out' variable which should be a PrintWriter or at least have a println() method defined on it. If there is no 'out' property then print to standard out.


evaluate

public Object evaluate(String expression)
                throws CompilationFailedException,
                       IOException
A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

Parameters:
expression - is the Groovy script expression to evaluate
Throws:
CompilationFailedException
IOException

evaluate

public Object evaluate(File file)
                throws CompilationFailedException,
                       IOException
A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

Parameters:
file - is the Groovy script to evaluate
Throws:
CompilationFailedException
IOException

run

public void run(File file,
                String[] arguments)
         throws CompilationFailedException,
                IOException
A helper method to allow scripts to be run taking command line arguments

Throws:
CompilationFailedException
IOException


Copyright © 2003-2007 The Codehaus. All Rights Reserved.