net.mtu.eggplant.dbc
Class CodeGenerator

java.lang.Object
  extended bynet.mtu.eggplant.dbc.CodeGenerator

public final class CodeGenerator
extends Object

Version:
$Revision: 1.14 $

Method Summary
static String generateAssertClassForInterface(AssertClass assertInterface)
          Assertions on interfaces are checked by using a delegate class.
static String generateAssertion(AssertToken tok)
          This should be inserted right after the close of the javadoc comment.
static String generateConstructorAssertions(AssertMethod assertMethod)
          Generate the calls to pre, post and invariant conditions for a constructor.
static String generateInvariantCall(AssertClass aClass)
          This should be added at the start and end of all instance methods, except for private ones and should be at the end of constructors that aren't private.
static String generateInvariantMethod(AssertClass assertClass)
          This should be inserted right at the end of a class, just before the closing curly.
static String generatePostConditionCall(AssertMethod assertMethod)
           
static String generatePostConditionMethod(AssertMethod assertMethod)
           
static String generatePreConditionCall(AssertMethod assertMethod)
          This code should be inserted right at the start of the method
static String generatePreConditionMethod(AssertMethod assertMethod)
           
static String getClassObjectForClass(String cl)
          Convert a class name to a class object call.
static String getObjectForParam(String paramType, String paramName)
          Take paramName and turn it into an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generateAssertion

public static String generateAssertion(AssertToken tok)
This should be inserted right after the close of the javadoc comment.

Parameters:
tok - the token that represents the assertion
Returns:
a String of code that checks this assert condition
PreConditions
(tok != null)

generateInvariantCall

public static String generateInvariantCall(AssertClass aClass)
This should be added at the start and end of all instance methods, except for private ones and should be at the end of constructors that aren't private.

Returns:
a string of code that will call the checkInvariant method

generateInvariantMethod

public static String generateInvariantMethod(AssertClass assertClass)
This should be inserted right at the end of a class, just before the closing curly.

Parameters:
assertClass - the class to generate the invariant check for
Returns:
a string of code that actually checks the invariant conditions
PreConditions
(assertClass != null)

generatePreConditionCall

public static String generatePreConditionCall(AssertMethod assertMethod)
This code should be inserted right at the start of the method

Parameters:
assertMethod - the method to generate the precondition call for
Returns:
the code for a call to check the pre conditions for the given method
PreConditions
(assertMethod != null)

generateConstructorAssertions

public static String generateConstructorAssertions(AssertMethod assertMethod)
Generate the calls to pre, post and invariant conditions for a constructor. Constructors are different enough to need they're own generator.

PreConditions
(null != assertMethod && assertMethod.isConstructor())

generatePostConditionCall

public static String generatePostConditionCall(AssertMethod assertMethod)
Parameters:
assertMethod - the method to generate the post condition check call for
Returns:
code to call the post condition check for a method
PreConditions
(assertMethod != null)

generatePreConditionMethod

public static String generatePreConditionMethod(AssertMethod assertMethod)
Returns:
the code neccessary to implement the pre conditions on this method

generatePostConditionMethod

public static String generatePostConditionMethod(AssertMethod assertMethod)
Returns:
the code neccessary to implement the post conditions on this method

generateAssertClassForInterface

public static String generateAssertClassForInterface(AssertClass assertInterface)
Assertions on interfaces are checked by using a delegate class. This method generates that class.

PreConditions
(assertInterface != null && assertInterface.isInterface())

getClassObjectForClass

public static String getClassObjectForClass(String cl)
Convert a class name to a class object call. Normally this is just appending '.class', however primatives need to be converted to the appropriate wrapper class and then append '.TYPE'.

PreConditions
(cl != null)

getObjectForParam

public static String getObjectForParam(String paramType,
                                       String paramName)
Take paramName and turn it into an object. This only effects primatives, if paramType is a primative, return code that will generate a properly wrapped primative object, otherwise just return paramName.