|
Jive Forums API (5.5.8) Developer Javadocs | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jivesoftware.forum.database.DbTreeWalker
public class DbTreeWalker
Database implementation of the TreeWalker interface. It caches the tree structure in memory for fastest access.
One important caveat is the following: we assumes that no child message will have a creation date that is earlier in time than its parent message. The assumption lets us make some big optimization gains and is safe as long as all the data is created in Jive Forums. The only possible problem is if data is imported from other forum apps that don't follow this behavior (not very likely).
| Constructor Summary | |
|---|---|
DbTreeWalker()
Constructor for internal use only. |
|
DbTreeWalker(DbForumThread thread)
Creates a new TreeWalker instance. |
|
| Method Summary | |
|---|---|
void |
addChild(ForumMessage parent,
ForumMessage child)
Adds a child message to an existing parent. |
ForumMessage |
getChild(ForumMessage message,
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 message)
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. |
int |
getSize()
|
boolean |
hasParent(ForumMessage message)
Returns true if the child message has a parent message. |
boolean |
isLeaf(ForumMessage message)
Returns true if node is a leaf. |
void |
readExternal(java.io.DataInput in)
|
void |
writeExternal(java.io.DataOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DbTreeWalker(DbForumThread thread)
public DbTreeWalker()
| Method Detail |
|---|
public ForumMessage getRoot()
TreeWalker
getRoot in interface TreeWalkerpublic int getChildCount(ForumMessage parent)
TreeWalker
getChildCount in interface TreeWalkerparent - a node in the tree, obtained from this data source.
public boolean hasParent(ForumMessage message)
TreeWalkerchild message has a parent message.
hasParent in interface TreeWalkermessage - the message.
public ForumMessage getParent(ForumMessage message)
throws ForumMessageNotFoundException
TreeWalkerchild ForumMessage.
getParent in interface TreeWalkerForumMessageNotFoundException - if child does not have a parent,
or if the parent message could not be loaded for any other reason.
public ForumMessage getChild(ForumMessage message,
int index)
throws ForumMessageNotFoundException
TreeWalkerindex >= 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.
getChild in interface TreeWalkermessage - the parent message.index - the index of the child.
ForumMessageNotFoundException - if the index was invalid or the
child could not be loaded for any other reason.public java.util.Iterator getChildren(ForumMessage parent)
TreeWalkerTreeWalker.getRecursiveChildren(ForumMessage) method.
getChildren in interface TreeWalkerparent - the parent message.
public java.util.Iterator getRecursiveMessages()
TreeWalker1 |-- 3 |-- |-- 4 |-- |-- |-- 7 |-- |-- |-- |-- 10 |-- |-- 6 |-- |-- 8 |-- 5Calling 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.
getRecursiveMessages in interface TreeWalkerpublic java.util.Iterator getRecursiveChildren(ForumMessage parent)
TreeWalker1 |-- 3 |-- |-- 4 |-- |-- |-- 7 |-- |-- |-- |-- 10 |-- |-- 6 |-- |-- 8 |-- 5Calling 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.
getRecursiveChildren in interface TreeWalkerparent - the parent message.
public int getMessageDepth(ForumMessage message)
TreeWalker1 |-- 3 |-- |-- 4 |-- |-- |-- 7The 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.
getMessageDepth in interface TreeWalkermessage - the message to determine the depth of.
public int getRecursiveChildCount(ForumMessage parent)
TreeWalker
getRecursiveChildCount in interface TreeWalkerparent.
public int getIndexOfChild(ForumMessage parent,
ForumMessage child)
TreeWalker4 |-- 2 |-- |-- 1 |-- |-- 6 |-- |-- 8 |-- 5In 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
getIndexOfChild in interface TreeWalkerparent - the parent message.child - the child message to get the index for.
public boolean isLeaf(ForumMessage message)
TreeWalker
isLeaf in interface TreeWalkermessage - a node in the tree, obtained from this data source
public void readExternal(java.io.DataInput in)
throws java.io.IOException
readExternal in interface com.tangosol.io.ExternalizableLitejava.io.IOException
public void writeExternal(java.io.DataOutput out)
throws java.io.IOException
writeExternal in interface com.tangosol.io.ExternalizableLitejava.io.IOException
public void addChild(ForumMessage parent,
ForumMessage child)
parent - the parent message.child - the new child message.public int getSize()
|
Jive Forums Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||