站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

Fold (NetBeans Code Folding API) - NetBeans API Javadoc 5.0.0

 

org.netbeans.api.editor.fold
Class Fold

java.lang.Object
  extended byorg.netbeans.api.editor.fold.Fold

public final class Fold
extends Object

Fold is a building block of the code folding tree-based hierarchy.
Folds cannot overlap but they can be nested arbitrarily.
It's possible to determine the fold's type, description and whether it is collapsed or expanded and explore the nested (children) folds.
There are various useful utility methods for folds in the FoldUtilities.

There is one root fold at the top of the code folding hierarchy.
The root fold is special uncollapsable fold covering the whole document.
It can be obtained by using FoldHierarchy.getRootFold().
The regular top-level folds are children of the root fold.


Method Summary
 String getDescription()
          Get text description that should be displayed when the fold is collapsed instead of the text contained in the fold.
 int getEndOffset()
          Get an absolute ending offset of this fold in the associated document.
 Fold getFold(int index)
          Get child fold of this fold at the given index.
 int getFoldCount()
          Get total count of child folds contained in this fold.
 int getFoldIndex(Fold child)
          Get index of the given child fold in this fold.
 FoldHierarchy getHierarchy()
          Get the code folding hierarchy for which this fold was created.
 Fold getParent()
          Get parent fold of this fold.
 int getStartOffset()
          Get an absolute starting offset of this fold in the associated document.
 FoldType getType()
          Get type of this fold.
 boolean isCollapsed()
          Return whether this fold is collapsed or expanded.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getType

public FoldType getType()
Get type of this fold.

Returns:
non-null type identification of this fold.

getParent

public Fold getParent()
Get parent fold of this fold.

Returns:
parent fold of this fold or null if this is root fold or if this fold was removed from the code folding hierarchy.
FoldUtilities.isRootFold(Fold) can be used to check whether this is root fold.

getHierarchy

public FoldHierarchy getHierarchy()
Get the code folding hierarchy for which this fold was created.

Returns:
non-null code folding hierarchy for which this fold was constructed.

getStartOffset

public int getStartOffset()
Get an absolute starting offset of this fold in the associated document.
The starting offset is expected to track possible changes in the underlying document (i.e. it's maintained in Position-like form).

Returns:
>=0 absolute starting offset of this fold in the document.

getEndOffset

public int getEndOffset()
Get an absolute ending offset of this fold in the associated document.
The ending offset is expected to track possible changes in the underlying document (i.e. it's maintained in Position-like form).

Returns:
>=getStartOffset() offset of the first character in the document that is not part of this fold.

isCollapsed

public boolean isCollapsed()
Return whether this fold is collapsed or expanded.
To collapse fold FoldHierarchy.collapse(Fold) can be used.

Returns:
true if this fold is collapsed or false if it's expanded.

getDescription

public String getDescription()
Get text description that should be displayed when the fold is collapsed instead of the text contained in the fold.
If there is no specific description the "..." is returned.

Returns:
non-null description of the fold.

getFoldCount

public int getFoldCount()
Get total count of child folds contained in this fold.

Returns:
count of child folds contained in this fold. Zero means there are no children folds under this fold.

getFold

public Fold getFold(int index)
Get child fold of this fold at the given index.

Parameters:
index - >=0 && <getFoldCount() index of child of this fold.

getFoldIndex

public int getFoldIndex(Fold child)
Get index of the given child fold in this fold.
The method has constant-time performance.

Parameters:
child - non-null child fold of this fold but in general it can be any non-null fold (see return value).
Returns:
>=0 index of the child fold in this fold or -1 if the given child fold is not a child of this fold.

toString

public String toString()

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.