Access keys

TraverseTreeEnumerator

Kind of class: class
Inherits from: TreeEnumerator < Enumerator
Version: 20 July 2005
Author: Arthur Clemens
Classpath: data.tree.TraverseTreeEnumerator
File last modified: Monday, 25 July 2005, 00:40:12
Enhanced tree enumerator, with traversal options (traverse children, loop and skip root), a delegate to validate new states and dispatching of update events.


About traverse options, see TraverseTreeOptions.
To do:
When setting a new root, should the depths of the containing nodes be relative to root's depth? For instance if I set a node with depth 2 to root, should the next node of depth 3 be regarded as a node of depth 1?
Events broadcast to listeners:
TraverseTreeEnumeratorEvent with type: UPDATE If the delegate validation method exists and only if the delegate method returns true.

Constructor

TraverseTreeEnumerator

function TraverseTreeEnumerator (
inRootNode:TreeNode, inTraverseOptions:Number)
Creates a new TraverseTreeEnumerator and initializes it for dispatching events.
Parameters:
inRootNode :
the root node of the enumerator; you may pass any node of the tree if the enumerator should start at that root - but the enumerator will traverse that branch only and will not traverse upwards to a node with a lower depth.
inTraverseOptions:
Tells the enumerator how to do traversing; see TraverseTreeOptions. Default set to TraverseTreeOptions.TRAVERSE_CHILDREN.

Instance properties

addEventListener

addEventListener:Function
(read,write)

removeEventListener

removeEventListener:Function
(read,write)

traverseOptions

traverseOptions:Number
(read,write)
The traversal options; see TraverseTreeOptions.

Instance methods

getNextNodeWithDepth

function getNextNodeWithDepth (
inDepth:Number, inTraverseOptions:Number) : TreeNode
Gets the next node with the given depth and set the current node to the found node.
Parameters:
inDepth :
the hierarchical depth of the node; see TreeNode.depth
inTraverseOptions:
(optional): the traversal options (see TraverseTreeOptions); if not passed, the stored mTraverseOptions are used
Returns:
If found, the return value of update; null if not found.

getNextObject

function getNextObject (
inTraverseOptions:Number) : TreeNode
Moves the enumerator one position forward and returns that node.
Parameters:
inTraverseOptions:
(optional): the traversal options (see TraverseTreeOptions); if not passed, the stored mTraverseOptions are used
Returns:
The return value of update.

getPreviousObject

function getPreviousObject (
inTraverseOptions:Number) : TreeNode
Moves the enumerator one position backward and returns that node.
Parameters:
inTraverseOptions:
(optional): the traversal options (see TraverseTreeOptions); if not passed, the stored mTraverseOptions are used
Returns:
The return value of update.

hasNextObject

function hasNextObject (
inTraverseOptions:Number) : Boolean
Checks if there is an object after the current object.
Returns:
True: there is a next object; false: the current object is the last.

setDelegate

function setDelegate (
inDelegateObject:Object, inDelegateMethod:String) : Void
A delegate validation method is called in update when a delegate object is set. The delegate's validation method is called to evaluate the new node before it is set.
Parameters:
inDelegateObject:
the owner of the delegate method
inDelegateMethod:
node validation method; this method should accept a TreeNode as parameter and return a Boolean to indicate the node's validity.