TUM CCSM Commons

edu.tum.cs.commons.tree
Class TreeUtils

java.lang.Object
  extended by edu.tum.cs.commons.tree.TreeUtils

public class TreeUtils
extends java.lang.Object

Utility class for tree construction.

Version:
$Rev: 26268 $
Author:
deissenb, $Author: juergens $
Rating:
GREEN Hash: 3CA3EEE13CB7C2935D6E01EE3AD9DA30

Constructor Summary
TreeUtils()
           
 
Method Summary
static
<T,K> T
createTree(java.util.Set<java.util.List<K>> paths, ITreeNodeHandler<T,K> handler)
          This method creates a tree from a set of paths.
static
<T> T
createTreeFromStrings(java.util.Set<java.lang.String> paths, java.lang.String separator, ITreeNodeHandler<T,java.lang.String> handler)
          Utility method for creating a tree from paths described by strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeUtils

public TreeUtils()
Method Detail

createTree

public static <T,K> T createTree(java.util.Set<java.util.List<K>> paths,
                                 ITreeNodeHandler<T,K> handler)
This method creates a tree from a set of paths.

Type Parameters:
T - the node type to be created
K - the key type used by the nodes
Parameters:
paths - a set of paths where each path is a list of path elements (keys)
handler - the handler used for creating the tree.
Returns:
The root node of the tree. The root node (as generated by ITreeNodeHandler.createRoot() is always returned, even if the set of paths is empty.

createTreeFromStrings

public static <T> T createTreeFromStrings(java.util.Set<java.lang.String> paths,
                                          java.lang.String separator,
                                          ITreeNodeHandler<T,java.lang.String> handler)
Utility method for creating a tree from paths described by strings.

Type Parameters:
T - the node type to be created
Parameters:
paths - a set of paths where each path is described by a path expression string, e.g. node1/node2/node3
separator - regular expression that defines the separator between path elements.
handler - the handler used for creating the tree.
Returns:
The root node of the tree. The root node (as generated by ITreeNodeHandler.createRoot() is always returned, even if the set of paths is empty.

TUM CCSM Commons

TUM CCSM Commons - 2.7