com.exoftware.exactor
Class Script

java.lang.Object
  extended bycom.exoftware.exactor.Script

public class Script
extends java.lang.Object

A collection of commands to be executed together. The script contains a context map that is accessible to all the commands contained in the script.

Author:
Brian Swan

Constructor Summary
Script()
          Create a new script.
Script(java.io.File scriptFile)
          Create a new script with the specified scriptFile.
 
Method Summary
 void addCommand(Command c)
          Add a command to the script.
 int countCommands()
          Returns the number of commands added to the script.
 void execute()
          Execute all the commands in the script.
 java.lang.String getAbsolutePath()
          Returns the full path of the script file.
 Command getCommand(int index)
          Returns the command at the specified index.
 java.util.Map getContext()
          Returns the context for all commands in this script.
 ExecutionSet getExecutionSet()
          Returns the ExecutionSet containing this script.
 java.lang.String getName()
          Returns the name of the script.
 boolean hasCommands()
          Check whether the script has any commands.
 void replaceCommand(Command command, Command replacement)
          Replace one command with another command.
 void setExecutionSet(ExecutionSet s)
          Set the ExecutionSet that contains this script.
 void substituteParameters(Parameter[] substitutions)
          Substitute the specified substitutions for all commands in the script.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Script

public Script()
Create a new script.


Script

public Script(java.io.File scriptFile)
Create a new script with the specified scriptFile.

Parameters:
scriptFile - the file containing the script.
Method Detail

getName

public java.lang.String getName()
Returns the name of the script.

Returns:
the name of the script.

getAbsolutePath

public java.lang.String getAbsolutePath()
Returns the full path of the script file.

Returns:
the full path of the script file.

getExecutionSet

public ExecutionSet getExecutionSet()
Returns the ExecutionSet containing this script.

Returns:
the ExecutionSet containing this script.

setExecutionSet

public void setExecutionSet(ExecutionSet s)
Set the ExecutionSet that contains this script.

Parameters:
s - the ExecutionSet that contains this script.

getContext

public java.util.Map getContext()
Returns the context for all commands in this script.

Returns:
the context for all commands in this script.

addCommand

public void addCommand(Command c)
Add a command to the script.

Parameters:
c - the command to add.

hasCommands

public boolean hasCommands()
Check whether the script has any commands.

Returns:
true if the script contains commands, otherwise false.

countCommands

public int countCommands()
Returns the number of commands added to the script.

Returns:
the number of commands added to the script.

getCommand

public Command getCommand(int index)
                   throws java.lang.IndexOutOfBoundsException
Returns the command at the specified index.

Parameters:
index - the index of the command to return.
Returns:
the command at the specified index.
Throws:
java.lang.IndexOutOfBoundsException - if the command has no parameters, or if the index is out of range (index < 0 || index >= countCommands()).

replaceCommand

public void replaceCommand(Command command,
                           Command replacement)
                    throws java.lang.NullPointerException,
                           java.lang.IllegalStateException
Replace one command with another command.

Parameters:
command - the command to replace.
replacement - the replacement command.
Throws:
java.lang.RuntimeException - if either command or replacement are null or if command is not contained in this script
java.lang.NullPointerException
java.lang.IllegalStateException

execute

public void execute()
Execute all the commands in the script.


substituteParameters

public void substituteParameters(Parameter[] substitutions)
Substitute the specified substitutions for all commands in the script.

Parameters:
substitutions - the array of parameters to use for substitutions.
See Also:
Command.substituteParameters(Parameter[])