Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.proxy
Class TreeWalkerProxy

java.lang.Object
  extended by com.jivesoftware.forum.proxy.TreeWalkerProxy
All Implemented Interfaces:
TreeWalker

public class TreeWalkerProxy
extends java.lang.Object
implements TreeWalker

Protection proxy for TreeWalker ojbects.


Constructor Summary
TreeWalkerProxy(TreeWalker treeWalker, AuthToken authToken, Permissions permissions)
           
 
Method Summary
 ForumMessage getChild(ForumMessage parent, int index)
          Returns the child of parent at index index in the parent's child array.
 int getChildCount(ForumMessage parent)
          Returns the number of children of parent.
 java.util.Iterator getChildren(ForumMessage parent)
          Returns an Iterator for all the child messages of the parent.
 int getIndexOfChild(ForumMessage parent, ForumMessage child)
          Returns the index of child in parent.
 int getMessageDepth(ForumMessage message)
          Returns the depth of a message in the message tree hierarchy.
 ForumMessage getParent(ForumMessage child)
          Returns the parent of the child ForumMessage.
 int getRecursiveChildCount(ForumMessage parent)
          Returns the total number of recursive children of a parent.
 java.util.Iterator getRecursiveChildren(ForumMessage parent)
          Returns an Iterator for all child messages (and sub-children, etc) of the parent.
 java.util.Iterator getRecursiveMessages()
          Returns an Iterator for all messages in the thread in depth-first order.
 ForumMessage getRoot()
          Returns the root of the tree.
 boolean hasParent(ForumMessage child)
          Returns true if the child message has a parent message.
 boolean isLeaf(ForumMessage node)
          Returns true if node is a leaf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeWalkerProxy

public TreeWalkerProxy(TreeWalker treeWalker,
                       AuthToken authToken,
                       Permissions permissions)
Method Detail

getRoot

public ForumMessage getRoot()
Description copied from interface: TreeWalker
Returns the root of the tree. Returns null only if the tree has no nodes.

Specified by:
getRoot in interface TreeWalker
Returns:
the root of the tree

hasParent

public boolean hasParent(ForumMessage child)
Description copied from interface: TreeWalker
Returns true if the child message has a parent message.

Specified by:
hasParent in interface TreeWalker
Parameters:
child - the message.
Returns:
true if the message has a parent.

getParent

public ForumMessage getParent(ForumMessage child)
                       throws ForumMessageNotFoundException
Description copied from interface: TreeWalker
Returns the parent of the child ForumMessage.

Specified by:
getParent in interface TreeWalker
Returns:
the parent message of child.
Throws:
ForumMessageNotFoundException - if child does not have a parent, or if the parent message could not be loaded for any other reason.

getChild

public ForumMessage getChild(ForumMessage parent,
                             int index)
                      throws ForumMessageNotFoundException
Description copied from interface: TreeWalker
Returns the child of parent at index index in the parent's child array. The index must be a valid one, that is: index >= 0, and index < getChildCount(parent). If the index is not valid, or if the child could not be loaded for any other reason, a ForumMessageNotFoundException will be thrown.

Specified by:
getChild in interface TreeWalker
Parameters:
parent - the parent message.
index - the index of the child.
Returns:
the child of parent at index.
Throws:
ForumMessageNotFoundException - if the index was invalid or the child could not be loaded for any other reason.

getChildren

public java.util.Iterator getChildren(ForumMessage parent)
Description copied from interface: TreeWalker
Returns an Iterator for all the child messages of the parent. This method only considers direct descendants of the parent message and not sub-children. To get an iterator for the full hierarchy of children for a parent message, use the TreeWalker.getRecursiveChildren(ForumMessage) method.

Specified by:
getChildren in interface TreeWalker
Parameters:
parent - the parent message.
Returns:
an Iterator for the children of parent.

getRecursiveMessages

