edu.toronto.cs.simulator
Class XCTraceState

java.lang.Object
  extended by edu.toronto.cs.simulator.XCTraceState

public class XCTraceState
extends java.lang.Object

XCTraceState is the class used to store the state info in the trace.


Constructor Summary
XCTraceState()
          Makes an empty trace state node with no parents or children.
XCTraceState(XCTraceState par, XCStateInfo si, boolean ms)
          Makes a trace tree node with the specified parent, children and state info.
 
Method Summary
 void addChild(XCTraceState child)
          Adds another next state.
 boolean equals(java.lang.Object o)
          If the object compared to is of type XCTraceState and has equal state info, returns true; otherwise returs false.
 XCTraceState getChild(int index)
          Retrieves the next state by its index.
 int getChildIndex(XCTraceState state)
          Retrieves the specified next state's index.
 XCTraceState[] getChildren()
          Gets all the next states that are available.
 XCStateInfo getInfo()
          Retrieves the state info.
 int getNumChildren()
          Tells the number of the next states available to be explored.
 XCTraceState getParent()
          Gets the previous state from the trace.
 boolean isMultiState()
           
 XCTraceState remove()
          Removes the node (with the entire sub-tree) from it's parent.
 void setInfo(XCStateInfo newinfo, boolean ms)
          Sets the state info.
 void setParent(XCTraceState newparent)
          Allows to specify the previous state in the trace.
 java.lang.String toString()
          Creates a string containg the state name as specified in the state info (not the parent or children info).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XCTraceState

public XCTraceState()
Makes an empty trace state node with no parents or children.


XCTraceState

public XCTraceState(XCTraceState par,
                    XCStateInfo si,
                    boolean ms)
Makes a trace tree node with the specified parent, children and state info.

Parameters:
par - - parent
si - - state info, if null an empty XCStateInfo will be used instead.
Method Detail

equals

public boolean equals(java.lang.Object o)
If the object compared to is of type XCTraceState and has equal state info, returns true; otherwise returs false.

Overrides:
equals in class java.lang.Object
Parameters:
o - - Object to compare.
Returns:
true if the state info of XCStateInfo objects is equal and false otherwise.

getInfo

public XCStateInfo getInfo()
Retrieves the state info.

Returns:
the state info.

setInfo

public void setInfo(XCStateInfo newinfo,
                    boolean ms)
Sets the state info.

Parameters:
newinfo - - the new state info, if null an empty XCStateInfo object will be used instead.

getNumChildren

public int getNumChildren()
Tells the number of the next states available to be explored.

Returns:
the number of the next states available to be explored.

getChildren

public XCTraceState[] getChildren()
Gets all the next states that are available.

Returns:
the array of all the next states that are available.

getChild

public XCTraceState getChild(int index)
Retrieves the next state by its index.

Parameters:
index - - index of the state to retrieve
Returns:
next state with the specified index or null if not found.

getChildIndex

public int getChildIndex(XCTraceState state)
Retrieves the specified next state's index.

Parameters:
state - - state you want the index of
Returns:
the index of the specified state or -1 if not found.

addChild

public void addChild(XCTraceState child)
Adds another next state.

Parameters:
child - - new next state to be added.

remove

public XCTraceState remove()
Removes the node (with the entire sub-tree) from it's parent. Note: removing a root does nothing.

Returns:
state node that was removed.

getParent

public XCTraceState getParent()
Gets the previous state from the trace.

Returns:
the previous state from the trace.

setParent

public void setParent(XCTraceState newparent)
Allows to specify the previous state in the trace. This is a convenience method.

Parameters:
newparent - - the previous state in the trace.

toString

public java.lang.String toString()
Creates a string containg the state name as specified in the state info (not the parent or children info).

Overrides:
toString in class java.lang.Object
Returns:
state name.

isMultiState

public boolean isMultiState()