public
class
Modifier
extends Object
java.lang.Object | |
↳ | java.lang.reflect.Modifier |
The Modifier class provides static
methods and
constants to decode class and member access modifiers. The sets of
modifiers are represented as integers with distinct bit positions
representing different modifiers. The values for the constants
representing the modifiers are taken from the tables in sections 4.1, 4.4, 4.5, and 4.7 of
The Java™ Virtual Machine Specification.
See also:
Constants | |
---|---|
int |
ABSTRACT
The |
int |
FINAL
The |
int |
INTERFACE
The |
int |
NATIVE
The |
int |
PRIVATE
The |
int |
PROTECTED
The |
int |
PUBLIC
The |
int |
STATIC
The |
int |
STRICT
The |
int |
SYNCHRONIZED
The |
int |
TRANSIENT
The |
int |
VOLATILE
The |
Public constructors | |
---|---|
Modifier()
|
Public methods | |
---|---|
static
int
|
classModifiers()
Return an |
static
int
|
constructorModifiers()
Return an |
static
int
|
fieldModifiers()
Return an |
static
int
|
interfaceModifiers()
Return an |
static
boolean
|
isAbstract(int mod)
Return |
static
boolean
|
isFinal(int mod)
Return |
static
boolean
|
isInterface(int mod)
Return |
static
boolean
|
isNative(int mod)
Return |
static
boolean
|
isPrivate(int mod)
Return |
static
boolean
|
isProtected(int mod)
Return |
static
boolean
|
isPublic(int mod)
Return |
static
boolean
|
isStatic(int mod)
Return |
static
boolean
|
isStrict(int mod)
Return |
static
boolean
|
isSynchronized(int mod)
Return |
static
boolean
|
isTransient(int mod)
Return |
static
boolean
|
isVolatile(int mod)
Return |
static
int
|
methodModifiers()
Return an |
static
String
|
toString(int mod)
Return a string describing the access modifier flags in the specified modifier. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
int ABSTRACT
The int
value representing the abstract
modifier.
Constant Value: 1024 (0x00000400)
int FINAL
The int
value representing the final
modifier.
Constant Value: 16 (0x00000010)
int INTERFACE
The int
value representing the interface
modifier.
Constant Value: 512 (0x00000200)
int NATIVE
The int
value representing the native
modifier.
Constant Value: 256 (0x00000100)
int PRIVATE
The int
value representing the private
modifier.
Constant Value: 2 (0x00000002)
int PROTECTED
The int
value representing the protected
modifier.
Constant Value: 4 (0x00000004)
int PUBLIC
The int
value representing the public
modifier.
Constant Value: 1 (0x00000001)
int STATIC
The int
value representing the static
modifier.
Constant Value: 8 (0x00000008)
int STRICT
The int
value representing the strictfp
modifier.
Constant Value: 2048 (0x00000800)
int SYNCHRONIZED
The int
value representing the synchronized
modifier.
Constant Value: 32 (0x00000020)
int TRANSIENT
The int
value representing the transient
modifier.
Constant Value: 128 (0x00000080)
int VOLATILE
The int
value representing the volatile
modifier.
Constant Value: 64 (0x00000040)
int classModifiers ()
Return an int
value OR-ing together the source language
modifiers that can be applied to a class.
Returns | |
---|---|
int |
an int value OR-ing together the source language
modifiers that can be applied to a class. |
int constructorModifiers ()
Return an int
value OR-ing together the source language
modifiers that can be applied to a constructor.
Returns | |
---|---|
int |
an int value OR-ing together the source language
modifiers that can be applied to a constructor. |
int fieldModifiers ()
Return an int
value OR-ing together the source language
modifiers that can be applied to a field.
Returns | |
---|---|
int |
an int value OR-ing together the source language
modifiers that can be applied to a field. |
int interfaceModifiers ()
Return an int
value OR-ing together the source language
modifiers that can be applied to an interface.
Returns | |
---|---|
int |
an int value OR-ing together the source language
modifiers that can be applied to an inteface. |
boolean isAbstract (int mod)
Return true
if the integer argument includes the
abstract
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
abstract modifier; false otherwise.
|
boolean isFinal (int mod)
Return true
if the integer argument includes the
final
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
final modifier; false otherwise.
|
boolean isInterface (int mod)
Return true
if the integer argument includes the
interface
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
interface modifier; false otherwise.
|
boolean isNative (int mod)
Return true
if the integer argument includes the
native
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
native modifier; false otherwise.
|
boolean isPrivate (int mod)
Return true
if the integer argument includes the
private
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
private modifier; false otherwise.
|
boolean isProtected (int mod)
Return true
if the integer argument includes the
protected
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
protected modifier; false otherwise.
|
boolean isPublic (int mod)
Return true
if the integer argument includes the
public
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
public modifier; false otherwise.
|
boolean isStatic (int mod)
Return true
if the integer argument includes the
static
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
static modifier; false otherwise.
|
boolean isStrict (int mod)
Return true
if the integer argument includes the
strictfp
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
strictfp modifier; false otherwise.
|
boolean isSynchronized (int mod)
Return true
if the integer argument includes the
synchronized
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
synchronized modifier; false otherwise.
|
boolean isTransient (int mod)
Return true
if the integer argument includes the
transient
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
transient modifier; false otherwise.
|
boolean isVolatile (int mod)
Return true
if the integer argument includes the
volatile
modifier, false
otherwise.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
boolean |
true if mod includes the
volatile modifier; false otherwise.
|
int methodModifiers ()
Return an int
value OR-ing together the source language
modifiers that can be applied to a method.
Returns | |
---|---|
int |
an int value OR-ing together the source language
modifiers that can be applied to a method. |
String toString (int mod)
Return a string describing the access modifier flags in the specified modifier. For example:
The modifier names are returned in an order consistent with the suggested modifier orderings given in sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1 of The Java™ Language Specification. The full modifier ordering used by this method is:public final synchronized strictfp
public protected private abstract static final transient
volatile synchronized native strictfp
interface
The interface
modifier discussed in this class is
not a true modifier in the Java language and it appears after
all other modifiers listed by this method. This method may
return a string of modifiers that are not valid modifiers of a
Java entity; in other words, no checking is done on the
possible validity of the combination of modifiers represented
by the input.
Note that to perform such checking for a known kind of entity,
such as a constructor or method, first AND the argument of
toString
with the appropriate mask from a method like
constructorModifiers()
or methodModifiers()
.
Parameters | |
---|---|
mod |
int :
a set of modifiers |
Returns | |
---|---|
String |
a string representation of the set of modifiers
represented by mod
|