org.griphyn.vdl.dax
Class Child

java.lang.Object
  extended by org.griphyn.vdl.Chimera
      extended by org.griphyn.vdl.dax.DAX
          extended by org.griphyn.vdl.dax.Child
All Implemented Interfaces:
Cloneable

public class Child
extends DAX
implements Cloneable

This class captures the parent-child relationship between any two nodes in a directed acyclic graph. For ease of external transportation, the graph is flattened into this two-level form. Please note that this presentation is slightly less powerful than the true DAGMan form, because for each child, there can be multiple parents, but multiple children cannot be grouped.

Version:
$Revision: 50 $
Author:
Jens-S. V??ckler, Yong Zhao

Field Summary
private  HashSet m_parentSet
          Captures the list of parent nodes for this child node.
private  String m_thisChild
          Captures the element for which we are constructing dependencies.
 
Constructor Summary
Child()
          Default ctor: Constructs a child node w/o any parents
Child(Job child)
          Ctor: Constructs a child node.
Child(Job child, Job parent)
          Convenience ctor: Constructs a child node with one parent.
Child(String child)
          Ctor: Constructs a child node.
Child(String child, String parent)
          Convenience ctor: Constructs a child node with one parent.
 
Method Summary
 void addParent(Job parent)
          Accessor: Adds a parent job id as dependency to the list of parents.
 void addParent(String parent)
          Accessor: Adds a parent job id as dependency to the list of parents.
 Object clone()
          Creates and returns a copy of this object.
 String getChild()
          Accessor: Obtains the child identifier.
 boolean getParent(String name)
          Accessor: Obtains a parent, iff it is in the bag.
 int getParentCount()
          Accessor: Obtains the count of parental dependencies.
 Iterator iterateParent()
          Accessor: Provides an iterator for the parent list.
 void removeAllParent()
          Accessor: Removes all parental dependencies.
 boolean removeParent(String name)
          Accessor: Removes a parent name from the bag.
 void setChild(Job job)
          Accessor: Sets the identifier for this dependency child.
 void setChild(String id)
          Accessor: Sets the identifier for this dependency child.
 void toString(Writer stream)
          Converts the active state into something meant for human consumption.
 void toXML(Writer stream, String indent, String namespace)
          Dump the state of the current element as XML output.
 Child updateChild(Map mapping)
          Updates the identifiers for child and parents from a mapping.
 
Methods inherited from class org.griphyn.vdl.Chimera
escape, quote, toString, toXML, toXML, writeAttribute
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_parentSet

private HashSet m_parentSet
Captures the list of parent nodes for this child node.


m_thisChild

private String m_thisChild
Captures the element for which we are constructing dependencies.

Constructor Detail

Child

public Child()
Default ctor: Constructs a child node w/o any parents


Child

public Child(String child)
Ctor: Constructs a child node.

Parameters:
child - is the job ID of the child node.

Child

public Child(Job child)
Ctor: Constructs a child node.

Parameters:
child - is the job reference of the child node.

Child

public Child(String child,
             String parent)
Convenience ctor: Constructs a child node with one parent.


Child

public Child(Job child,
             Job parent)
Convenience ctor: Constructs a child node with one parent.

Method Detail

clone

public Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class Object
Returns:
a new instance.

addParent

public void addParent(String parent)
Accessor: Adds a parent job id as dependency to the list of parents.

Parameters:
parent - is the parent id to add, not the parent reference.
See Also:
Job

addParent

public void addParent(Job parent)
Accessor: Adds a parent job id as dependency to the list of parents.

Parameters:
parent - is the parent reference to add
See Also:
Job

iterateParent

public Iterator iterateParent()
Accessor: Provides an iterator for the parent list.

Returns:
the iterator for all dependencies.
See Also:
Job

getChild

public String getChild()
Accessor: Obtains the child identifier.

Returns:
the name of the current child, or null, if the element is hollow.
See Also:
setChild( String )

getParent

public boolean getParent(String name)
Accessor: Obtains a parent, iff it is in the bag.

Parameters:
name - is the parent id to look up.
Returns:
true if the parent is know, false otherwise.

getParentCount

public int getParentCount()
Accessor: Obtains the count of parental dependencies.

Returns:
the number of parents.
See Also:
Job

removeAllParent

public void removeAllParent()
Accessor: Removes all parental dependencies.

See Also:
Job

removeParent

public boolean removeParent(String name)
Accessor: Removes a parent name from the bag.

Parameters:
name - is the name of the parent ID to remove.
Returns:
true, if the parent was removed, false, if it was not present.
See Also:
Job, HashSet.remove(Object)

setChild

public void setChild(String id)
Accessor: Sets the identifier for this dependency child.

Parameters:
id - is the job identifier.
See Also:
getChild()

setChild

public void setChild(Job job)
Accessor: Sets the identifier for this dependency child.

Parameters:
job - is a job reference.
See Also:
getChild()

updateChild

public Child updateChild(Map mapping)
Updates the identifiers for child and parents from a mapping.

Parameters:
mapping - is the mapping between old and new identifier
Returns:
a new instance with mapped identifiers. If none of the old identifiers in mapping are in the child, the result is the same as a clone().

toString

public void toString(Writer stream)
              throws IOException
Converts the active state into something meant for human consumption. The method will be called when recursively traversing the instance tree.

Specified by:
toString in class Chimera
Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
Throws:
IOException - if something fishy happens to the stream.

toXML

public void toXML(Writer stream,
                  String indent,
                  String namespace)
           throws IOException
Dump the state of the current element as XML output. This function traverses all sibling classes as necessary, and converts the data into pretty-printed XML output. The stream interface should be able to handle large output efficiently.

Specified by:
toXML in class Chimera
Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal.
namespace - is the XML schema namespace prefix. If neither empty nor null, each element will be prefixed with this prefix, and the root element will map the XML namespace.
Throws:
IOException - if something fishy happens to the stream.
See Also:
BufferedWriter


Copyright © 2007 The University of Southern California. All Rights Reserved.