org.pfsw.reflect
Class Modifiers

java.lang.Object
  extended by org.pfsw.reflect.Modifiers

public class Modifiers
extends java.lang.Object

This class provides methods to conveniently set/unset modifier bits without having to fiddle around with bit logic.


Field Summary
static java.lang.String VIS_DEFAULT
          String constant for "".
static java.lang.String VIS_PRIVATE
          String constant for "private".
static java.lang.String VIS_PROTECTED
          String constant for "protected".
static java.lang.String VIS_PUBLIC
          String constant for "public".
 
Constructor Summary
Modifiers()
          Initialize the new instance with default value 0.
Modifiers(int initialValue)
          Initialize the new instance with given value.
 
Method Summary
 boolean equals(java.lang.Object object)
          Indicates whether some other object is "equal to" this one.
 int getBits()
          Return the bits as they are currently set.
 int hashCode()
          Returns a hash code value for the object.
 boolean isAbstract()
          Return true if the modifiers includes the abstract modifier, false otherwise.
 boolean isDefaultVisibility()
          Return true if the modifier bits does not include any of the visibility modifiers public, protected private, false otherwise.
 boolean isFinal()
          Return true if the modifiers includes the final modifier, false otherwise.
 boolean isInterface()
          Return true if the modifiers includes the interface modifier, false otherwise.
 boolean isNative()
          Return true if the modifiers includes the native modifier, false otherwise.
 boolean isPrivate()
          Return true if the modifiers includes the private modifier, false otherwise.
 boolean isProtected()
          Return true if the modifiers includes the protected modifier, false otherwise.
 boolean isPublic()
          Return true if the modifiers includes the public modifier, false otherwise.
 boolean isStatic()
          Return true if the modifiers includes the static modifier, false otherwise.
 boolean isStrict()
          Return true if the modifiers includes the strict modifier, false otherwise.
 boolean isSynchronized()
          Return true if the modifiers includes the synchronized modifier, false otherwise.
 boolean isTransient()
          Return true if the modifiers includes the transient modifier, false otherwise.
 boolean isVolatile()
          Return true if the modifiers includes the volatile modifier, false otherwise.
 void reset()
          Resets the modifier to 0.
 void setAbstract()
          Sets the ABSTRACT bit.
protected  void setBits(int newValue)
           
 void setDefaultVisibility()
          Sets the visibility to default that means unset PUBLIC, PROTECTED, PRIVATE bits.
 void setFinal()
          Sets the FINAL bit.
 void setInterface()
          Sets the INTERFACE bit.
protected  void setModifier(int mod)
          Sets the bits in the underlying int that are specified by mod.
 void setNative()
          Sets the NATIVE bit.
 void setPrivate()
          Sets the PRIVATE bit.
 void setProtected()
          Sets the PROTECTED bit.
 void setPublic()
          Sets the PUBLIC bit.
 void setStatic()
          Sets the STATIC bit.
 void setStrict()
          Sets the STRICT bit.
 void setSynchronized()
          Sets the SYNCHRONIZED bit.
 void setTransient()
          Sets the TRANSIENT bit.
 void setVisibility(java.lang.String visibility)
          Sets the visibility from the given string.
 void setVolatile()
          Sets the VOLATILE bit.
 java.lang.String toString()
          Return a string describing the access modifier flags in the specified modifier.
 void unsetAbstract()
          Unsets the ABSTRACT bit.
 void unsetFinal()
          Unsets the FINAL bit.
 void unsetInterface()
          Unsets the INTERFACE bit.
protected  void unsetModifier(int mod)
          Unsets the bits in the underlying int that are specified by mod.
 void unsetNative()
          Unsets the NATIVE bit.
 void unsetPrivate()
          Unsets the PRIVATE bit.
 void unsetProtected()
          Unsets the PROTECTED bit.
 void unsetPublic()
          Unsets the PUBLIC bit.
 void unsetStatic()
          Unsets the STATIC bit.
 void unsetStrict()
          Unsets the STRICT bit.
 void unsetSynchronized()
          Unsets the SYNCHRONIZED bit.
 void unsetTransient()
          Unsets the TRANSIENT bit.
 void unsetVolatile()
          Unsets the VOLATILE bit.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VIS_PUBLIC

public static final java.lang.String VIS_PUBLIC
String constant for "public".

See Also:
Constant Field Values

VIS_PROTECTED

public static final java.lang.String VIS_PROTECTED
String constant for "protected".

See Also:
Constant Field Values

VIS_PRIVATE

public static final java.lang.String VIS_PRIVATE
String constant for "private".

