|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.mtu.eggplant.dbc.AssertTools
class of static helper methods for assertions.
Nested Class Summary | |
static class |
AssertTools.MethodLock
Used for locking methods. |
Field Summary | |
static String |
ASSERT_BEHAVIOR
what to do if an assertion violation is raised |
static boolean |
ENFORCE_ASSERT_CONDITION
if assert conditions should be enforced |
static boolean |
ENFORCE_INHERITED_CONDITIONS
if inherited conditions should be enforced |
static boolean |
ENFORCE_INVARIANT_CONDITION
if invariant conditions should be enforced |
static boolean |
ENFORCE_POST_CONDITION
if post conditions should be enforced |
static boolean |
ENFORCE_PRE_CONDITION
if pre conditions should be enforced |
static net.mtu.eggplant.dbc.AssertTools.NONE |
NO_CLASS
Used to represent no class. |
static Method |
NO_METHOD
Used in caching to represent that no super method can be found. |
Method Summary | |
static void |
assertFailed(AssertionViolation av)
Called when an assert fails. |
static Class |
classForName(String className)
Get the class object for this class name. |
static boolean |
extendsObject(AssertClass clazz)
|
static void |
fail(AssertionViolation av)
Called to signal an assertion failure. |
static Class[] |
findAssertClassInterfaces(Class[] interfaces)
Do a depth first search of each interface heirarchy and return the class objects that implement the DBC conditions, if found. |
static Method |
findSuperMethod(Class thisClass,
String methodName,
Class[] methodArgs)
Find the superclasses method, this is my version of a superClass method, this means that the method name is __ |
static AssertionViolation |
getCurrentAssertionViolation()
|
static void |
internalError(String message)
called whenever an erorr occurs in the code that was generated that is not caused by the user. |
static void |
invariantFailed(AssertionViolation av)
called when an invariant fails. |
static boolean |
isPrimative(String type)
|
static AssertTools.MethodLock |
lockMethod(String signature,
Object instance)
Lock a method. |
static void |
postConditionFailed(AssertionViolation av)
called when a post condition fails. |
static void |
preConditionFailed(AssertionViolation av)
Called when a precondition fails. |
static void |
setCurrentAssertionViolation(AssertionViolation violation)
set the assertion violation that should be throw next. |
static void |
setUniqueParams(AssertClass assertClass)
Calculate the unique parameters for all constructors for class and set those values on the AssertMethod objects. |
static boolean |
unlockMethod(AssertTools.MethodLock lock)
Unlock a method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean ENFORCE_INHERITED_CONDITIONS
net.mtu.eggplant.dbc
public static final boolean ENFORCE_ASSERT_CONDITION
net.mtu.eggplant.dbc
public static final boolean ENFORCE_INVARIANT_CONDITION
net.mtu.eggplant.dbc
public static final boolean ENFORCE_PRE_CONDITION
net.mtu.eggplant.dbc
public static final boolean ENFORCE_POST_CONDITION
net.mtu.eggplant.dbc
public static final String ASSERT_BEHAVIOR
net.mtu.eggplant.dbc
public static final net.mtu.eggplant.dbc.AssertTools.NONE NO_CLASS
public static final Method NO_METHOD
Method Detail |
public static Class[] findAssertClassInterfaces(Class[] interfaces)
interfaces
- the interfaces to look in
public static Method findSuperMethod(Class thisClass, String methodName, Class[] methodArgs)
public static void setCurrentAssertionViolation(AssertionViolation violation)
public static AssertionViolation getCurrentAssertionViolation()
public static void assertFailed(AssertionViolation av)
av
- AssertionViolation with information about the failureENFORCE_ASSERT_CONDITION
public static void invariantFailed(AssertionViolation av)
av
- AssertionViolation with information about the failureENFORCE_INVARIANT_CONDITION
public static void postConditionFailed(AssertionViolation av)
av
- AssertionViolation with information about the failureENFORCE_POST_CONDITION
public static void preConditionFailed(AssertionViolation av)
av
- AssertionViolation with information about the failureENFORCE_PRE_CONDITION
public static void fail(AssertionViolation av)
ASSERT_BEHAVIOR
public static void internalError(String message)
public static Class classForName(String className)
Class.forName()
, but returns
null on an exception.
public static AssertTools.MethodLock lockMethod(String signature, Object instance)
signature
- the signature of the method to lockinstance
- the instance that should be locked. this or null (for
static methods)
public static boolean unlockMethod(AssertTools.MethodLock lock)
lock
- the lock that was recieved from lockMethod()
lockMethod(String, Object)
public static void setUniqueParams(AssertClass assertClass)
Calculate the unique parameters for all constructors for class and set those values on the AssertMethod objects. This is for creating a unique parameter list for checking preconditions on constructors. If in a class there exists a constructor C1 such that there is another constructor C2 that has number parameters N+1, where N is the number of parameters to C1, and the first N parameter types match exactly and the N+1 parameter is not a primative there is a possibility for ambiguity errors with the generated constructors. So boolean parameters are added to such constructors to guarentee uniqueness.
Here is an example:
This won't work: public class A { public A(int i) { this(i, new AssertDummy(i)); } private A(int i, AssertDummy ad) { //generated to handle preconditions } public A(int i, int j) { this(i, null); //should call following constructor, but with generated constructor is ambiguous } public A(int i, Component c) { //do something } } This will work: public class A { public A(int i) { this(i, true, new AssertDummy(i)); } private A(int i, boolean dummy0, AssertDummy ad) { //generated to handle preconditions } public A(int i, int j) { this(i, null); //should call following constructor, and now will since the code is no longer ambigous } public A(int i, Component c) { //do something } }
public static boolean isPrimative(String type)
type
- String that represents a java type
public static boolean extendsObject(AssertClass clazz)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |