net.mtu.eggplant.dbc
Class CodeFragment

java.lang.Object
  extended bynet.mtu.eggplant.dbc.CodeFragment
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
CodeModification

public class CodeFragment
extends Object
implements Comparable

Class that represents a fragment of code that needs to be inserted into a file to instrument it for assertions.

Version:
$Revision: 1.4 $

Constructor Summary
CodeFragment(CodePoint location, String code, CodeFragmentType type)
          create a new CodeFragment
 
Method Summary
 int compareTo(Object o)
          Only compares to other CodeFragments.
 boolean equals(Object o)
           
 String getCode()
          what code to insert
 CodePoint getLocation()
          where to insert the code
 CodeFragmentType getType()
          what type of assertion is this.
 int hashCode()
           
 int instrumentLine(int offset, StringBuffer line)
          Instrument the given line.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CodeFragment

public CodeFragment(CodePoint location,
                    String code,
                    CodeFragmentType type)
create a new CodeFragment

PreConditions
(location != null), (code != null), (type != null)
Method Detail

getLocation

public final CodePoint getLocation()
where to insert the code


getCode

public final String getCode()
what code to insert


getType

public final CodeFragmentType getType()
what type of assertion is this.


equals

public boolean equals(Object o)

hashCode

public int hashCode()

toString

public String toString()

instrumentLine

public int instrumentLine(int offset,
                          StringBuffer line)
Instrument the given line.

Parameters:
offset - how many characters have been added to this line since it was pulled from the file
line - the line to modify
Returns:
the new offset

compareTo

public int compareTo(Object o)
              throws ClassCastException
Only compares to other CodeFragments.

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to compare to
Throws:
ClassCastException - if o is not a CodeFragment