Class Flags
This class provides static methods only.
Note that the numeric values of these flags match the ones for class files
as described in the Java Virtual Machine Specification (except for
AccDeprecated
, AccAnnotationDefault
, and AccDefaultMethod
).
The AST class Modifier
provides
similar functionality as this class, only in the
org.eclipse.jdt.core.dom
package.
- See Also:
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Abstract property flag.static final int
Annotation property flag (added in J2SE 1.5).static final int
Annotation method default property flag.static final int
Bridge method property flag (added in J2SE 1.5).static final int
Constant representing the absence of any flag.static final int
Default method property flag.static final int
Deprecated property flag.static final int
Enum property flag (added in J2SE 1.5).static final int
Final access flag.static final int
Interface property flag.static final int
Module declaration property flag.static final int
Native property flag.static final int
Non-sealed property flag.static final int
Private access flag.static final int
Protected access flag.static final int
Public access flag.static final int
Record property flag.static final int
Sealed property flag.static final int
Static access flag.static final int
Strictfp property flag.static final int
Super property flag.static final int
Synchronized access flag.static final int
Synthetic property flag.static final int
Transient property flag.static final int
Varargs method property flag (added in J2SE 1.5).static final int
Volatile property flag. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isAbstract
(int flags) Returns whether the given integer includes theabstract
modifier.static boolean
isAnnnotationDefault
(int flags) Returns whether the given integer has theAccAnnnotationDefault
bit set.static boolean
isAnnotation
(int flags) Returns whether the given integer has theAccAnnotation
bit set.static boolean
isBridge
(int flags) Returns whether the given integer has theAccBridge
bit set.static boolean
isDefaultMethod
(int flags) Returns whether the given integer has theAccDefaultMethod
bit set.static boolean
isDeprecated
(int flags) Returns whether the given integer includes the indication that the element is deprecated (@deprecated
tag in Javadoc comment).static boolean
isEnum
(int flags) Returns whether the given integer has theAccEnum
bit set.static boolean
isFinal
(int flags) Returns whether the given integer includes thefinal
modifier.static boolean
isInterface
(int flags) Returns whether the given integer includes theinterface
modifier.static boolean
isModule
(int flags) Returns whether the given integer has theAccModule
bit set.static boolean
isNative
(int flags) Returns whether the given integer includes thenative
modifier.static boolean
isNonSealed
(int flags) Returns whether the given integer has theAccNonSealed
bit set.static boolean
isPackageDefault
(int flags) Returns whether the given integer does not include one of thepublic
,private
, orprotected
flags.static boolean
isPrivate
(int flags) Returns whether the given integer includes theprivate
modifier.static boolean
isProtected
(int flags) Returns whether the given integer includes theprotected
modifier.static boolean
isPublic
(int flags) Returns whether the given integer includes thepublic
modifier.static boolean
isRecord
(int flags) Returns whether the given integer has theAccRecord
bit set.static boolean
isSealed
(int flags) Returns whether the given integer has theAccSealed
bit set.static boolean
isStatic
(int flags) Returns whether the given integer includes thestatic
modifier.static boolean
isStrictfp
(int flags) Returns whether the given integer includes thestrictfp
modifier.static boolean
isSuper
(int flags) Returns whether the given integer includes thesuper
modifier.static boolean
isSynchronized
(int flags) Returns whether the given integer includes thesynchronized
modifier.static boolean
isSynthetic
(int flags) Returns whether the given integer includes the indication that the element is synthetic.static boolean
isTransient
(int flags) Returns whether the given integer includes thetransient
modifier.static boolean
isVarargs
(int flags) Returns whether the given integer has theAccVarargs
bit set.static boolean
isVolatile
(int flags) Returns whether the given integer includes thevolatile
modifier.static String
toString
(int flags) Returns a standard string describing the given modifier flags.
-
Field Details
-
AccDefault
public static final int AccDefaultConstant representing the absence of any flag.- Since:
- 3.0
- See Also:
-
AccPublic
public static final int AccPublicPublic access flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccPrivate
public static final int AccPrivatePrivate access flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccProtected
public static final int AccProtectedProtected access flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccStatic
public static final int AccStaticStatic access flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccFinal
public static final int AccFinalFinal access flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccSynchronized
public static final int AccSynchronizedSynchronized access flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccVolatile
public static final int AccVolatileVolatile property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccTransient
public static final int AccTransientTransient property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccNative
public static final int AccNativeNative property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccInterface
public static final int AccInterfaceInterface property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccAbstract
public static final int AccAbstractAbstract property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccStrictfp
public static final int AccStrictfpStrictfp property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccSuper
public static final int AccSuperSuper property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccSynthetic
public static final int AccSyntheticSynthetic property flag. See The Java Virtual Machine Specification for more details.- Since:
- 2.0
- See Also:
-
AccDeprecated
public static final int AccDeprecatedDeprecated property flag.Note that this flag's value is internal and is not defined in the Virtual Machine specification.
- Since:
- 2.0
- See Also:
-
AccBridge
public static final int AccBridgeBridge method property flag (added in J2SE 1.5). Used to flag a compiler-generated bridge methods. See The Java Virtual Machine Specification for more details.- Since:
- 3.0
- See Also:
-
AccVarargs
public static final int AccVarargsVarargs method property flag (added in J2SE 1.5). Used to flag variable arity method declarations. See The Java Virtual Machine Specification for more details.- Since:
- 3.0
- See Also:
-
AccEnum
public static final int AccEnumEnum property flag (added in J2SE 1.5). See The Java Virtual Machine Specification for more details.- Since:
- 3.0
- See Also:
-
AccAnnotation
public static final int AccAnnotationAnnotation property flag (added in J2SE 1.5). See The Java Virtual Machine Specification for more details.- Since:
- 3.0
- See Also:
-
AccDefaultMethod
public static final int AccDefaultMethodDefault method property flag.Note that this flag's value is internal and is not defined in the Virtual Machine specification.
- Since:
- 3.10
- See Also:
-
AccAnnotationDefault
public static final int AccAnnotationDefaultAnnotation method default property flag. Used to flag annotation type methods that declare a default value.Note that this flag's value is internal and is not defined in the Virtual Machine specification.
- Since:
- 3.10
- See Also:
-
AccModule
public static final int AccModuleModule declaration property flag. Used to flag a compilation unit or a class file that contains a module declaration.- Since:
- 3.14
- See Also:
-
AccRecord
public static final int AccRecordRecord property flag.Note that this flag's value is internal and is not defined in the Virtual Machine specification.
- Since:
- 3.26
- See Also:
-
AccSealed
public static final int AccSealedSealed property flag.Note that this flag's value is internal and is not defined in the Virtual Machine specification.
- Since:
- 3.24
- See Also:
-
AccNonSealed
public static final int AccNonSealedNon-sealed property flag.Note that this flag's value is internal and is not defined in the Virtual Machine specification.
- Since:
- 3.24
- See Also:
-
-
Method Details
-
isAbstract
public static boolean isAbstract(int flags) Returns whether the given integer includes theabstract
modifier.- Parameters:
flags
- the flags- Returns:
true
if theabstract
modifier is included
-
isDeprecated
public static boolean isDeprecated(int flags) Returns whether the given integer includes the indication that the element is deprecated (@deprecated
tag in Javadoc comment).- Parameters:
flags
- the flags- Returns:
true
if the element is marked as deprecated
-
isFinal
public static boolean isFinal(int flags) Returns whether the given integer includes thefinal
modifier.- Parameters:
flags
- the flags- Returns:
true
if thefinal
modifier is included
-
isInterface
public static boolean isInterface(int flags) Returns whether the given integer includes theinterface
modifier.- Parameters:
flags
- the flags- Returns:
true
if theinterface
modifier is included- Since:
- 2.0
-
isNative
public static boolean isNative(int flags) Returns whether the given integer includes thenative
modifier.- Parameters:
flags
- the flags- Returns:
true
if thenative
modifier is included
-
isPackageDefault
public static boolean isPackageDefault(int flags) Returns whether the given integer does not include one of thepublic
,private
, orprotected
flags.- Parameters:
flags
- the flags- Returns:
true
if no visibility flag is set- Since:
- 3.2
-
isPrivate
public static boolean isPrivate(int flags) Returns whether the given integer includes theprivate
modifier.- Parameters:
flags
- the flags- Returns:
true
if theprivate
modifier is included
-
isProtected
public static boolean isProtected(int flags) Returns whether the given integer includes theprotected
modifier.- Parameters:
flags
- the flags- Returns:
true
if theprotected
modifier is included
-
isPublic
public static boolean isPublic(int flags) Returns whether the given integer includes thepublic
modifier.- Parameters:
flags
- the flags- Returns:
true
if thepublic
modifier is included
-
isStatic
public static boolean isStatic(int flags) Returns whether the given integer includes thestatic
modifier.- Parameters:
flags
- the flags- Returns:
true
if thestatic
modifier is included
-
isSuper
public static boolean isSuper(int flags) Returns whether the given integer includes thesuper
modifier.- Parameters:
flags
- the flags- Returns:
true
if thesuper
modifier is included- Since:
- 3.2
-
isStrictfp
public static boolean isStrictfp(int flags) Returns whether the given integer includes thestrictfp
modifier.- Parameters:
flags
- the flags- Returns:
true
if thestrictfp
modifier is included
-
isSynchronized
public static boolean isSynchronized(int flags) Returns whether the given integer includes thesynchronized
modifier.- Parameters:
flags
- the flags- Returns:
true
if thesynchronized
modifier is included
-
isSynthetic
public static boolean isSynthetic(int flags) Returns whether the given integer includes the indication that the element is synthetic.- Parameters:
flags
- the flags- Returns:
true
if the element is marked synthetic
-
isTransient
public static boolean isTransient(int flags) Returns whether the given integer includes thetransient
modifier.- Parameters:
flags
- the flags- Returns:
true
if thetransient
modifier is included
-
isVolatile
public static boolean isVolatile(int flags) Returns whether the given integer includes thevolatile
modifier.- Parameters:
flags
- the flags- Returns:
true
if thevolatile
modifier is included
-
isBridge
public static boolean isBridge(int flags) Returns whether the given integer has theAccBridge
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccBridge
flag is included- Since:
- 3.0
- See Also:
-
isVarargs
public static boolean isVarargs(int flags) Returns whether the given integer has theAccVarargs
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccVarargs
flag is included- Since:
- 3.0
- See Also:
-
isEnum
public static boolean isEnum(int flags) Returns whether the given integer has theAccEnum
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccEnum
flag is included- Since:
- 3.0
- See Also:
-
isRecord
public static boolean isRecord(int flags) Returns whether the given integer has theAccRecord
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccRecord
flag is included- Since:
- 3.26
- See Also:
-
isSealed
public static boolean isSealed(int flags) Returns whether the given integer has theAccSealed
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccSealed
flag is included- Since:
- 3.28
- See Also:
-
isNonSealed
public static boolean isNonSealed(int flags) Returns whether the given integer has theAccNonSealed
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccNonSealed
flag is included- Since:
- 3.28
- See Also:
-
isAnnotation
public static boolean isAnnotation(int flags) Returns whether the given integer has theAccAnnotation
bit set.- Parameters:
flags
- the flags- Returns:
true
if theAccAnnotation
flag is included- Since:
- 3.0
- See Also:
-
isDefaultMethod
public static boolean isDefaultMethod(int flags) Returns whether the given integer has theAccDefaultMethod
bit set. Note that this flag represents the usage of the 'default' keyword on a method and should not be confused with the 'package' access visibility (which used to be called 'default access').- Returns:
true
if theAccDefaultMethod
flag is included- Since:
- 3.10
- See Also:
-
isAnnnotationDefault
public static boolean isAnnnotationDefault(int flags) Returns whether the given integer has theAccAnnnotationDefault
bit set.- Returns:
true
if theAccAnnotationDefault
flag is included- Since:
- 3.10
- See Also:
-
isModule
public static boolean isModule(int flags) Returns whether the given integer has theAccModule
bit set.- Returns:
true
if theAccModule
flag is included- Since:
- 3.14
- See Also:
-
toString
Returns a standard string describing the given modifier flags. Only modifier flags are included in the output; deprecated, synthetic, bridge, etc. flags are ignored.The flags are output in the following order:
public protected private abstract default static final synchronized native strictfp transient volatile
This order is consistent with the recommendations in JLS8 ("*Modifier:" rules in chapters 8 and 9).
Note that the flags of a method can include the AccVarargs flag that has no standard description. Since the AccVarargs flag has the same value as the AccTransient flag (valid for fields only), attempting to get the description of method modifiers with the AccVarargs flag set would result in an unexpected description. Clients should ensure that the AccVarargs is not included in the flags of a method as follows:
IMethod method = ... int flags = method.getFlags() & ~Flags.AccVarargs; return Flags.toString(flags);
Examples results:
"public static final"
"private native"
- Parameters:
flags
- the flags- Returns:
- the standard string representation of the given flags
-