|
Jive Forums API (5.5.20.2-oracle) 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 TreeWalker
public int getChildCount(ForumMessage parent)
TreeWalker
getChildCount
in interface TreeWalker
parent
- a node in the tree, obtained from this data source.
public boolean hasParent(ForumMessage message)
TreeWalker
child
message has a parent message.
hasParent
in interface TreeWalker
message
- the message.
public ForumMessage getParent(ForumMessage message) throws ForumMessageNotFoundException
TreeWalker
child
ForumMessage.
getParent
in interface TreeWalker
ForumMessageNotFoundException
- 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
TreeWalker
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.
getChild
in interface TreeWalker
message
- 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)
TreeWalker
TreeWalker.getRecursiveChildren(ForumMessage)
method.
getChildren
in interface TreeWalker
parent
- the parent message.
public java.util.Iterator getRecursiveMessages()
TreeWalker
1 |-- 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 TreeWalker
public java.util.Iterator getRecursiveChildren(ForumMessage parent)
TreeWalker
1 |-- 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 TreeWalker
parent
- the parent message.
public int getMessageDepth(ForumMessage message)
TreeWalker
1 |-- 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 TreeWalker
message
- the message to determine the depth of.
public int getRecursiveChildCount(ForumMessage parent)
TreeWalker
getRecursiveChildCount
in interface TreeWalker
parent
.public int getIndexOfChild(ForumMessage parent, ForumMessage child)
TreeWalker
4 |-- 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 TreeWalker
parent
- the parent message.child
- the child message to get the index for.
public boolean isLeaf(ForumMessage message)
TreeWalker
isLeaf
in interface TreeWalker
message
- 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.ExternalizableLite
java.io.IOException
public void writeExternal(java.io.DataOutput out) throws java.io.IOException
writeExternal
in interface com.tangosol.io.ExternalizableLite
java.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 |