uk.org.arlott.simon.hw.f24.lbsta
Class Script

java.lang.Object
  extended by uk.org.arlott.simon.hw.f24.lbsta.Script

public class Script
extends java.lang.Object

Holds the script elements to be processed when running the simulation.


Field Summary
private  ScriptComponent current
          Current script element.
private  boolean finished
          Finished state.
private  Network network
          The network this script is run on.
private  java.util.ArrayList<ScriptComponent> script
          List of script elements.
 
Constructor Summary
Script(Network network)
          Creates a new Script attached to the specified network.
 
Method Summary
 void add(ScriptComponent sc)
          Adds a script element.
 void add(ScriptComponent sc, int id)
          Adds a script element at the specified position.
 void clear()
          Clears all the elements from the list.
 ScriptComponent get(int id)
          Gets a script element.
 ScriptComponent getCurrent()
          Gets the current element.
 java.util.Vector<ScriptComponent> getScript()
          Gets the script.
 void moveDown(int id)
          Move a script element down one position in the list.
 void moveUp(int id)
          Move a script element up one position in the list.
 void remove(int id)
          Removes a script element.
 void reset()
          Resets the script to restart at the first element.
 boolean run(java.util.Vector<NetworkEvent> events, boolean steppingMode)
          Runs the script on the specified events.
private  boolean steppingMode(java.util.Vector<NetworkEvent> events)
          Runs the simulation test in stepping mode (only valid if there is are no script elements).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

network

private Network network
The network this script is run on.


script

private java.util.ArrayList<ScriptComponent> script
List of script elements.


current

private ScriptComponent current
Current script element.


finished

private boolean finished
Finished state.

Constructor Detail

Script

public Script(Network network)
Creates a new Script attached to the specified network.

Parameters:
network - The Network this script is run on.
Method Detail

getScript

public java.util.Vector<ScriptComponent> getScript()
Gets the script.

Returns:
All the script elements.

getCurrent

public ScriptComponent getCurrent()
Gets the current element.

Returns:
The current script element or null if finished or the script is empty.

add

public void add(ScriptComponent sc)
Adds a script element.

Parameters:
sc - The ScriptComponent to be added to the end of the list.

add

public void add(ScriptComponent sc,
                int id)
Adds a script element at the specified position.

Parameters:
sc - The ScriptComponent to be added.
id - The position in the list to place the element.

get

public ScriptComponent get(int id)
Gets a script element.

Parameters:
id - The position of the element.
Returns:
The script element at position id in the list.

remove

public void remove(int id)
Removes a script element.

Parameters:
id - The position of the element to be removed.

moveUp

public void moveUp(int id)
Move a script element up one position in the list.

Parameters:
id - The position of the element to be moved up.

moveDown

public void moveDown(int id)
Move a script element down one position in the list.

Parameters:
id - The position of the element to be moved down.

clear

public void clear()
Clears all the elements from the list.


reset

public void reset()
Resets the script to restart at the first element.


run

public boolean run(java.util.Vector<NetworkEvent> events,
                   boolean steppingMode)
Runs the script on the specified events.

Parameters:
events - The events that have occurred on the Network
steppingMode - Whether or not stepping mode is in use.
Returns:
true if the simulation should be paused.

steppingMode

private boolean steppingMode(java.util.Vector<NetworkEvent> events)
Runs the simulation test in stepping mode (only valid if there is are no script elements).

Parameters:
events - The events that have occurred on the Network
Returns:
true if the simulation should be paused.