Jcontract API

jcontract
Class LogRuntimeHandler

java.lang.Object
  |
  +--jcontract.RuntimeHandler
        |
        +--jcontract.LogRuntimeHandler
Direct Known Subclasses:
LogStderrRuntimeHandler, LogStdoutRuntimeHandler

public class LogRuntimeHandler
extends RuntimeHandler

A non-intrusive RuntimeHandler.
Logs all the contract violations into a "./jcontract.log" file.
The logging information also includes the instrumented classes loaded, environment information and statistics collected while running the program.


Constructor Summary
LogRuntimeHandler()
           
 
Method Summary
 void contractViolation(java.lang.RuntimeException exception)
          Logs the contract violated
protected  java.io.PrintStream getLogStream()
          Returns the current log stream
protected  void instrumentedClassLoaded(java.lang.String class_name)
          Logs the name of the class
protected  void log()
          logs an empty line
protected  void log(java.lang.String line)
          Logs a line to the log stream
protected  boolean logActive()
          Returns true if the log stream is not null
protected  void logViolation(java.lang.RuntimeException exception)
          Logs the contract violation described by the exception
 java.io.PrintStream makeLogStream()
          Returns the default log PrintStream (the file "jcontract.log").
Override this method if you want the log PrintStream to go to a different stream.
protected  void shutdownAction()
          Prints the RuntimeStatistics for this Runtime Handler
protected  void startAction()
          Prints the JContract's Copyright message
 
Methods inherited from class jcontract.RuntimeHandler
documentedExceptionThrown, getRuntimeStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogRuntimeHandler

public LogRuntimeHandler()
Method Detail

contractViolation

public void contractViolation(java.lang.RuntimeException exception)
Logs the contract violated
Overrides:
contractViolation in class RuntimeHandler
Following copied from class: jcontract.RuntimeHandler
Parameters:
exception - the exception that describes the contract violated

getLogStream

protected final java.io.PrintStream getLogStream()
Returns the current log stream

instrumentedClassLoaded

protected final void instrumentedClassLoaded(java.lang.String class_name)
Logs the name of the class
Overrides:
instrumentedClassLoaded in class RuntimeHandler
Following copied from class: jcontract.RuntimeHandler
Parameters:
class_name - name of the class being loaded

log

protected final void log()
logs an empty line

log

protected final void log(java.lang.String line)
Logs a line to the log stream
Parameters:
line - line to be logged

logActive

protected final boolean logActive()
Returns true if the log stream is not null

logViolation

protected final void logViolation(java.lang.RuntimeException exception)
Logs the contract violation described by the exception

makeLogStream

public java.io.PrintStream makeLogStream()
                                  throws java.io.IOException
Returns the default log PrintStream (the file "jcontract.log").
Override this method if you want the log PrintStream to go to a different stream.

shutdownAction

protected void shutdownAction()
Prints the RuntimeStatistics for this Runtime Handler
Overrides:
shutdownAction in class RuntimeHandler

startAction

protected void startAction()
Prints the JContract's Copyright message
Overrides:
startAction in class RuntimeHandler

Jcontract API