See Also:
Constant Field Values

VIS_DEFAULT

public static final java.lang.String VIS_DEFAULT
String constant for "".

See Also:
Constant Field Values
Constructor Detail

Modifiers

public Modifiers()
Initialize the new instance with default value 0.


Modifiers

public Modifiers(int initialValue)
Initialize the new instance with given value.

Method Detail

getBits

public int getBits()
Return the bits as they are currently set.


setBits

protected void setBits(int newValue)

reset

public void reset()
Resets the modifier to 0.


isAbstract

public boolean isAbstract()
Return true if the modifiers includes the abstract modifier, false otherwise.


isFinal

public boolean isFinal()
Return true if the modifiers includes the final modifier, false otherwise.


isInterface

public boolean isInterface()
Return true if the modifiers includes the interface modifier, false otherwise.


isNative

public boolean isNative()
Return true if the modifiers includes the native modifier, false otherwise.


isPrivate

public boolean isPrivate()
Return true if the modifiers includes the private modifier, false otherwise.


isProtected

public boolean isProtected()
Return true if the modifiers includes the protected modifier, false otherwise.


isPublic

public boolean isPublic()
Return true if the modifiers includes the public modifier, false otherwise.


isStatic

public boolean isStatic()
Return true if the modifiers includes the static modifier, false otherwise.


isStrict

public boolean isStrict()
Return true if the modifiers includes the strict modifier, false otherwise.


isSynchronized

public boolean isSynchronized()
Return true if the modifiers includes the synchronized modifier, false otherwise.


isTransient

public boolean isTransient()
Return true if the modifiers includes the transient modifier, false otherwise.


isVolatile

public boolean isVolatile()
Return true if the modifiers includes the volatile modifier, false otherwise.


isDefaultVisibility

public boolean isDefaultVisibility()
Return true if the modifier bits does not include any of the visibility modifiers public, protected private, false otherwise.


toString

public java.lang.String toString()
Return a string describing the access modifier flags in the specified modifier.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object

setAbstract

public void setAbstract()
Sets the ABSTRACT bit.


setFinal

public void setFinal()
Sets the FINAL bit.


setInterface

public void setInterface()
Sets the INTERFACE bit.


setNative

public void setNative()
Sets the NATIVE bit.


setPrivate

public void setPrivate()
Sets the PRIVATE bit. This automatically unsets the PUBLIC and PROTECTED bits.


setProtected

public void setProtected()
Sets the PROTECTED bit. This automatically unsets the PUBLIC and PRIVATE bits.


setPublic

public void setPublic()
Sets the PUBLIC bit. This automatically unsets the PROTECTED and PRIVATE bits.


setStatic

public void setStatic()
Sets the STATIC bit.


setStrict

public void setStrict()
Sets the STRICT bit.


setSynchronized

public void setSynchronized()
Sets the SYNCHRONIZED bit.


setTransient

public void setTransient()
Sets the TRANSIENT bit.


setVolatile

public void setVolatile()
Sets the VOLATILE bit.


setDefaultVisibility

public void setDefaultVisibility()
Sets the visibility to default that means unset PUBLIC, PROTECTED, PRIVATE bits.


setVisibility

public void setVisibility(java.lang.String visibility)
Sets the visibility from the given string. If the given string is not one of "public", "protected", "private" the the default visibility is set.

Parameters:
visibility - One of the visibility strings

unsetAbstract

public void unsetAbstract()
Unsets the ABSTRACT bit.


unsetFinal

public void unsetFinal()
Unsets the FINAL bit.


unsetInterface

public void unsetInterface()
Unsets the INTERFACE bit.


unsetNative

public void unsetNative()
Unsets the NATIVE bit.


unsetPrivate

public void unsetPrivate()
Unsets the PRIVATE bit.


unsetProtected

public void unsetProtected()
Unsets the PROTECTED bit.


unsetPublic

public void unsetPublic()
Unsets the PUBLIC bit.


unsetStatic

public void unsetStatic()
Unsets the STATIC bit.


unsetStrict

public void unsetStrict()
Unsets the STRICT bit.


unsetSynchronized

public void unsetSynchronized()
Unsets the SYNCHRONIZED bit.


unsetTransient

public void unsetTransient()
Unsets the TRANSIENT bit.


unsetVolatile

public void unsetVolatile()
Unsets the VOLATILE bit.


setModifier

protected void setModifier(int mod)
Sets the bits in the underlying int that are specified by mod.


unsetModifier

protected void unsetModifier(int mod)
Unsets the bits in the underlying int that are specified by mod.