org.zkoss.pivot.util
Class Trees

java.lang.Object
  extended by org.zkoss.pivot.util.Trees

public class Trees
extends java.lang.Object

Utility class for PivotHeaderTree

Author:
simonpai

Nested Class Summary
static interface Trees.NodeRunner
           
static class Trees.TreeTravCtx
           
 
Constructor Summary
Trees()
           
 
Method Summary
static Calculator getCalculator(PivotField field, int index)
          Retrieves the Calculator from a field by index.
static Calculator getCalculator(PivotHeaderNode node, int index)
          Retrieves the Calculator from a node by index.
static java.lang.Object getKey(PivotField field, java.lang.Object value)
          Returns the key defined by GroupHandler on the field, if any.
static PivotHeaderNode getNode(PivotHeaderTree tree, int[] indicies)
          Seek down PivotHeaderNode by indices.
static PivotHeaderNode getNode(PivotHeaderTree tree, java.lang.Object[] keys)
          Seek down PivotHeaderNode based on keys.
static int getSize(PivotHeaderTree tree)
          Compute the size of tree.
static int getSize(PivotHeaderTree tree, boolean open)
          Compute the size of tree.
static int getSubtotalCount(PivotField field)
          Return the count of subtotal Calculators on a field
static int getSubtotalCount(PivotHeaderNode node)
          Return the count of subtotal Calculators on a node
static int getSubtotalCount(PivotHeaderNode node, boolean open)
          Return the count of subtotal Calculators on a node
static boolean isRoot(PivotHeaderNode node)
          Return true if node is root.
static boolean isTerminal(PivotHeaderNode node)
          Return true if node is leaf or closed.
static void openDown(PivotHeaderNode node, boolean open)
          Recursively set open or close to a node and all its descendants.
static void traverse(PivotHeaderTree tree, boolean asIfOpenAll, int offset, int limit, Trees.NodeRunner runner)
          Traverse the tree in a depth first, children first fashion, while concern paging. runner will not be invoked on nodes that are completely out of range.
static void traverse(PivotHeaderTree tree, boolean open, Trees.NodeRunner runner)
          Traverse the tree in a depth first, children first fashion.
static void traverse(PivotHeaderTree tree, Trees.NodeRunner runner)
          Traverse the tree in a depth first, children first fashion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Trees

public Trees()
Method Detail

getSubtotalCount

public static int getSubtotalCount(PivotHeaderNode node)
Return the count of subtotal Calculators on a node


getSubtotalCount

public static int getSubtotalCount(PivotHeaderNode node,
                                   boolean open)
Return the count of subtotal Calculators on a node

Parameters:
open - compute as if the node were always open.

getSubtotalCount

public static int getSubtotalCount(PivotField field)
Return the count of subtotal Calculators on a field


getCalculator

public static Calculator getCalculator(PivotHeaderNode node,
                                       int index)
Retrieves the Calculator from a node by index.


getCalculator

public static Calculator getCalculator(PivotField field,
                                       int index)
Retrieves the Calculator from a field by index.


getKey

public static java.lang.Object getKey(PivotField field,
                                      java.lang.Object value)
Returns the key defined by GroupHandler on the field, if any.


getSize

public static int getSize(PivotHeaderTree tree)
Compute the size of tree. Subtotal Calculator numbers are taken into account. A full traversal of the tree will be performed upon calling this method.


getSize

public static int getSize(PivotHeaderTree tree,
                          boolean open)
Compute the size of tree. Subtotal Calculator numbers are taken into account. A full traversal of the tree will be performed upon calling this method.

Parameters:
open - compute as if all nodes were open

isTerminal

public static boolean isTerminal(PivotHeaderNode node)
Return true if node is leaf or closed.


isRoot

public static boolean isRoot(PivotHeaderNode node)
Return true if node is root.


getNode

public static PivotHeaderNode getNode(PivotHeaderTree tree,
                                      java.lang.Object[] keys)
Seek down PivotHeaderNode based on keys.

Returns:
null if not found

getNode

public static PivotHeaderNode getNode(PivotHeaderTree tree,
                                      int[] indicies)
Seek down PivotHeaderNode by indices.

Returns:
null if not found

openDown

public static void openDown(PivotHeaderNode node,
                            boolean open)
Recursively set open or close to a node and all its descendants.


traverse

public static void traverse(PivotHeaderTree tree,
                            Trees.NodeRunner runner)
Traverse the tree in a depth first, children first fashion.


traverse

public static void traverse(PivotHeaderTree tree,
                            boolean open,
                            Trees.NodeRunner runner)
Traverse the tree in a depth first, children first fashion.

Parameters:
open - traverse as if all nodes were open.

traverse

public static void traverse(PivotHeaderTree tree,
                            boolean asIfOpenAll,
                            int offset,
                            int limit,
                            Trees.NodeRunner runner)
Traverse the tree in a depth first, children first fashion, while concern paging. runner will not be invoked on nodes that are completely out of range.

Parameters:
asIfOpenAll - traverse as if all nodes were open.
offset -
limit - no limit if negative


Copyright © 2013. All Rights Reserved.