public final class FoldType extends Object
Fold
is identified by its fold type.
equals()
method is declared final
(delegating to super
) the fold types
can directly be compared by using ==
operator.
FoldType.Domain
,
which can be obtained by FoldUtilities.getFoldTypes(java.lang.String)
. FoldTypes for a MIME type are
collected with the help of FoldTypeProvider
.
Several generalized types of folds are defined in this class as constants.
When creating custom FoldTypes, please check carefully whether the new FoldType is not,
in fact, one of these general ones,
or is not a specialization of it. If a general action (e.g. auto-collapse all folds XXX) would
make sense for the new fold, consider to FoldType.derive(java.lang.String, java.lang.String, org.netbeans.api.editor.fold.FoldTemplate)
it from an existing one.
Each FoldType has a specific FoldTemplate instance that controls how it is presented. If a
new Fold has same semantics as an existing one, but a different FoldTemplate
is needed,
use FoldType.override(java.lang.String, org.netbeans.api.editor.fold.FoldTemplate)
to create a new FoldType with appropriate properties. FoldTypes
defined here can be reused in individual MIME types, if their configuration is appropriate.
In general, FoldTypes from more general MIME types (e.g. text/xml) can be reused in specialized ones
(e.g. text/x-ant+xml).
FoldTypes can form a hierarchy of generalization. For example java Method fold can have a more general
'parent', FoldType.MEMBER
.
The generalization is designed to allow several kinds of the same concept operated separately at the
level of the language, but managed at once using general options or operations.
If no settings are specified for Method folding, FoldType.MEMBER
settings are
applied. Likewise, a general-purpose folding operation can work on FoldType.MEMBER
fold type,
which will affect both FUNCTION in PHP or METHOD in java (and other fold types in other languages).
Because of this, please be careful
to use FoldType.isKindOf(org.netbeans.api.editor.fold.FoldType)
to check whether a FoldType is of a specific type. This method respects the
generalization. == can be still used to check for exact type match. When using ==, javadoc comments
may be evaluated as different from general 'documentation' and yet different from PHP docs. Comparison using
== are safe only when applied on FoldType instances defined for the same MIME type
Modifier and Type | Class and Description |
---|---|
static interface |
FoldType.Domain
Represents a value set of
FoldType s for one MIME type. |
Modifier and Type | Field and Description |
---|---|
static FoldType |
CODE_BLOCK
A generic code block.
|
static FoldType |
COMMENT
Unspecified type of comment
|
static FoldType |
DOCUMENTATION
Documentation comment, as defined by the language
|
static FoldType |
IMPORT
Various import, includes and references to sibling files.
|
static FoldType |
INITIAL_COMMENT
Initial file-level comment.
|
static FoldType |
MEMBER
Member of a symbol (type, class, object)
|
static FoldType |
NESTED
Nested part; for example an embedded type, or nested namespace.
|
static FoldType |
TAG
Tag in markup languages
|
static FoldType |
USER
User-defined fold, recoded using a special comment
|
Constructor and Description |
---|
FoldType(String description)
Deprecated.
Use the {link create} static method.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accepts(FoldType type)
Deprecated.
|
String |
code()
Persistable value of FoldType.
|
static FoldType |
create(String code,
String label,
FoldTemplate template)
Creates an instance of FoldType.
|
FoldType |
derive(String code,
String label,
FoldTemplate template)
Derives a FoldType which acts as a child of this instance.
|
String |
getLabel()
Provides human-readable label for the type
|
FoldTemplate |
getTemplate()
Provides FoldTemplate instance for this type.
|
boolean |
isKindOf(FoldType other)
Checks whether the fold can act as the 'other' type.
|
FoldType |
override(String label,
FoldTemplate template)
Creates a FoldType, overriding its appearance.
|
FoldType |
parent()
Provides parent of this FoldType.
|
String |
toString() |
public static final FoldType CODE_BLOCK
public static final FoldType DOCUMENTATION
public static final FoldType COMMENT
public static final FoldType INITIAL_COMMENT
public static final FoldType TAG
public static final FoldType NESTED
public static final FoldType MEMBER
public static final FoldType IMPORT
public static final FoldType USER
@Deprecated public FoldType(String description)
description
- textual description of the fold type.
Two fold types with the same description are not equal.public static FoldType create(String code, String label, FoldTemplate template)
code
- code used to form, e.g. persistent keys for info related to the FoldType. Cannot be null
.label
- human-readable label that identifies the FoldType. Must not be null
.template
- describes how the fold is presented. If null
, FoldTemplate.DEFAULT
will be used.public FoldType override(String label, FoldTemplate template)
label
- human-readable label that describes the FoldType. If null
, the original label will be used.template
- human-readable label that describes the FoldType. If null
, the original template will be used.public FoldType derive(String code, String label, FoldTemplate template)
code
- new code for the FoldTypelabel
- human-readable label that describes the FoldType. If null
, the original label will be used.template
- human-readable label that describes the FoldType. If null
, the original template will be used.@Deprecated public boolean accepts(FoldType type)
FoldType.isKindOf(org.netbeans.api.editor.fold.FoldType)
type
- public String getLabel()
public FoldTemplate getTemplate()
public boolean isKindOf(FoldType other)
FoldType.parent
). The method returns true,
if semantics, operations, settings,... applicable to 'other' could be also applied on
this FoldType.other
- the type to checkpublic FoldType parent()
null
, if no parent is defined.
The parent is a FoldType, which is more general and could be used as a fallback when no information
is provided/available on this FoldType instance.null
public String code()
FoldType.Domain.valueOf(java.lang.String)
to convert the value back to FoldType instance. The value
can (and is) used to compose preference setting keys.