org.cojen.classfile
Class Modifiers

java.lang.Object
  extended by org.cojen.classfile.Modifiers

public class Modifiers
extends Object

The Modifiers class is an immutable wrapper around a modifier bitmask. The methods provided to manipulate the bitmask ensure that it is always legal. i.e. setting it public automatically clears it from being private or protected.

Author:
Brian S O'Neill

Field Summary
static Modifiers NONE
           
static Modifiers PRIVATE
           
static Modifiers PROTECTED
           
static Modifiers PUBLIC
           
static Modifiers PUBLIC_ABSTRACT
           
static Modifiers PUBLIC_STATIC
           
 
Method Summary
 boolean equals(Object obj)
           
 int getBitmask()
          Returns the bitmask.
static Modifiers getInstance(int bitmask)
          Returns a Modifiers object with the given bitmask.
 int hashCode()
           
 boolean isAbstract()
           
 boolean isBridge()
           
 boolean isEnum()
           
 boolean isFinal()
           
 boolean isInterface()
           
 boolean isNative()
           
 boolean isPrivate()
           
 boolean isProtected()
           
 boolean isPublic()
           
 boolean isStatic()
           
 boolean isStrict()
           
 boolean isSynchronized()
           
 boolean isTransient()
           
 boolean isVarArgs()
           
 boolean isVolatile()
           
 Modifiers toAbstract(boolean b)
          When set abstract, the bitmask is cleared from being final, volatile, transient, native, synchronized, and strictfp.
 Modifiers toBridge(boolean b)
          Used to identify if a method is a bridge method.
 Modifiers toEnum(boolean b)
          Used to identify if a field is an enum constant.
 Modifiers toFinal(boolean b)
          When set final, the bitmask is cleared from being an interface or abstract.
 Modifiers toInterface(boolean b)
          When set as an interface, non-interface settings are cleared and the bitmask is set abstract.
 Modifiers toNative(boolean b)
          When set native, non-native-method settings are cleared.
 Modifiers toPrivate(boolean b)
          When set private, the bitmask is cleared from being public or protected.
 Modifiers toProtected(boolean b)
          When set protected, the bitmask is cleared from being public or private.
 Modifiers toPublic(boolean b)
          When set public, the bitmask is cleared from being private or protected.
 Modifiers toStatic(boolean b)
           
 Modifiers toStrict(boolean b)
           
 String toString()
          Returns the string value generated by the Modifier class.
 Modifiers toSynchronized(boolean b)
          When set synchronized, non-method settings are cleared.
 Modifiers toTransient(boolean b)
          When set transient, non-field settings are cleared.
 Modifiers toVarArgs(boolean b)
          Used to identify if a method accepts a variable amount of arguments.
 Modifiers toVolatile(boolean b)
          When set volatile, non-field settings are cleared.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final Modifiers NONE

PUBLIC

public static final Modifiers PUBLIC

PUBLIC_ABSTRACT

public static final Modifiers PUBLIC_ABSTRACT

PUBLIC_STATIC

public static final Modifiers PUBLIC_STATIC

PROTECTED

public static final Modifiers PROTECTED

PRIVATE

public static final Modifiers PRIVATE
Method Detail

getInstance

public static Modifiers getInstance(int bitmask)
Returns a Modifiers object with the given bitmask.


getBitmask

public final int getBitmask()
Returns the bitmask.


isPublic

public boolean isPublic()

isPrivate

public boolean isPrivate()

isProtected

public boolean isProtected()

isStatic

public boolean isStatic()

isFinal

public boolean isFinal()

isSynchronized

public boolean isSynchronized()

isVolatile

public boolean isVolatile()

isTransient

public boolean isTransient()

isNative

public boolean isNative()

isInterface

public boolean isInterface()

isAbstract

public boolean isAbstract()

isStrict

public boolean isStrict()

isBridge

public boolean isBridge()

isEnum

public boolean isEnum()

isVarArgs

public boolean isVarArgs()

toPublic

public Modifiers toPublic(boolean b)
When set public, the bitmask is cleared from being private or protected.

Parameters:
b - true to set public, false otherwise

toPrivate

public Modifiers toPrivate(boolean b)
When set private, the bitmask is cleared from being public or protected.

Parameters:
b - true to set private, false otherwise

toProtected

public Modifiers toProtected(boolean b)
When set protected, the bitmask is cleared from being public or private.

Parameters:
b - true to set protected, false otherwise

toStatic

public Modifiers toStatic(boolean b)
Parameters:
b - true to set static, false otherwise

toFinal

public Modifiers toFinal(boolean b)
When set final, the bitmask is cleared from being an interface or abstract.

Parameters:
b - true to set final, false otherwise

toSynchronized

public Modifiers toSynchronized(boolean b)
When set synchronized, non-method settings are cleared.

Parameters:
b - true to set synchronized, false otherwise

toVolatile

public Modifiers toVolatile(boolean b)
When set volatile, non-field settings are cleared.

Parameters:
b - true to set volatile, false otherwise

toTransient

public Modifiers toTransient(boolean b)
When set transient, non-field settings are cleared.

Parameters:
b - true to set transient, false otherwise

toNative

public Modifiers toNative(boolean b)
When set native, non-native-method settings are cleared.

Parameters:
b - true to set native, false otherwise

toInterface

public Modifiers toInterface(boolean b)
When set as an interface, non-interface settings are cleared and the bitmask is set abstract.

Parameters:
b - true to set interface, false otherwise

toAbstract

public Modifiers toAbstract(boolean b)
When set abstract, the bitmask is cleared from being final, volatile, transient, native, synchronized, and strictfp. When cleared from being abstract, the bitmask is also cleared from being an interface.

Parameters:
b - true to set abstract, false otherwise

toStrict

public Modifiers toStrict(boolean b)
Parameters:
b - true to set strictfp, false otherwise

toBridge

public Modifiers toBridge(boolean b)
Used to identify if a method is a bridge method.

Parameters:
b - true to set bridge, false otherwise

toEnum

public Modifiers toEnum(boolean b)
Used to identify if a field is an enum constant.

Parameters:
b - true to set enum, false otherwise

toVarArgs

public Modifiers toVarArgs(boolean b)
Used to identify if a method accepts a variable amount of arguments.

Parameters:
b - true to set varargs, false otherwise

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Returns the string value generated by the Modifier class.

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2004-2011 Brian S O'Neill. All Rights Reserved.