com.iplanet.jato.model
Class TreeModelBase

java.lang.Object
  |
  +--com.iplanet.jato.model.TreeModelBase
All Implemented Interfaces:
Model, TreeModel
Direct Known Subclasses:
TestTreeModelImpl

public abstract class TreeModelBase
extends java.lang.Object
implements TreeModel

Partial implementation of the TreeModel interface. Currently, the algorithm for depth-first traversal is implemented in this class; subclasses need only define the operations specific to their backing data structures to allow iteration over the nodes of those structures. There is no requirement to use this implementation; it exists purely for convenience.

Version:
JATO/1.2.2 $Id: TreeModelBase.java,v 1.9 2002/03/16 03:26:32 todd Exp $

Fields inherited from interface com.iplanet.jato.model.TreeModel
BREADTH_FIRST_TRAVERSAL, DEPTH_FIRST_TRAVERSAL, NEXT_CHILD, NEXT_SIBLING, ROOT_NODE_LEVEL, UNDEFINED_NODE_LEVEL
 
Constructor Summary
TreeModelBase()
          Default constructor
 
Method Summary
abstract  void beforeRoot()
          In addition to making the root node the next available node, this method should set the node level to UNDEFINED_NODE_LEVEL and call setIterationComplete(false) if there are children available to iterator over
protected  void clearCurrentNode()
          Clears the currently cached node object, and sets the current node level to be undefined.
protected  void decrementNodeLevel()
          Decrements the current node level by one level.
