jml2b.structure.java
Class Modifiers

java.lang.Object
  extended byjml2b.util.Profiler
      extended byjml2b.structure.java.Modifiers
All Implemented Interfaces:
IModifiers, java.io.Serializable

public class Modifiers
extends Profiler
implements IModifiers, java.io.Serializable

Class used to represent Java modifiers .

Author:
A. Requet
See Also:
Serialized Form

Constructor Summary
Modifiers(antlr.collections.AST tree)
          Creates a new instance, initialising the modifiers from the given AST.
Modifiers(int flags)
          Creates a new instance, initialising the modifiers from the given flags.
 
Method Summary
 void clearFlag(int flag)
          Clear the given flag(s).
 java.lang.String emit()
           
 boolean isCompatible(IModifiers modifiers)
          Indicates wether the modifier is compatible with the given modifier.
 boolean isExternalVisible()
          Returns true if the modifier allow external visibility (that is visibility outside of the package).
 boolean isFinal()
           
 boolean isJml()
           
 boolean isPackageVisible()
          Indicates wether the modifier corresponds to the package visibility.
 boolean isPrivate()
          Indicates wether the modifier has the private modifier set.
 boolean isProtected()
          Indicates wether the modifier has the protected modifier set.
 boolean isProtectedNotSpecPublic()
          Return true iff the protected modifier is set, and not the spec_public modifier.
 boolean isSet(int flag)
          Returns true if flag is set, false otherwise.
 boolean isStatic()
          Indicates wether the modifier has the static modifier set.
 void parse(antlr.collections.AST tree)
          Initialise the modifiers from the given AST.
 void setFlag(int flag)
          Sets the given flag(s).
 
Methods inherited from class jml2b.util.Profiler
runGC
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Modifiers

public Modifiers(antlr.collections.AST tree)
Creates a new instance, initialising the modifiers from the given AST.

Parameters:
tree - the AST that should be used for initialising the modifiers.

Modifiers

public Modifiers(int flags)
Creates a new instance, initialising the modifiers from the given flags. flags should contain a bitmask of the values defined in the ModFlags interface.

Parameters:
flags - a bitmask of the modifiers, using the constants defined in the ModFlags interface.
See Also:
ModFlags
Method Detail

parse

public void parse(antlr.collections.AST tree)
Initialise the modifiers from the given AST.

Parameters:
tree - the AST corresponding to the modifiers declaration.

isExternalVisible

public boolean isExternalVisible()
Returns true if the modifier allow external visibility (that is visibility outside of the package).

That is, if the modifier is public, protected or spec_public.

It should be noted that if this method returns true, that does not means that the corresponding declaration is obligatory visible (it can be protected).

Specified by:
isExternalVisible in interface IModifiers
Returns:
boolean true if the modifier allow external visibility, false otherwise.

isStatic

public boolean isStatic()
Indicates wether the modifier has the static modifier set.

Specified by:
isStatic in interface IModifiers
Returns:
boolean true if the static modifier is set, false otherwise.

isFinal

public boolean isFinal()
Specified by:
isFinal in interface IModifiers

isJml

public boolean isJml()

isPrivate

public boolean isPrivate()
Indicates wether the modifier has the private modifier set.

Specified by:
isPrivate in interface IModifiers
Returns:
boolean true if the private modifier is set, false otherwise.

isProtected

public boolean isProtected()
Indicates wether the modifier has the protected modifier set.

Specified by:
isProtected in interface IModifiers
Returns:
boolean true if the protected modifier is set, false otherwise.

isPackageVisible

public boolean isPackageVisible()
Indicates wether the modifier corresponds to the package visibility. That is, if neither the public, private nor protected modifiers are set.

Specified by:
isPackageVisible in interface IModifiers
Returns:
boolean true if the modifiers corresponds to a package visibility, false otherwise.

isProtectedNotSpecPublic

public boolean isProtectedNotSpecPublic()
Return true iff the protected modifier is set, and not the spec_public modifier.

Specified by:
isProtectedNotSpecPublic in interface IModifiers
Returns:
true iff the protected modifier is set, and not the spec_public modifier.

isSet

public boolean isSet(int flag)
Returns true if flag is set, false otherwise.

Returns:
true if flag is set, false otherwise.

setFlag

public void setFlag(int flag)
Sets the given flag(s).

Parameters:
flag - a bitmask of the flags that should be sets. Valid flags are defined in the ModFlags interface.
See Also:
ModFlags

clearFlag

public void clearFlag(int flag)
Clear the given flag(s).

Parameters:
flag - a bitmask of the flags that should be sets. Valid flags are defined in the ModFlags interface.
See Also:
ModFlags

isCompatible

public boolean isCompatible(IModifiers modifiers)
Indicates wether the modifier is compatible with the given modifier. The modifier is compatible with the given modifiers if both modifiers are static or non-static, and that the given modifier is more visible than the current modifier.

Parameters:
modifiers - the modifiers that should be checked for compatibility.

emit

public java.lang.String emit()
Specified by:
emit in interface IModifiers