org.moyoman.framework
Class DAGNode

java.lang.Object
  |
  +--org.moyoman.framework.DAGNode
All Implemented Interfaces:
Cloneable, Serializable

class DAGNode
extends Object
implements Cloneable, Serializable

This class represents a single ModuleName within the DAG.


Field Summary
private  boolean hasCompleted
          This is true if the Module represented by the ModuleName has already executed.
private  ModuleName name
          The ModuleName object.
private  ArrayList next
          Each element is a DAGNode representing the immediate successors of this node.
private  ArrayList previous
          Each element is a DAGNode representing the immediate predecessors of this node.
 
Constructor Summary
protected DAGNode(ModuleName mn)
          Create the DAGNode object.
 
Method Summary
protected  void addNext(DAGNode node)
          Add an immediate successor to this node.
protected  void addPrevious(DAGNode node)
          Add an immediate predecessor to this node.
 Object clone()
          Clone this object.
protected  ModuleName getModuleName()
          Get the module name of this node.
protected  DAGNode[] getNext()
          Get all of the immediate successors to this node.
protected  DAGNode[] getPrevious()
          Get all of the immediate predecessors to this node.
private  boolean isCompleted()
          Return the completed flag.
protected  boolean isReady()
          Return whether this module is ready to run.
protected  void setCompleted(boolean flag)
          Set the completed flag of this node.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private ModuleName name
The ModuleName object.


hasCompleted

private boolean hasCompleted
This is true if the Module represented by the ModuleName has already executed.


previous

private ArrayList previous
Each element is a DAGNode representing the immediate predecessors of this node.


next

private ArrayList next
Each element is a DAGNode representing the immediate successors of this node.

Constructor Detail

DAGNode

protected DAGNode(ModuleName mn)
Create the DAGNode object.

Parameters:
mn - The ModuleName which this object represents.
Method Detail

addPrevious

protected void addPrevious(DAGNode node)
Add an immediate predecessor to this node.

Parameters:
node - The predecessor to this node.

addNext

protected void addNext(DAGNode node)
Add an immediate successor to this node.

Parameters:
node - The successor to this node.

setCompleted

protected void setCompleted(boolean flag)
Set the completed flag of this node.

Parameters:
flag - The flag which indicates if this node has completed.

isCompleted

private boolean isCompleted()
Return the completed flag.

Returns:
true if the module has completed, or false.

isReady

protected boolean isReady()
Return whether this module is ready to run. It is ready if all of its immediate predecessors have completed. It is assumed that the caller ensures that it calls this method only on nodes that have not yet been started.

Returns:
true if ready to run, or false.

getPrevious

protected DAGNode[] getPrevious()
Get all of the immediate predecessors to this node.

Returns:
An array of DAGNode objects.

getNext

protected DAGNode[] getNext()
Get all of the immediate successors to this node.

Returns:
An array of DAGNode objects.

getModuleName

protected ModuleName getModuleName()
Get the module name of this node.

Returns:
A ModuleName object.

clone

public Object clone()
Clone this object. Unfortunately, it is not possible for this object to completely clone itself in isolation, because of the fact that it is a linked list. After this call, the name and hasCompleted fields are correct, but the next and previous ArrayList objects are empty. It is the responsibility of the caller to ensure that next and previous are filled in with the correct values through calls to addNext() and addPrevious(). For example, the DAG.clone() method does this.

Overrides:
clone in class Object
Returns:
A DAGNode object.