public java.util.Iterator getRecursiveMessages()
Description copied from interface: TreeWalker
Returns an Iterator for all messages in the thread in depth-first order. For example, consider the following message tree:
   1
   |-- 3
   |-- |-- 4
   |-- |-- |-- 7
   |-- |-- |-- |-- 10
   |-- |-- 6
   |-- |-- 8
   |-- 5
 
Calling getRecursiveMessages() on the tree above would return the sequence 1, 3, 4, 7, 10, 6, 8, 5. This method is a powerful way to show the full tree of messages, especially in combination with the TreeWalker.getMessageDepth(ForumMessage) method.

Specified by:
getRecursiveMessages in interface TreeWalker
Returns:
an Iterator for all messages in the thread in depth-first order.

getRecursiveChildren

public java.util.Iterator getRecursiveChildren(ForumMessage parent)
Description copied from interface: TreeWalker
Returns an Iterator for all child messages (and sub-children, etc) of the parent. Messages will be returned depth-first. For example, consider the following message tree:
   1
   |-- 3
   |-- |-- 4
   |-- |-- |-- 7
   |-- |-- |-- |-- 10
   |-- |-- 6
   |-- |-- 8
   |-- 5
 
Calling getRecursiveChildren(3) on the tree above would return the sequence 4, 7, 10, 6, 8. This method is a powerful way to show all children of a message, especially in combination with the TreeWalker.getMessageDepth(ForumMessage) method.

Specified by:
getRecursiveChildren in interface TreeWalker
Parameters:
parent - the parent message.
Returns:
an Iterator for all the recursive children of the parent.

getMessageDepth

public int getMessageDepth(ForumMessage message)
Description copied from interface: TreeWalker
Returns the depth of a message in the message tree hierarchy. The root message is always at depth 0. For example, consider the following message tree:
   1
   |-- 3
   |-- |-- 4
   |-- |-- |-- 7
 
The depth of message 4 is 2, the depth of message 7 is 3, etc. This method is useful in combination with the TreeWalker.getRecursiveChildren(ForumMessage) Iterator to build a UI of hierarchical messages.

Specified by:
getMessageDepth in interface TreeWalker
Parameters:
message - the message to determine the depth of.
Returns:
the depth of the message in the message tree hiearchy.

getChildCount

public int getChildCount(ForumMessage parent)
Description copied from interface: TreeWalker
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children.

Specified by:
getChildCount in interface TreeWalker
Parameters:
parent - a node in the tree, obtained from this data source.
Returns:
the number of children of the node parent.

getRecursiveChildCount

public int getRecursiveChildCount(ForumMessage parent)
Description copied from interface: TreeWalker
Returns the total number of recursive children of a parent. Returns 0 if there are no children. This method is not intended to aid in navigation of a Thread but is included as an added utility.

Specified by:
getRecursiveChildCount in interface TreeWalker
Returns:
the recursive count of the children of parent.

getIndexOfChild

public int getIndexOfChild(ForumMessage parent,
                           ForumMessage child)
Description copied from interface: TreeWalker
Returns the index of child in parent. This method does not deal with the indexes of sub-children of parents. For example, take the following tree:
   4
   |-- 2
   |-- |-- 1
   |-- |-- 6
   |-- |-- 8
   |-- 5
 
In this example, getIndexOfChild(4, 2) would return 0, getIndexOfChild(4, 5) would return 1, and getIndexOfChild(2, 8) would return 2. getIndexOfChild(4, 8) -- NOT VALID

Specified by:
getIndexOfChild in interface TreeWalker
Parameters:
parent - the parent message.
child - the child message to get the index for.
Returns:
the index of child in the list of siblings under parent.

isLeaf

public boolean isLeaf(ForumMessage node)
Description copied from interface: TreeWalker
Returns true if node is a leaf. A node is a leaf when it has no children messages.

Specified by:
isLeaf in interface TreeWalker
Parameters:
node - a node in the tree, obtained from this data source
Returns:
true if node is a leaf

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.