abstract  boolean firstChild()
          / public abstract boolean previousNode() throws ModelControlException; /** The implementation of this method should call incrementNodeLevel()
protected  java.lang.Object getCurrentNode()
          Gets the currently cached node object.
abstract  java.lang.String getNodeID()
          Return a unique ID for the current node within the backing data structure.
 int getNodeLevel()
          Return the current node level, meaning the an index indicating how far this node is removed from being the root of the tree.
abstract  java.lang.String getNodeName()
          Return the logical name of the current node
abstract  java.lang.String getNodeType()
          Return the logical type of the current node
 int getTraversalType()
          Return the tree traversal type.
protected  void incrementNodeLevel()
          Increments the current node level by one level.
abstract  boolean isChildNode()
          Check if the current node is a child of a parent node
 boolean isIterationComplete()
          Indicates whether the current iteration cycle has been completed
abstract  boolean isParentNode()
          Check if the current node is a parent of other nodes
 boolean nextNode()
          Subclasses need not override this method if they wish to use the standard node traversal implementation provided by this class
 boolean nextNode(int nextNode)
          Subclasses need not override this method if they wish to use the standard node traversal implementation provided by this class
abstract  boolean nextSibling()
          The implementation of this method should leave the node level unchanged
abstract  boolean parent()
          The implementation of this method should call decrementNodeLevel()
abstract  void root()
          In addition to making the root node the current node, this method should set the node level to ROOT_NODE_LEVEL
protected  void setCurrentNode(java.lang.Object value)
          Sets the currently cached node object.
protected  void setIterationComplete(boolean value)
          Sets whether the current iteration cycle has been completed.
protected  void setNodeLevel(int value)
          Sets the current node level.
 void setTraversalType(int value)
          Sets the tree traversal type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.iplanet.jato.model.Model
getName, getValue, getValues, setName, setValue, setValues
 

Constructor Detail

TreeModelBase

public TreeModelBase()
Default constructor
Method Detail

getNodeName

public abstract java.lang.String getNodeName()
                                      throws ModelControlException
Description copied from interface: TreeModel
Return the logical name of the current node
Specified by:
getNodeName in interface TreeModel

getNodeType

public abstract java.lang.String getNodeType()
                                      throws ModelControlException
Description copied from interface: TreeModel
Return the logical type of the current node
Specified by:
getNodeType in interface TreeModel

getNodeID

public abstract java.lang.String getNodeID()
Description copied from interface: TreeModel
Return a unique ID for the current node within the backing data structure. This ID should unambiguously identify the current node within the entire model. In some model implementations and usages, this ID will need to unambiguously identify the node across requests, and even across instantiations of the model instances. In some cases, a fully qualified path to the node will be sufficient; in other cases, a more unique identifier, possible assigned by the model, will be required.
Specified by:
getNodeID in interface TreeModel

isParentNode

public abstract boolean isParentNode()
Description copied from interface: TreeModel
Check if the current node is a parent of other nodes
Specified by:
isParentNode in interface TreeModel

isChildNode

public abstract boolean isChildNode()
Description copied from interface: TreeModel
Check if the current node is a child of a parent node
Specified by:
isChildNode in interface TreeModel

getNodeLevel

public int getNodeLevel()
Description copied from interface: TreeModel
Return the current node level, meaning the an index indicating how far this node is removed from being the root of the tree. The root node has a node level of 0. A child of the root would have a node level of 1, and a child of that child would have a root node of 2, etc.
Specified by:
getNodeLevel in interface TreeModel

setNodeLevel

protected void setNodeLevel(int value)
Sets the current node level. Subclasses should set the node level whenever they change the node position.

incrementNodeLevel

protected void incrementNodeLevel()
Increments the current node level by one level. Subclasses should increment the node level as needed when changing node position.

decrementNodeLevel

protected void decrementNodeLevel()
Decrements the current node level by one level. Subclasses should increment the node level as needed when changing node position.

getTraversalType

public int getTraversalType()
                     throws ModelControlException
Description copied from interface: TreeModel
Return the tree traversal type. The traversal type affects the way in which the various node iteration methods traverse the backing tree structure. A particular implementation need not support more than a single traversal type, which will usually be DEPTH_FIRST_TRAVERSAL .
Specified by:
getTraversalType in interface TreeModel

setTraversalType

public void setTraversalType(int value)
                      throws ModelControlException
Description copied from interface: TreeModel
Sets the tree traversal type. The traversal type affects the way in which the various node iteration methods traverse the backing tree structure. A particular implementation need not support more than a single traversal type, which will usually be DEPTH_FIRST_TRAVERSAL .
Specified by:
setTraversalType in interface TreeModel

beforeRoot

public abstract void beforeRoot()
                         throws ModelControlException
In addition to making the root node the next available node, this method should set the node level to UNDEFINED_NODE_LEVEL and call setIterationComplete(false) if there are children available to iterator over
Specified by:
beforeRoot in interface TreeModel

root

public abstract void root()
                   throws ModelControlException
In addition to making the root node the current node, this method should set the node level to ROOT_NODE_LEVEL
Specified by:
root in interface TreeModel

nextNode

public boolean nextNode()
                 throws ModelControlException
Subclasses need not override this method if they wish to use the standard node traversal implementation provided by this class
Specified by:
nextNode in interface TreeModel

nextNode

public boolean nextNode(int nextNode)
                 throws ModelControlException
Subclasses need not override this method if they wish to use the standard node traversal implementation provided by this class
Specified by:
nextNode in interface TreeModel

firstChild

public abstract boolean firstChild()
                            throws ModelControlException
/ public abstract boolean previousNode() throws ModelControlException; /** The implementation of this method should call incrementNodeLevel()

parent

public abstract boolean parent()
                        throws ModelControlException
The implementation of this method should call decrementNodeLevel()

nextSibling

public abstract boolean nextSibling()
                             throws ModelControlException
The implementation of this method should leave the node level unchanged

getCurrentNode

protected java.lang.Object getCurrentNode()
Gets the currently cached node object. Subclasses can set any arbitrary object as the current node object, and retrieve it later. This method is a convenience method solely for use by subclasses; it is not used by the existing implementation of this class.

setCurrentNode

protected void setCurrentNode(java.lang.Object value)
Sets the currently cached node object. Subclasses can set any arbitrary object as the current node object, and retrieve it later. This method is a convenience method solely for use by subclasses; it is not used by the existing implementation of this class.

clearCurrentNode

protected void clearCurrentNode()
Clears the currently cached node object, and sets the current node level to be undefined. This method is a convenience method solely for use by subclasses; it is not used by the existing implementation of this class.

isIterationComplete

public boolean isIterationComplete()
Indicates whether the current iteration cycle has been completed

setIterationComplete

protected void setIterationComplete(boolean value)
Sets whether the current iteration cycle has been completed. The root() must call this method with a value of false to reset the flag before iteration begins.