net.sf.ant4eclipse.lang.dependencygraph
Class DependencyGraph

java.lang.Object
  extended by net.sf.ant4eclipse.lang.dependencygraph.DependencyGraph

public final class DependencyGraph
extends java.lang.Object

A DependencyGraph could be used to serialise tree structures regarding the dependencies. The tree will be transformed in a linear structure (List).

A referenced node will always appear prior to the referencing node. Example:

           A
           |
     -------------
     |     |     |
     B     C     D
           |
           E
 
will be transformed to E,B,D,C,A oder B,E,D,C,A.

The order of the nodes depends on the order of the defintion via addVertex() and addEdge().


Nested Class Summary
static class DependencyGraph.Edge
          Internal representation of an edge.
 
Constructor Summary
DependencyGraph()
          Creates a new instance of type DependencyGraph.
 
Method Summary
 void addEdge(java.lang.Object parent, java.lang.Object child)
          Adds an edge to the dependency graph.
 void addVertex(java.lang.Object vertex)
          Adds a vertex to the dependency graph.
 java.util.List calculateOrder()
          Computers the order of all the nodes.
 boolean containsVertex(java.lang.Object vertex)
          Returns true, if the given vertex has already been added to the DependencyGraph.
 boolean isClosed()
          Returns true, if the graph is closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyGraph

public DependencyGraph()
Creates a new instance of type DependencyGraph.

Method Detail

addVertex

public void addVertex(java.lang.Object vertex)
Adds a vertex to the dependency graph.

Parameters:
vertex - the vertex that will be added.

containsVertex

public boolean containsVertex(java.lang.Object vertex)
Returns true, if the given vertex has already been added to the DependencyGraph.

Parameters:
vertex - the vertex
Returns:
true, if the given vertex has already been added to the DependencyGraph, otherwise false.

addEdge

public void addEdge(java.lang.Object parent,
                    java.lang.Object child)
Adds an edge to the dependency graph.

Parameters:
parent - the parent node
child - the child node

isClosed

public boolean isClosed()
Returns true, if the graph is closed.

Returns:
true, if the graph is closed.

calculateOrder

public java.util.List calculateOrder()
                              throws CyclicDependencyException
Computers the order of all the nodes.

Returns:
the odered list of all the nodes..
Throws:
CyclicDependencyException - thrown, if the graph structure contains a cycle.