|
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.renderer.filter.wiki.list.WikiList
public class WikiList
A simple tree structure for lists.
The tree holds a maximum of 65534 nodes. It is not intended to be thread-safe. Based on algorithm found in the book "Introduction To Algorithms" by Cormen et all, MIT Press, 1997.
| Field Summary | |
|---|---|
protected ListItem[] |
keys
|
protected char[] |
leftChildren
|
protected char |
nextIndex
|
protected char[] |
rightSiblings
|
protected ListItem |
rootItem
|
| Constructor Summary | |
|---|---|
WikiList()
Creates a new wiki list tree. |
|
| Method Summary | |
|---|---|
void |
addChild(ListItem parent,
ListItem newChild)
Adds a child list item to the tree. |
protected int |
fillDepthKeys(char startIndex,
ListItem[] depthKeys,
int cursor)
Recursive method that fills the depthKeys array with all the child keys in the tree in depth first order. |
protected char |
findDepth(ListItem item,
char startIndex,
int[] depth)
Identical to the findKey method, but it also keeps track of the depth. |
protected char |
findKey(ListItem item,
char startIndex)
Returns the index of the specified value, or 0 if the item could not be found. |
ListItem |
getChild(ListItem parent,
int index)
Returns a child of parent at index index. |
int |
getChildCount(ListItem parent)
Returns the number of children of parent. |
ListItem[] |
getChildren(ListItem parent)
Returns an array of the children of the parent, or an empty array if there are no children or the parent is not in the tree. |
int |
getDepth(ListItem item)
Returns the depth in the tree that the element can be found at or -1 if the element is not in the tree. |
int |
getIndexOfChild(ListItem parent,
ListItem child)
Returns the index of child in parent or
-1 if child is not a child of parent. |
protected char |
getLeftSiblingIndex(char index)
Returs the left sibling index of index. |
ListItem |
getParent(ListItem child)
Returns a parent of child, or null if there is no parent. |
ListItem[] |
getRecursiveChildren(ListItem parent)
Returns the list items in the in the tree in depth-first order. |
ListItem[] |
getRecursiveKeys()
Returns the list items in the in the tree in depth-first order. |
ListItem |
getRootItem()
Returns the dummy root item that is used to create the tree (since the tree is required to have a single root node). |
boolean |
isLeaf(ListItem item)
Returns true if the tree node is a leaf. |
ListItem[] |
keys()
Returns the list items in the tree. |
protected void |
resizeTree()
|
void |
toString(java.lang.StringBuffer buffer,
RenderContext renderContext)
Returns the list rendered out to html |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ListItem[] keys
protected char[] leftChildren
protected char[] rightSiblings
protected char nextIndex
protected ListItem rootItem
| Constructor Detail |
|---|
public WikiList()
| Method Detail |
|---|
public ListItem getRootItem()
public void addChild(ListItem parent,
ListItem newChild)
parent - the parent to add the new value to.newChild - new child to add to the tree.public ListItem getParent(ListItem child)
child, or null if there is no parent.
child - the child item to return the parent for
child, or null if there is no parent.
public ListItem getChild(ListItem parent,
int index)
parent at index index.
parent - the parent itemindex - the child's index in the parent's children
parent at index index.public int getChildCount(ListItem parent)
parent.
parent - the parent item
parent.public ListItem[] getChildren(ListItem parent)
parent - the parent to get the children of.
public int getIndexOfChild(ListItem parent,
ListItem child)
child in parent or
-1 if child is not a child of parent.
parent - the parent itemchild - the child item
child in parent or
-1 if child is not a child of parent.public int getDepth(ListItem item)
item - the item to find the depth for.
public ListItem[] getRecursiveKeys()
1 |-- 3 |-- |-- 4 |-- |-- |-- 7 |-- |-- 6 |-- 5Then this method would return the sequence: 1, 3, 4, 7, 6, 5.
public ListItem[] getRecursiveChildren(ListItem parent)
1 |-- 3 |-- |-- 4 |-- |-- |-- 7 |-- |-- 6 |-- 5Then this method would return the sequence: 1, 3, 4, 7, 6, 5.
parent - the parent to get children of.
public boolean isLeaf(ListItem item)
item - the item to check
item has no children.public ListItem[] keys()
protected char findKey(ListItem item,
char startIndex)
item - the item to search for.startIndex - the index in the tree to start searching at. Pass in
the root index to search the entire tree.
protected char findDepth(ListItem item,
char startIndex,
int[] depth)
item - the item to search for.startIndex - the index in the tree to start searching at. Pass in
the root index to search the entire tree.depth - an array - only the first element is used to designate the depth of the item
protected int fillDepthKeys(char startIndex,
ListItem[] depthKeys,
int cursor)
startIndex - the starting index for the current recursive iteration.depthKeys - the array of depth-first keys that is being filled.cursor - the current index in the depthKeys array.
protected char getLeftSiblingIndex(char index)
index - the item's index
protected void resizeTree()
public void toString(java.lang.StringBuffer buffer,
RenderContext renderContext)
buffer - the buffer to write the rendered html torenderContext - the render context
|
Jive Forums Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||