mwalk Platform 0.3.0

mwalk.visitor
Class AbstractVisitor

java.lang.Object
  |
  +--mwalk.visitor.AbstractVisitor
Direct Known Subclasses:
CollapseVisitor, DataVisitor, GlobalVisitor, JoinVisitor, MergeVisitor, PathlessVisitor, PrimaryPathVisitor, PrintVisitor, RandomPathVisitor, TraceVisitor

public abstract class AbstractVisitor
extends java.lang.Object
implements Visitor

Abstract class which defines a set of default methods for most visitors. This class defines methods for Visitor, UpVisitor, and DownVisitor although it only implements Visitor. This allows sub-classes to regulate which calls actually get made.

Version:
1.0
Author:
Robert Chalmers

Field Summary
private static java.lang.String CFG_BASE
          Base of keys in configuration file
protected  ActivityEvaluator eval
          Evaluator used to determine activity when walking
protected  java.util.Hashtable seen
          Hash table used to track who we have seen and processed
protected  boolean verbose
          Whether the visitor prints verbose messages in verbose mode
 
Constructor Summary
AbstractVisitor()
          Default constructor.
 
Method Summary
 boolean again(Tree tree)
          Check whether the visitor wants another pass over the tree.
protected  boolean cfgBoolean(java.lang.String key)
          Get a configuration value as a boolean.
protected  int cfgInt(java.lang.String key)
          Get a configuration value as an integer.
protected  java.lang.String cfgString(java.lang.String key)
          Get a configuration value as a string.
protected  Visitor cfgVisitor(java.lang.String key)
          Get a configuration value as a visitor object.
 ActivityEvaluator evaluator()
          Return the current activity evaluator.
 void evaluator(ActivityEvaluator eval)
          Set the current activity evaluator.
 TreeNode[] getChildren(Tree tree, TreeNode node)
          Retrieve the list of children of this node.
 TreeNode[] getParents(Tree tree, TreeNode node)
          Retrieve the list of parents of this node.
 java.util.Enumeration getReceivers(Tree tree)
          Get a list of active receivers.
 boolean haveSeen(TreeNode node)
           
 boolean haveVisited(TreeNode node)
           
 boolean init(Tree tree)
          Initialize the visitor state.
 boolean markSeen(TreeNode node)
           
 boolean markVisited(TreeNode node)
           
 boolean nextReceiver(Tree tree, Receiver recv)
          Check whether the next receiver should start a visiting path.
 boolean postfix()
          Whether to visit after visiting parent/children.
 boolean prefix()
          Whether to visit prior to visiting parent/children.
 void reset(Tree tree)
          Reset the visitor for a new pass over the tree.
 boolean verbose()
          Check whether the visitor is verbose.
 java.lang.Object visitDown(Tree tree, TreeNode node)
          Visit the current node prior to visiting children.
 java.lang.Object visitDown(Tree tree, TreeNode node, java.util.Vector list)
          Visit the current node after visiting children.
 java.lang.Object visitUp(Tree tree, TreeNode node)
          Visit the current node prior to visiting parent.
 java.lang.Object visitUp(Tree tree, TreeNode node, java.util.Vector list)
          Visit the current node after visiting parent.
 boolean walkDown()
          Whether to walk down the tree.
 boolean walkUp()
          Whether to walk up the tree.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CFG_BASE

private static final java.lang.String CFG_BASE
Base of keys in configuration file

eval

protected ActivityEvaluator eval
Evaluator used to determine activity when walking

seen

protected java.util.Hashtable seen
Hash table used to track who we have seen and processed

verbose

protected boolean verbose
Whether the visitor prints verbose messages in verbose mode
Constructor Detail

AbstractVisitor

public AbstractVisitor()
Default constructor.
Method Detail

evaluator

public ActivityEvaluator evaluator()
Return the current activity evaluator.
Specified by:
evaluator in interface Visitor
Returns:
ActivityEvaluator current evaluator

evaluator

public void evaluator(ActivityEvaluator eval)
Set the current activity evaluator.
Specified by:
evaluator in interface Visitor
Parameters:
ActivityEvaluator - new evaluator

verbose

public boolean verbose()
Check whether the visitor is verbose.
Specified by:
verbose in interface Visitor
Returns:
boolean whether visitor is verbose

prefix

public boolean prefix()
Whether to visit prior to visiting parent/children.
Specified by:
prefix in interface Visitor
Returns:
boolean whether to visit prior

postfix

