DOMTraversal Class Reference

List of all members.

Detailed Description

Encapsulates the logic of walking the DOM tree. The traversal sends messages to a delegate for each node in the tree.

See the documentation for setDelegate: for more info on how the delegate should be set up.


Public Member Functions

(id)  initWithContextNode:
(void)  setDelegate:
(void)  setUserInfo:
(void)  start

Static Public Member Functions

(void)  startTraversalForContextNode:delegate:userInfo:

Protected Attributes

id< DOMNode contextNode
id  delegate
id  userInfo

Member Function Documentation

- (id) initWithContextNode: (id< DOMNode >)  node  
 

- (void) setDelegate: (id)  delegate  
 

Set the delegate that will recieve messages during the traversal.

The delgate should respond to any combination of these messages:

  • visitNode:userInfo: or preorderVisitNode:userInfo: sent before the children of the node are traversed, i.e preorder traversal

  • postorderVisitNode:userInfo: sent after the children of the node are traversed, i.e postorder traversal

The first argument is a node (id < DOMNode >), the user info argument is a generic object pointer (id). The return type is void.

Don't implement both visitNode:userInfo: and preorderVisitNode:userInfo:, that would be bad and confusing. You can see visitNode:userInfo: as an alias for preorderVisitNode:userInfo: that can be used when you only want to recieve messages before children are traversed, and would like a shorter and slightly more appropriate name for the delegate method.

visitNode:userInfo: will NOT be called if the delegate responds to preorderVisitNode:userInfo:.

- (void) setUserInfo: (id)  userInfo  
 

The user info pointer will be sent to the delegate for each visited node.

- (void) start  
 

Starts the traversal.

+ (void) startTraversalForContextNode: (id< DOMNode >)  node
delegate: (id)  delegate
userInfo: (id)  userInfo
 
 

Convenience method for creating the traversal object, setting context node, delegate and user info object and starting the traversal.

Member Data Documentation

- (id<DOMNode>) contextNode [protected]
 

- (id) delegate [protected]
 

- (id) userInfo [protected]