Package org.zkoss.pivot.util
Class Trees
- java.lang.Object
-
- org.zkoss.pivot.util.Trees
-
public class Trees extends Object
Utility class for PivotHeaderTree- Author:
- simonpai
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Trees.NodeRunner
static class
Trees.TreeTravCtx
-
Constructor Summary
Constructors Constructor Description Trees()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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 Object
getKey(PivotField field, 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, 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 fieldstatic int
getSubtotalCount(PivotHeaderNode node)
Return the count of subtotal Calculators on a nodestatic int
getSubtotalCount(PivotHeaderNode node, boolean open)
Return the count of subtotal Calculators on a nodestatic 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.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.
-
-
-
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 Object getKey(PivotField field, 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, 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
-
-