|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.squashtest.csp.tm.domain.library.structures.LibraryTree<T>
public class LibraryTree<T extends TreeNode<T>>
This tree can have multiple roots and internally its structure is layered. The details are :
| Nested Class Summary | |
|---|---|
class |
LibraryTree.TreeNodePair
A TreeNodePair is a scaffolding class which is mainly used when initializing a tree. |
| Field Summary | |
|---|---|
protected Map<Integer,List<T>> |
layers
|
| Constructor Summary | |
|---|---|
LibraryTree()
|
|
| Method Summary | ||
|---|---|---|
void |
addNode(LibraryTree.TreeNodePair newPair)
Given a TreeNodePair (see documentation of the inner class for details), will add the child node to the tree. |
|
void |
addNode(Long parentKey,
T childNode)
Same than addNode(TreeNodePair), but the TreeNodePair parameter will be built using the parameter provided here. |
|
void |
addNodes(List<LibraryTree.TreeNodePair> unsortedFlatTree)
Accepts a list of TreeNodePair and will add all the nodes in that list (see TreeNodePair and TreeNode). |
|
|
collect(org.apache.commons.collections.Transformer transformer)
That method will gather arbitrary informations on every single nodes and return the list of the gathered informations. |
|
List<Long> |
collectKeys()
short hand for collect(Transformer) with a Transformer returning the data.key for each nodes. |
|
protected T |
createNewNode(T parent,
int depth,
T newNode)
|
|
void |
doBottomUp(org.apache.commons.collections.Closure closure)
Accepts a Closure that will be applied on the nodes using bottom-up exploration. |
|
void |
doTopDown(org.apache.commons.collections.Closure closure)
Accepts a Closure that will be applied on the nodes using top-down exploration. |
|
List<T> |
getAllNodes()
|
|
int |
getDepth()
return the depth of the tree, ie how many layers does the tree count. |
|
List<T> |
getLayer(Integer depth)
Given an integer, returns the layer at the corresponding depth in the tree. |
|
T |
getNode(Long key)
Accepts a identifier - aka key - and returns the corresponding node if found. |
|
void |
merge(List<T> mergeData)
Accepts a list of TreeNodes and use their data to update existing nodes data. |
|
LibraryTree.TreeNodePair |
newPair()
Returns a new instance of a TreeNodePair. |
|
LibraryTree.TreeNodePair |
newPair(Long parentKey,
T child)
An initializing version of newPair(). |
|
protected List<LibraryTree.TreeNodePair> |
sortData(List<LibraryTree.TreeNodePair> unsortedData)
This method accepts a list of TreeNodePair and returns the sorted version of that list. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Map<Integer,List<T extends TreeNode<T>>> layers
| Constructor Detail |
|---|
public LibraryTree()
| Method Detail |
|---|
public List<T> getLayer(Integer depth)
getDepth().
The layer is returned as a list of nodes.
depth - the depth of the layer we want an access to.
IndexOutOfBoundsExceptionpublic void addNode(LibraryTree.TreeNodePair newPair)
newPair - a TreeNodePair with informations regarding parent and child node included.
NoSuchElementException - if a parent node cannot be found.
public void addNode(Long parentKey,
T childNode)
addNode(TreeNodePair), but the TreeNodePair parameter will be built using the parameter provided here.
parentKey - the key designating the parent node.childNode - the child we want eventually to insert.public void addNodes(List<LibraryTree.TreeNodePair> unsortedFlatTree)
unsortedData - the flat representation of the tree.#sortData(List)}, TreeNode, TreeNodePairprotected List<LibraryTree.TreeNodePair> sortData(List<LibraryTree.TreeNodePair> unsortedData)
This method accepts a list of TreeNodePair and returns the sorted version of that list. Sorting means here that nodes will be grouped by layers and the layer will be ordered.
For each TreeNodePair d from the input list:
unsortedData - an unsorted list of TreeNodePair
TreeNode, TreeNodePair.public T getNode(Long key)
key - the key identifying a node
NoSuchElementException - if the node was not found.public void doBottomUp(org.apache.commons.collections.Closure closure)
Accepts a Closure that will be applied on the nodes using bottom-up exploration. The method will walk up the tree :
closure - code to apply on the nodes.public void doTopDown(org.apache.commons.collections.Closure closure)
Accepts a Closure that will be applied on the nodes using top-down exploration. The method will walk down the tree :
closure - code to apply on the nodes.public void merge(List<T> mergeData)
Accepts a list of TreeNodes and use their data to update existing nodes data. The TreeNodes of the input list are merely carrying informations : the key property will identify actual nodes in the tree and the rest of their data will be used to update the found nodes.
The particulars of how data will be merged depends on how the TreeNodes implement TreeNode.updateWith(TreeNode).
NoSuchElementException - if one of the node was not found.public <X> List<X> collect(org.apache.commons.collections.Transformer transformer)
That method will gather arbitrary informations on every single nodes and return the list of the gathered informations. What will be gathered and how it is done is defined in the
Transformer parameter. The tree will be processed top-down, ie, walked down (see doTopDown(Closure)).
X - the type of the data returned by the transformer.transformer - the code to be applied over all the nodes.
public List<Long> collectKeys()
short hand for collect(Transformer) with a Transformer returning the data.key for each nodes.
public List<T> getAllNodes()
public int getDepth()
protected T createNewNode(T parent,
int depth,
T newNode)
public LibraryTree.TreeNodePair newPair()
public LibraryTree.TreeNodePair newPair(Long parentKey,
T child)
newPair().
parentKey - the identifier of the parent node.child - the child node.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||