com.arsdigita.bebop.util
Class Traversal

java.lang.Object
  extended bycom.arsdigita.bebop.util.Traversal
Direct Known Subclasses:
ComponentTraverse

public abstract class Traversal
extends Object

A utility class for walking down a tree of Bebop components and performing some work on each one.

Uses a filter to perform the action only on certain components. This filter may be used to skip only individual components or entire subtrees. The default filter matches all components.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/util/Traversal.java#8 $

Field Summary
static int PERFORM_ACTION
          If test returns PERFORM_ACTION, then the action is performed on the component and its children.
static int SKIP_COMPONENT
          If test returns SKIP_COMPONENT, then the current component is skipped but its descendants are still traversed.
static int SKIP_SUBTREE
          If test returns SKIP_SUBTREE, then the current component and all of its descendants are skipped.
static String versionId
           
 
Constructor Summary
Traversal()
           
 
Method Summary
protected abstract  void act(Component c)
          Defines the action to be performed on each node.
 void preorder(Component c)
          Invoke act(com.arsdigita.bebop.Component) on this component, and then do the same for each of its children for which the supplied test condition is true.
protected  int test(Component c)
          The default component test returns PERFORM_ACTION to act on all components in the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERFORM_ACTION

public static final int PERFORM_ACTION
If test returns PERFORM_ACTION, then the action is performed on the component and its children. (This is the default.)

See Also:
Constant Field Values

SKIP_COMPONENT

public static final int SKIP_COMPONENT
If test returns SKIP_COMPONENT, then the current component is skipped but its descendants are still traversed.

See Also:
Constant Field Values

SKIP_SUBTREE

public static final int SKIP_SUBTREE
If test returns SKIP_SUBTREE, then the current component and all of its descendants are skipped.

See Also:
Constant Field Values

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

Traversal

public Traversal()
Method Detail

act

protected abstract void act(Component c)
Defines the action to be performed on each node. Users of this class should override this method with behavior for their particular domain.

Parameters:
c - the component on which to perform this action.

preorder

public void preorder(Component c)
Invoke act(com.arsdigita.bebop.Component) on this component, and then do the same for each of its children for which the supplied test condition is true.

Parameters:
c - the component on which to call act(com.arsdigita.bebop.Component).

test

protected int test(Component c)
The default component test returns PERFORM_ACTION to act on all components in the tree. Override this method to supply your own component test.

Parameters:
c - the component to test
Returns:
by default returns PERFORM_ACTION on all components.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC