com.iotabits.examples.revisitor
Class GraphNode

java.lang.Object
  extended bycom.iotabits.revisitor.BasicVisitable
      extended bycom.iotabits.examples.revisitor.GraphNode
All Implemented Interfaces:
iVisitable

public class GraphNode
extends BasicVisitable

This class provides an example of using the revisitor with a passback. These nodes can be used to represent a directed acyclic graph (DAG).


Nested Class Summary
static class GraphNode.GraphPrinter
          Our simple visitor.
 
Constructor Summary
GraphNode(java.lang.Object data, GraphNode[] children)
          ctor
 
Method Summary
 void accept(iReflectiveVisitor visitor)
          Graph traversal
 GraphNode[] getChildren()
          Return all the directly accessible adjacent nodes.
static void main(java.lang.String[] args)
          This is a simple test program that constructs a simple graph and then iterates over it using the GraphPrinter visitor class.
 void traverse(iReflectiveVisitor visitor)
          If we could make the accept private, we would.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphNode

public GraphNode(java.lang.Object data,
                 GraphNode[] children)
ctor

Method Detail

getChildren

public GraphNode[] getChildren()
Return all the directly accessible adjacent nodes.

Returns:

accept

public void accept(iReflectiveVisitor visitor)
            throws java.lang.Exception
Graph traversal

Specified by:
accept in interface iVisitable
Overrides:
accept in class BasicVisitable
Parameters:
visitor -
Throws:
java.lang.Exception

traverse

public void traverse(iReflectiveVisitor visitor)
              throws java.lang.Exception
If we could make the accept private, we would. Okay, we could if the reflective visitor where to look up the accept method on the visitable objects and setAccessible to true and so on... but that't too much because we wouldn't do that (or be able to) in the static visitor pattern. This is the method to call to start traversing.

Parameters:
visitor -
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
This is a simple test program that constructs a simple graph and then iterates over it using the GraphPrinter visitor class.

Parameters:
args -