tcra.math
Class MethodContract

java.lang.Object
  extended by tcra.math.MethodContract
Direct Known Subclasses:
QueueClearContract, QueueDequeueContract, QueueEnqueueContract, QueueFrontContract, QueueLengthContract, StackClearContract, StackLengthContract, StackPopContract, StackPushContract, StackTopContract

public abstract class MethodContract
extends java.lang.Object

Representation of a method's formal contract.


Field Summary
protected  java.util.Vector<MethodArgument> args
           
protected  java.lang.String name
           
protected  Assertion postcondition
           
protected  Assertion precondition
           
protected  ProgrammingType returnType
           
 
Constructor Summary
protected MethodContract(java.lang.String name)
           
 
Method Summary
abstract  boolean check(java.lang.String[] l)
          Returns whether the supplied values hold to the precondition and postcondition using the Assertions' check method.
It is recommended that the parsed input is saved in a private variable of any extending class for use in the toInstanceString method.
 java.util.List<MethodArgument> getArgs()
          Returns the list of arguments required by this method.
 java.lang.String getMethodName()
          Returns the signature of the method being tested.
 Assertion getPostcondition()
          Returns the postconditional Assertion.
 Assertion getPrecondition()
          Returns the preconditional Assertion.
 ProgrammingType getReturnType()
          Returns the programming type of what is returned from this method.
abstract  java.lang.String toInstanceString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

precondition

protected Assertion precondition

postcondition

protected Assertion postcondition

args

protected java.util.Vector<MethodArgument> args

returnType

protected ProgrammingType returnType
Constructor Detail

MethodContract

protected MethodContract(java.lang.String name)
Method Detail

getMethodName

public java.lang.String getMethodName()
Returns the signature of the method being tested.

Returns:
the signature of the method

getPrecondition

public Assertion getPrecondition()
Returns the preconditional Assertion.

Returns:
the preconditional assertion

getPostcondition

public Assertion getPostcondition()
Returns the postconditional Assertion.

Returns:
the postconditional assertion

getArgs

public java.util.List<MethodArgument> getArgs()
Returns the list of arguments required by this method.

Returns:
list of Arguments

getReturnType

public ProgrammingType getReturnType()
Returns the programming type of what is returned from this method.

Returns:
programming type of the return value

check

public abstract boolean check(java.lang.String[] l)
                       throws MathFormatException
Returns whether the supplied values hold to the precondition and postcondition using the Assertions' check method.
It is recommended that the parsed input is saved in a private variable of any extending class for use in the toInstanceString method.

Parameters:
l - User input obtained from the GUI. Must be parsed by the contract to obtain the correct MathType objects
Returns:
true if the user input is parsed correctly and the values hold to the pre and postconditions. false if the values do not hold to the precondition and postcondition.
Throws:
MathFormatException - If the parsing of the user input goes awry.

toInstanceString

public abstract java.lang.String toInstanceString()