Class ActionSequence

java.lang.Object
  |
  +--ActionSequence

public class ActionSequence
extends Object

This class implements a sequence of compound actions:

   a0, a1, ..., an.
 
A compound action is a set of (elementary) actions. The number of steps in the sequence is equal to the number of its elements.

Notice that the last compoud action is assumed to be always empty.


Constructor Summary
ActionSequence()
          Constructs an empty ActionSequence.
 
Method Summary
 String actionsToString(int step)
          Returns a string representation of a compound action.
 void add(int step, String action)
          Adds an action to the compound action at the given step.
 void extendTimeSteps(int step)
          Ensures that the sequence is large enough to contain the given step.
 String getAction(int step, int index)
          Returns an action from the compound action at the specified step.
 Enumeration getActions(int step)
          Returns an Enumeration of the actions contained in a compound action.
 MathSet getActionSet(int step)
          Returns the MathSet wrapped around a compound action.
 int getLastTime()
          Returns the number of usable compound actions in the sequence (recall that the last compound action is assumed to be always empty).
 int getNumActions()
          Returns the number of actions present in the ActionSequence.
 int getNumActionsAt(int step)
          Returns the number of actions present at the given step of the ActionSequence.
 int getTrimmedLength()
          Returns the length of the longest sub-sequence of this ActionSequence which starts at 0 and end with a non-empty compound action.
 Vector toAProlog()
          Returns an A-Prolog representation of the ActionSequence.
 void toAProlog(File f)
          Writes to the given file an A-Prolog representation of the whole ActionSequence.
 Vector toAProlog(int fromStep)
          Returns an A-Prolog representation of the ActionSequence starting from the given step.
 void toAProlog(int fromStep, File f)
          Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step.
 void toAProlog(int fromStep, File f, boolean append)
          Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step.
 void toAProlog(int fromStep, String f)
          Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step.
 void toAProlog(int fromStep, String f, boolean append)
          Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step.
 void toAProlog(String f)
          Writes to the given file an A-Prolog representation of the whole ActionSequence.
 String toString()
          Returns a string representation of the whole ActionSequence.
 String toString(int fromStep)
          Returns a string representation of the ActionSequence starting from the given step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActionSequence

public ActionSequence()
Constructs an empty ActionSequence.
Method Detail

extendTimeSteps

public void extendTimeSteps(int step)
Ensures that the sequence is large enough to contain the given step.
Parameters:
step - the step that must be contained in the sequence

add

public void add(int step,
                String action)
Adds an action to the compound action at the given step.
Parameters:
step - the step whose compound action must be modified
action - the (elementary) action to be added

getLastTime

public int getLastTime()
Returns the number of usable compound actions in the sequence (recall that the last compound action is assumed to be always empty).
Returns:
the number of usable compound actions in the sequence

getTrimmedLength

public int getTrimmedLength()
Returns the length of the longest sub-sequence of this ActionSequence which starts at 0 and end with a non-empty compound action.
Returns:
the length of the longest sub-sequence

getNumActions

public int getNumActions()
Returns the number of actions present in the ActionSequence.
Returns:
the number of actions in the ActionSequence

getNumActionsAt

public int getNumActionsAt(int step)
Returns the number of actions present at the given step of the ActionSequence.
Returns:
the number of actions at the given step of the ActionSequence

getAction

public String getAction(int step,
                        int index)
Returns an action from the compound action at the specified step.
Parameters:
step - the step from which we want to retrieve the action
index - the index of the action that we want to retrieve
Returns:
the action retrieved

getActionSet

public MathSet getActionSet(int step)
Returns the MathSet wrapped around a compound action.
Parameters:
step - the step where the compound action is
Returns:
the MathSet wrapper around the compound action

getActions

public Enumeration getActions(int step)
Returns an Enumeration of the actions contained in a compound action.
Parameters:
step - the step where the compound action is
Returns:
the Enumeration of the actions contained in the compound action

actionsToString

public String actionsToString(int step)
Returns a string representation of a compound action. The beginning and the end of the string are marked by "{" and "}", and elements are comma-separated.
Parameters:
step - the step where the compound action is
Returns:
the string representation of the compound action

toString

public String toString(int fromStep)
Returns a string representation of the ActionSequence starting from the given step. Compound actions are comma-separated.
Parameters:
fromStep - the first step to represent
Returns:
the string representation of the ActionSequence

toString

public String toString()
Returns a string representation of the whole ActionSequence.
Overrides:
toString in class Object
Returns:
the string representation of the ActionSequence

toAProlog

public Vector toAProlog(int fromStep)
Returns an A-Prolog representation of the ActionSequence starting from the given step. The representation is stored in a Vector. Each element of the Vector contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs.
Parameters:
fromStep - the first step to represent
Returns:
the Vector containing the A-Prolog representation of the ActionSequence

toAProlog

public Vector toAProlog()
Returns an A-Prolog representation of the ActionSequence. The representation is stored in a Vector. Each element of the Vector contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs.
Returns:
the Vector containing the A-Prolog representation of the ActionSequence

toAProlog

public void toAProlog(int fromStep,
                      String f,
                      boolean append)
Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step. Each line of the file contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs.
Parameters:
fromStep - the first step to represent
f - the name of the file to be written
append - true if the representation should be appended to the file; false if the file should be overwritten

toAProlog

public void toAProlog(int fromStep,
                      File f,
                      boolean append)
Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step. Each line of the file contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs.
Parameters:
fromStep - the first step to represent
f - the File object representing the file to be written
append - true if the representation should be appended to the file; false if the file should be overwritten

toAProlog

public void toAProlog(int fromStep,
                      String f)
Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step. Each line of the file contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs. The file is overwritten.
Parameters:
fromStep - the first step to represent
f - the name of the file to be written

toAProlog

public void toAProlog(int fromStep,
                      File f)
Writes to the given file an A-Prolog representation of the ActionSequence starting from the given step. Each line of the file contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs. The file is overwritten.
Parameters:
fromStep - the first step to represent
f - the File object representing the file to be written

toAProlog

public void toAProlog(String f)
Writes to the given file an A-Prolog representation of the whole ActionSequence. Each line of the file contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs. The file is overwritten.
Parameters:
fromStep - the first step to represent
f - the name of the file to be written

toAProlog

public void toAProlog(File f)
Writes to the given file an A-Prolog representation of the whole ActionSequence. Each line of the file contains a string "o(ELEM,T)", where ELEM is an elementary action from the ActionSequence, and T is the step where ELEM occurs. The file is overwritten.
Parameters:
fromStep - the first step to represent
f - the File object representing the file to be written