org.expasy.jpl.commons.collection.tree
Class TreeViewImpl<T>

java.lang.Object
  extended by org.expasy.jpl.commons.collection.tree.TreeViewImpl<T>
Type Parameters:
T - the node type.
All Implemented Interfaces:
TreeView<T>

public final class TreeViewImpl<T>
extends Object
implements TreeView<T>

A read-only tree view.

Version:
1.0
Author:
nikitin

Constructor Summary
TreeViewImpl(TreeNode<T> root)
           
 
Method Summary
static
<T,E extends TreeView<T>>
void
depthSearchFirst(E fromNode, Set<E> nodes, boolean isLeaveOnly)
          Recursive depth search first.
 TreeView<T> getChildAt(int index)
          
 List<? extends TreeView<T>> getChildren()
          
 T getData()
          
 Set<? extends TreeView<T>> getLeaves()
          
 Set<? extends TreeView<T>> getNodes()
          
 int getNumberOfChildren()
          
 TreeView<T> getParent()
          
 boolean isLeave()
          
 boolean isRoot()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeViewImpl

public TreeViewImpl(TreeNode<T> root)
Method Detail

getChildAt

public TreeView<T> getChildAt(int index)

Specified by:
getChildAt in interface TreeView<T>
Returns:
the child node at index.

getChildren

public List<? extends TreeView<T>> getChildren()

Specified by:
getChildren in interface TreeView<T>
Returns:
the direct children of the node.

getData

public T getData()

Specified by:
getData in interface TreeView<T>
Returns:
the node data.

getLeaves

public Set<? extends TreeView<T>> getLeaves()

Specified by:
getLeaves in interface TreeView<T>
Returns:
the tree leaves.

getNodes

public Set<? extends TreeView<T>> getNodes()

Specified by:
getNodes in interface TreeView<T>
Returns:
the tree nodes.

getNumberOfChildren

public int getNumberOfChildren()

Specified by:
getNumberOfChildren in interface TreeView<T>
Returns:
the number of children of this node.

getParent

public TreeView<T> getParent()

Specified by:
getParent in interface TreeView<T>
Returns:
the parent node.

isLeave

public boolean isLeave()

Specified by:
isLeave in interface TreeView<T>
Returns:
the parent node.

isRoot

public boolean isRoot()

Specified by:
isRoot in interface TreeView<T>
Returns:
true if root node.

depthSearchFirst

public static <T,E extends TreeView<T>> void depthSearchFirst(E fromNode,
                                                              Set<E> nodes,
                                                              boolean isLeaveOnly)
Recursive depth search first.

Parameters:
fromNode - the root node.
nodes - the found nodes.
isLeaveOnly - search only leaves if true.


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.