net.sweetohm.ant.bsh
Class BshTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by net.sweetohm.ant.util.FileTask
              extended by net.sweetohm.ant.bsh.BshTask
All Implemented Interfaces:
bsh.ConsoleInterface, java.lang.Cloneable

public class BshTask
extends FileTask
implements bsh.ConsoleInterface

This task executes a Beanshell script within an Ant script. See documentation for this task usage.

Author:
Michel CASABIANCA

Field Summary
(package private)  java.lang.String[] args
          The list of arguments to pass to the script.
(package private) static bsh.Interpreter interpreter
          The BSH interpreter.
(package private)  boolean reset
          Reset flag.
(package private)  java.lang.String script
          The nested script to process.
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
BshTask()
          Empty constructor.
 
Method Summary
 void addText(java.lang.String text)
          Add text to the script to process.
 void error(java.lang.String message)
           
 void execute()
          Processing method for the task.
 java.io.PrintStream getErr()
           
 java.io.Reader getIn()
           
 java.io.PrintStream getOut()
           
 void log(java.lang.String message)
          A log method that avoid message mixing with synchronization.
 void print(java.lang.String message)
           
 void println(java.lang.String message)
           
 void setArgs(java.lang.String args)
          Set command line arguments for the script.
 void setReset(boolean reset)
          Reset flag setter.
 
Methods inherited from class net.sweetohm.ant.util.FileTask
addFileset, getFiles, setDir, setFile
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reset

boolean reset
Reset flag. If this flag is true, the BSH interpreter is reseted for each script. If it is set to false, the fields and functions are persistent between BSH elements (but args are set to null anyway).


args

java.lang.String[] args
The list of arguments to pass to the script. This list behave the same as if it was passed on the command line to the script, but the values are come separated.


script

java.lang.String script
The nested script to process. This value is null if no script is nested in the element.


interpreter

static bsh.Interpreter interpreter
The BSH interpreter. Only one interpreter is necessary for all BSH tasks, that is why this field is static.

Constructor Detail

BshTask

public BshTask()
Empty constructor.

Method Detail

setReset

public void setReset(boolean reset)
Reset flag setter.

Parameters:
reset - The flag value.

setArgs

public void setArgs(java.lang.String args)
Set command line arguments for the script.

Parameters:
args - The coma separated of command line arguments.

addText

public void addText(java.lang.String text)
Add text to the script to process.

Parameters:
text - The text to add to the script.

execute

public void execute()
Processing method for the task.

Overrides:
execute in class org.apache.tools.ant.Task

log

public void log(java.lang.String message)
A log method that avoid message mixing with synchronization.

Overrides:
log in class org.apache.tools.ant.Task
Parameters:
message - The message to log.

getIn

public java.io.Reader getIn()
Specified by:
getIn in interface bsh.ConsoleInterface

getOut

public java.io.PrintStream getOut()
Specified by:
getOut in interface bsh.ConsoleInterface

getErr

public java.io.PrintStream getErr()
Specified by:
getErr in interface bsh.ConsoleInterface

println

public void println(java.lang.String message)
Specified by:
println in interface bsh.ConsoleInterface

print

public void print(java.lang.String message)
Specified by:
print in interface bsh.ConsoleInterface

error

public void error(java.lang.String message)
Specified by:
error in interface bsh.ConsoleInterface