Method Summary |
|
public static List | childrenAsList(Fold fold) Return children of the given fold as modifiable list.
FoldUtilities.findRecursive(Fold) can be used
to collect children recursively.
Parameters: fold - fold which children will be returned. |
public static List | childrenAsList(Fold fold, int index, int count) Return children of the given fold as list.
Parameters: fold - fold which children will be returned. Parameters: index - >=0 index of the first child to be returned. Parameters: count - >=0 number of children to be returned.index + count <= Fold.getFoldCount . |
public static Fold[] | childrenToArray(Fold fold) Return children of the given fold as array.
Parameters: fold - fold which children will be returned. |
public static Fold[] | childrenToArray(Fold fold, int index, int count) Return children of the given fold as array.
Parameters: fold - fold which children will be returned. Parameters: index - >=0 index of the first child to be returned. Parameters: count - >=0 number of children to be returned.index + count <= Fold.getFoldCount . |
public static void | collapse(FoldHierarchy hierarchy, FoldType type) Collapse all folds of the given type. |
public static void | collapse(FoldHierarchy hierarchy, Collection foldTypes) Collapse all folds that having any
of the fold types in the given collection. |
public static void | collapseAll(FoldHierarchy hierarchy) Collapse all folds in the hierarchy. |
public static Iterator | collapsedFoldIterator(FoldHierarchy hierarchy, int startOffset, int endOffset) Get iterator over the collapsed folds.
Parameters: hierarchy - hierarchy in which to search. Parameters: startOffset - >=0 only folds ending above it will be returned. Parameters: endOffset - >=0 only folds starting before it will be returned. |
public static boolean | containsOffset(Fold fold, int offset) Check whether fold contains the given offset.
Parameters: fold - fold to be tested for containing the given offset Parameters: offset - that will be tested for being contained in the given fold. |
public static void | expand(FoldHierarchy hierarchy, FoldType type) Expand all folds of the given type. |
public static void | expand(FoldHierarchy hierarchy, Collection foldTypes) Expand all folds of the given type (or all folds if the type is null)
found in the whole fold hierarchy. |
public static void | expandAll(FoldHierarchy hierarchy) Expand all folds in the hierarchy. |
public static List | find(Fold fold, FoldType foldType) Find direct subfolds of the given fold having certain type.
Complexity corresponds to number of direct child folds under the given fold.
Parameters: fold - direct children of this fold will be searched.The search is *not* recursive in grandchildren etc. Parameters: foldType - non-null fold type to search for. |
public static List | find(Fold fold, Collection foldTypes) Find direct subfolds of the given fold having any
of the fold types in the given collection.
Complexity corresponds to number of direct child folds under the given fold.
Parameters: fold - direct children of this fold will be searched.The search is *not* recursive in grandchildren etc. Parameters: foldTypes - collection of fold types to search for. |
public static Fold | findCollapsedFold(FoldHierarchy hierarchy, int startOffset, int endOffset) Find a first collapsed fold by going from top-level folds to more nested ones
within the requested bounds. |
public static int | findFoldEndIndex(Fold fold, int offset) Find index of the first child of the given fold that ends
above the given offset ("contains" the offset).
This method uses binary search and has log2(n) performance
where n is number of children of the given fold.
The efficiency may drop to linear if there would be many empty folds
at the given offset.
Parameters: fold - fold which children will be inspected. Parameters: offset - >=0 offset in the document for which the representingchild will be searched. |
public static int | findFoldStartIndex(Fold fold, int offset) Find index of the child of the given fold that
starts right at or below the given offset.
This method uses binary search and has log2(n) performance
where n is number of children of the given fold.
The efficiency may drop to linear if there would be many empty folds
at the given offset.
Parameters: fold - fold which children will be inspected. Parameters: offset - >=0 offset in the document for which the representingchild will be searched. |
public static Fold | findNearestFold(FoldHierarchy hierarchy, int offset) Find nearest fold that either starts right at or follows
the given offset.
The search deep-dives into hierarchy.
Parameters: offset - >=0 offset in a document. |
public static Fold | findOffsetFold(FoldHierarchy hierarchy, int offset) Find a deepest fold in the hierarchy which contains the offset
or has it as one of its boundaries.
The search deep-dives into hierarchy.
Parameters: offset - >=0 offset in a document. |
public static List | findRecursive(Fold fold) Collect all children of the given fold recursively.
Complexity corresponds to number of all child folds
(including grandchildren etc.) under the given fold.
Parameters: fold - all children of this fold will be collected. |
public static List | findRecursive(Fold fold, FoldType foldType) Recursively find any subfolds of the given fold having certain type.
Complexity corresponds to number of all child folds
(including grandchildren etc.) under the given fold.
Parameters: fold - all children of this fold will be searched.The search is recursive into grandchildren etc. Parameters: foldType - non-null fold type to search for. |
public static List | findRecursive(Fold fold, Collection foldTypes) Recursively find any subfolds of the given fold having any
of the fold types in the given collection.
Complexity corresponds to number of all child folds
(including grandchildren etc.) under the given fold.
Parameters: fold - all children of this fold will be searched.The search is recursive into grandchildren etc. Parameters: foldTypes - collection of fold types to search for. |
public static boolean | isEmpty(Fold fold) Check whether the starting offset of the fold is the same like
its ending offset.
Parameters: fold - fold that should be checked whether it's empty. |
public static boolean | isRootFold(Fold fold) Is the given fold a root fold?
Parameters: fold - non-null fold which is either root fold or a regular fold. |