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 interfaceTrees.NodeRunnerstatic classTrees.TreeTravCtx
-
Constructor Summary
Constructors Constructor Description Trees()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CalculatorgetCalculator(PivotField field, int index)Retrieves the Calculator from a field by index.static CalculatorgetCalculator(PivotHeaderNode node, int index)Retrieves the Calculator from a node by index.static ObjectgetKey(PivotField field, Object value)Returns the key defined by GroupHandler on the field, if any.static PivotHeaderNodegetNode(PivotHeaderTree tree, int[] indicies)Seek down PivotHeaderNode by indices.static PivotHeaderNodegetNode(PivotHeaderTree tree, Object[] keys)Seek down PivotHeaderNode based on keys.static intgetSize(PivotHeaderTree tree)Compute the size of tree.static intgetSize(PivotHeaderTree tree, boolean open)Compute the size of tree.static intgetSubtotalCount(PivotField field)Return the count of subtotal Calculators on a fieldstatic intgetSubtotalCount(PivotHeaderNode node)Return the count of subtotal Calculators on a nodestatic intgetSubtotalCount(PivotHeaderNode node, boolean open)Return the count of subtotal Calculators on a nodestatic booleanisRoot(PivotHeaderNode node)Return true if node is root.static booleanisTerminal(PivotHeaderNode node)Return true if node is leaf or closed.static voidopenDown(PivotHeaderNode node, boolean open)Recursively set open or close to a node and all its descendants.static voidtraverse(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 voidtraverse(PivotHeaderTree tree, boolean open, Trees.NodeRunner runner)Traverse the tree in a depth first, children first fashion.static voidtraverse(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
-
-