public boolean postfix()
Whether to visit after visiting parent/children.
Specified by:
postfix in interface Visitor
Returns:
boolean whether to visit after

init

public boolean init(Tree tree)
Initialize the visitor state.
Specified by:
init in interface Visitor
Parameters:
Tree - current tree instance
Returns:
boolean whether to walk again

reset

public void reset(Tree tree)
Reset the visitor for a new pass over the tree.
Specified by:
reset in interface Visitor
Parameters:
Tree - vistited tree

again

public boolean again(Tree tree)
Check whether the visitor wants another pass over the tree.
Specified by:
again in interface Visitor
Parameters:
Tree - vistited tree
Returns:
boolean whether to walk again

walkUp

public boolean walkUp()
Whether to walk up the tree.
Returns:
boolean whether to walk up the tree

getReceivers

public java.util.Enumeration getReceivers(Tree tree)
Get a list of active receivers.
Parameters:
Tree - current tree instance
Returns:
Enumeration list of receivers to visit

nextReceiver

public boolean nextReceiver(Tree tree,
                            Receiver recv)
Check whether the next receiver should start a visiting path.
Parameters:
Tree - current tree instance
Receiver - next receiver
Returns:
boolean whether to visit next receiver

visitUp

public java.lang.Object visitUp(Tree tree,
                                TreeNode node)
                         throws VisitException
Visit the current node prior to visiting parent.
Parameters:
Tree - current tree instance
TreeNode - current node
Returns:
Object optional return value to pass back along the path
Throws:
VisitException - if a problem ocurred during visit

visitUp

public java.lang.Object visitUp(Tree tree,
                                TreeNode node,
                                java.util.Vector list)
                         throws VisitException
Visit the current node after visiting parent.
Parameters:
Tree - current tree instance
TreeNode - current node
Object - list of return values passed back along the path
Returns:
Object optional return value to pass back along the path
Throws:
VisitException - if a problem ocurred during visit

getParents

public TreeNode[] getParents(Tree tree,
                             TreeNode node)
Retrieve the list of parents of this node.
Parameters:
Tree - vistited tree
TreeNode - currently visited node
Returns:
TreeNode[] array of parent nodes of currently visited node

walkDown

public boolean walkDown()
Whether to walk down the tree.
Returns:
boolean whether to walk down the tree

visitDown

public java.lang.Object visitDown(Tree tree,
                                  TreeNode node)
                           throws VisitException
Visit the current node prior to visiting children. This method is called if prefix() returns true.
Parameters:
Tree - current tree instance
TreeNode - current node
Returns:
Object optional return value to pass back along the path
Throws:
VisitException - if a problem ocurred during visit

visitDown

public java.lang.Object visitDown(Tree tree,
                                  TreeNode node,
                                  java.util.Vector list)
                           throws VisitException
Visit the current node after visiting children. This method is called if postfix() returns true.
Parameters:
Tree - current tree instance
TreeNode - current node
Object - list of return values passed back along the path
Returns:
Object optional return value to pass back along the path
Throws:
VisitException - if a problem ocurred during visit

getChildren

public TreeNode[] getChildren(Tree tree,
                              TreeNode node)
Retrieve the list of children of this node.
Parameters:
Tree - vistited tree
TreeNode - currently visited node
Returns:
TreeNode[] array of child nodes of currently visited node

haveSeen

public boolean haveSeen(TreeNode node)

haveVisited

public boolean haveVisited(TreeNode node)

markSeen

public boolean markSeen(TreeNode node)

markVisited

public boolean markVisited(TreeNode node)

cfgString

protected java.lang.String cfgString(java.lang.String key)
Get a configuration value as a string. Returns null if value not found.
Parameters:
String - key string
Returns:
String config value

cfgInt

protected int cfgInt(java.lang.String key)
Get a configuration value as an integer. Returns -1 if value not found.
Parameters:
String - key string
Returns:
int config value

cfgBoolean

protected boolean cfgBoolean(java.lang.String key)
Get a configuration value as a boolean. Returns false if value not found.
Parameters:
String - key string
Returns:
boolean config value

cfgVisitor

protected Visitor cfgVisitor(java.lang.String key)
Get a configuration value as a visitor object. Returns null if value not found.
Parameters:
String - key string
Returns:
Visitor instantiated visitor

mwalk Platform 0.3.0

Submit a bug or feature mwalk Platform API Specification 0.3.0
Sensitivity: {Public:Research}
Copyright(c) 2000, Robert Chalmers