mwalk Platform 0.3.0

mwalk.visitor
Class GlobalVisitor

java.lang.Object
  |
  +--mwalk.visitor.AbstractVisitor
        |
        +--mwalk.visitor.GlobalVisitor
Direct Known Subclasses:
RandomVisitor

public class GlobalVisitor
extends AbstractVisitor
implements UpVisitor, DownVisitor

A compund visitor which runs a pair of visitors, one walking up the tree and a second which walks back down.

Version:
1.0
Author:
Robert Chalmers

Field Summary
private static java.lang.String CFG_BASE
          Base of keys in configuration file
protected  DownVisitor dv
          Visitor to use while walking down the tree
protected  boolean goingUp
          Flag indicating whether we are currently walking up the tree
protected  long round
          Current round
protected  long rounds
          Number of rounds and current repitition
protected  UpVisitor uv
          Visitor to use while walking up the tree
 
Fields inherited from class mwalk.visitor.AbstractVisitor
CFG_BASE, eval, seen, verbose
 
Constructor Summary
GlobalVisitor()
          Default constructor.
GlobalVisitor(DownVisitor dv)
           
GlobalVisitor(DownVisitor dv, int rounds)
           
GlobalVisitor(int rounds)
           
GlobalVisitor(UpVisitor uv, DownVisitor dv)
           
GlobalVisitor(UpVisitor uv, DownVisitor dv, int rounds)
           
 
Method Summary
 boolean again(Tree tree)
          Check whether the visitor wants another pass over the tree.
 TreeNode[] getChildren(Tree tree, TreeNode node)
          Get a list of children for the current node applying correct activity semantics.
 TreeNode[] getParents(Tree tree, TreeNode node)
          Get a list of parents for the current node applying correct activity semantics.
 java.util.Enumeration getReceivers(Tree tree)
          Get a list of active receivers.
 boolean init(Tree tree)
          Initialize the visitor state.
 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 prepare(Tree tree)
          Prepare the up/down visitors for a new pass over the tree.
 void reset(Tree tree)
          Reset the visitor for a new pass over the tree.
 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 mwalk.visitor.AbstractVisitor
cfgBoolean, cfgInt, cfgString, cfgVisitor, evaluator, evaluator, haveSeen, haveVisited, markSeen, markVisited, verbose
 
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

uv

protected UpVisitor uv
Visitor to use while walking up the tree

dv

protected DownVisitor dv
Visitor to use while walking down the tree

goingUp

protected boolean goingUp
Flag indicating whether we are currently walking up the tree

rounds

protected long rounds
Number of rounds and current repitition

round

protected long round
Current round
Constructor Detail

GlobalVisitor

public GlobalVisitor()
Default constructor.

GlobalVisitor

public GlobalVisitor(int rounds)

GlobalVisitor

public GlobalVisitor(DownVisitor dv)

GlobalVisitor

public GlobalVisitor(UpVisitor uv,
                     DownVisitor dv)

GlobalVisitor

public GlobalVisitor(DownVisitor dv,
                     int rounds)

GlobalVisitor

public GlobalVisitor(UpVisitor uv,
                     DownVisitor dv,
                     int rounds)
Method Detail

prefix

public boolean prefix()
Whether to visit prior to visiting parent/children.
Overrides:
prefix in class AbstractVisitor
Returns:
boolean whether to visit prior

postfix

public boolean postfix()
Whether to visit after visiting parent/children.
Overrides:
postfix in class AbstractVisitor
Returns:
boolean whether to visit after

walkUp

public boolean walkUp()
Whether to walk up the tree.
Specified by:
walkUp in interface UpVisitor
Overrides:
walkUp in class AbstractVisitor
Returns:
boolean whether to walk up the tree

walkDown

public boolean walkDown()
Whether to walk down the tree.
Specified by:
walkDown in interface DownVisitor
Overrides:
walkDown in class AbstractVisitor
Returns:
boolean whether to walk down the tree

init

public boolean init(Tree tree)
Initialize the visitor state.
Overrides:
init in class AbstractVisitor
Parameters:
Tree - current tree instance

reset

public void reset(Tree tree)
Reset the visitor for a new pass over the tree.
Overrides:
reset in class AbstractVisitor
Parameters:
Tree - vistited tree

again

public boolean again(Tree tree)
Check whether the visitor wants another pass over the tree. Repeat complete up/down series for total number of rounds.
Overrides:
again in class AbstractVisitor
Parameters:
Tree - vistited tree
Returns:
boolean whether to walk again

prepare

public void prepare(Tree tree)
Prepare the up/down visitors for a new pass over the tree.
Parameters:
Tree - vistited tree

nextReceiver

public boolean nextReceiver(Tree tree,
                            Receiver recv)
Check whether the next receiver should start a visiting path.
Specified by:
nextReceiver in interface UpVisitor
Overrides:
nextReceiver in class AbstractVisitor
Parameters:
Tree - current tree instance
Receiver - next receiver
Returns:
boolean whether to visit next receiver

getReceivers

public java.util.Enumeration getReceivers(Tree tree)
Get a list of active receivers.
Specified by:
getReceivers in interface UpVisitor
Overrides:
getReceivers in class AbstractVisitor
Parameters:
Tree - current tree instance
Returns:
Enumeration list of receivers to visit

visitUp

public java.lang.Object visitUp(Tree tree,
                                TreeNode node)
                         throws VisitException
Visit the current node prior to visiting parent.
Specified by:
visitUp in interface UpVisitor
Overrides:
visitUp in class AbstractVisitor
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.
Specified by:
visitUp in interface UpVisitor
Overrides:
visitUp in class AbstractVisitor
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

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.
Specified by:
visitDown in interface DownVisitor
Overrides:
visitDown in class AbstractVisitor
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.
Specified by:
visitDown in interface DownVisitor
Overrides:
visitDown in class AbstractVisitor
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)
Get a list of parents for the current node applying correct activity semantics.
Specified by:
getParents in interface UpVisitor
Overrides:
getParents in class AbstractVisitor
Parameters:
Tree - current tree instance
TreeNode - current node
Returns:
TreeNode[] array of active parent nodes

getChildren

public TreeNode[] getChildren(Tree tree,
                              TreeNode node)
Get a list of children for the current node applying correct activity semantics.
Specified by:
getChildren in interface DownVisitor
Overrides:
getChildren in class AbstractVisitor
Parameters:
Tree - current tree instance
TreeNode - current node
Returns:
TreeNode[] list of active children nodes

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