net.mtu.eggplant.dbc
Class AssertMethod

java.lang.Object
  extended bynet.mtu.eggplant.dbc.AssertMethod
All Implemented Interfaces:
net.mtu.eggplant.util.Named

public class AssertMethod
extends Object
implements net.mtu.eggplant.util.Named

Object that contains the data needed to generate instrumented code for a method.

Version:
$Revision: 1.6 $

Constructor Summary
AssertMethod(AssertClass theClass, String name, List preConditions, List postConditions, List params, String retType, Set mods)
           
 
Method Summary
 void addExit(CodePointPair points)
          Add an exit to this method.
 String getAssertMethodVisibility()
          Look at the mods list and determine what the visibility of the method that checks assertions should be.
 CodePoint getClose()
           
 AssertClass getContainingClass()
           
 CodePoint getEntrance()
           
 Set getExits()
           
 Set getMods()
           
 String getName()
           
 List getParams()
           
 List getPostConditions()
           
 List getPreConditions()
           
 String getReturnType()
           
 Set getThrownExceptions()
           
 List getUniqueParams()
          Get the unique parameters for this method.
 String getVisibility()
          Look at the mods list and determine the visibility of this method.
 boolean isAbstract()
           
 boolean isConstructor()
           
 boolean isPrivate()
           
 boolean isStatic()
           
 boolean isVoid()
           
 void setClose(CodePoint close)
          Set the point at which should be added to be just outside the method, location of '}' + 1
 void setMethodEntrance(CodePoint entrance)
          Set the entrance to this method.
 void setThrownExceptions(Set thrownExceptions)
           
 void setUniqueParams(List uniqueParams)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AssertMethod

public AssertMethod(AssertClass theClass,
                    String name,
                    List preConditions,
                    List postConditions,
                    List params,
                    String retType,
                    Set mods)
Parameters:
theClass - the class that this method is contained in
name - the name of this method, will match the name of the class if a constructor
preConditions - the preconditions for this method
postConditions - the postconditions for this method
params - List of StringPairs (class, parameter name)
retType - the return type of this method, null signals this method is a constructor
mods - a Set of Strings that are the modifiers for this method
PreConditions
(theClass != null), (name != null), (preConditions != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(postConditions, AssertToken.class)), (postConditions != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(preConditions, AssertToken.class)), (params != null && net.mtu.eggplant.util.JPSCollections.elementsInstanceOf(StringPair.class)), (mods != null)
Method Detail

getName

public String getName()
Specified by:
getName in interface net.mtu.eggplant.util.Named

getContainingClass

public final AssertClass getContainingClass()
Returns:
the class that this method belongs to.

getPreConditions

public final List getPreConditions()
Returns:
the preConditions for this method, list of AssertTokens

getPostConditions

public final List getPostConditions()
Returns:
the postConditions for this method, list of AssertTokens

setMethodEntrance

public final void setMethodEntrance(CodePoint entrance)
Set the entrance to this method.


getEntrance

public final CodePoint getEntrance()
Returns:
the entrance to this class, ie. the location of the open brace. Don't modify this Point.

addExit

public final void addExit(CodePointPair points)
Add an exit to this method.

Parameters:
points - The first point is the start of the return token, the second is the location of the semiColon at the end of the return. If the method is void or a constructor, these two locations are equal because the first one will be ignored on instrumentation.
PreConditions
(exit != null)

getExits

public final Set getExits()
Returns:
list of the exits of this class, all return statements and the closing brace if this is a void method. Don't modify this Set. Set of CodePointPairs(start of return, semicolon)

getParams

public final List getParams()
Returns:
List of StringPairs (class, parameter name), don't modify this List

getUniqueParams

public List getUniqueParams()
Get the unique parameters for this method. This is initialized to the parameter list passed into the constructor. If this object represents a constructor then this list may be changed in a post processing phase before code generation.


setUniqueParams

public void setUniqueParams(List uniqueParams)

getReturnType

public final String getReturnType()
Returns:
the return type of this method, used for building post checks

isConstructor

public final boolean isConstructor()
Returns:
true if this method is a constructor, therefore do the special processing for the preConditions and don't check the invariant at the top of the method, only at the bottom.

isVoid

public final boolean isVoid()
Returns:
true if this method is a void method, this includes constructors.

getClose

public final CodePoint getClose()
Returns:
the point at which should be added to be just outside the method, location of '}' + 1

setClose

public final void setClose(CodePoint close)
Set the point at which should be added to be just outside the method, location of '}' + 1


toString

public String toString()

setThrownExceptions

public final void setThrownExceptions(Set thrownExceptions)
PreConditions
(thrownExceptions != null)

getThrownExceptions

public final Set getThrownExceptions()

getMods

public Set getMods()
Returns:
the set of modifiers for this method.

isStatic

public final boolean isStatic()
Returns:
true if this method is static, therefore the pre and post checks need to be static and the invariant condition isn't checked.

isPrivate

public final boolean isPrivate()
Returns:
true if this method is private, therefore the invariant condition isn't checked.

isAbstract

public final boolean isAbstract()
Returns:
true if this method is abstract or native

getVisibility

public final String getVisibility()
Look at the mods list and determine the visibility of this method.

Returns:
a string representing the visibility of this method, /*package*/ is returned for package visibility

getAssertMethodVisibility

public final String getAssertMethodVisibility()
Look at the mods list and determine what the visibility of the method that checks assertions should be. This returns the visibility of the method in all cases except for public. In this case "protected" is returned.

Returns:
a string representing the visibility of this method, /*package*/ is returned for package visibility