org.jminor.common.model
Class MethodLogger

java.lang.Object
  extended by org.jminor.common.model.MethodLogger

public class MethodLogger
extends Object

A cyclycal method logger.


Constructor Summary
MethodLogger(int logSize)
          Instantiates a new MethodLogger.
MethodLogger(int logSize, boolean enabled)
          Instantiates a new MethodLogger.
 
Method Summary
protected  String argumentArrayToString(Object[] arguments)
           
 long getLastAccessDate()
           
 String getLastAccessedMethod()
           
 String getLastAccessMessage()
           
 long getLastExitDate()
           
 String getLastExitedMethod()
           
 List<LogEntry> getLogEntries()
           
protected  String getMethodArgumentAsString(Object argument)
           
 boolean isEnabled()
           
 void logAccess(String method, Object[] arguments)
           
 LogEntry logExit(String method, Throwable exception, List<LogEntry> subLog)
           
 LogEntry logExit(String method, Throwable exception, List<LogEntry> subLog, String exitMessage)
           
 void reset()
          Resets this log
 void setEnabled(boolean enabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodLogger

public MethodLogger(int logSize)
Instantiates a new MethodLogger.

Parameters:
logSize - the log size

MethodLogger

public MethodLogger(int logSize,
                    boolean enabled)
Instantiates a new MethodLogger.

Parameters:
logSize - the log size
enabled - true if this logger should be enabled
Method Detail

getLastAccessDate

public final long getLastAccessDate()
Returns:
last access date

getLastAccessedMethod

public final String getLastAccessedMethod()
Returns:
the last accessed method

getLastAccessMessage

public final String getLastAccessMessage()
Returns:
the last access message

getLastExitDate

public final long getLastExitDate()
Returns:
the last exit message

getLastExitedMethod

public final String getLastExitedMethod()
Returns:
the last exited method

reset

public final void reset()
Resets this log


getLogEntries

public final List<LogEntry> getLogEntries()
Returns:
the log entries

logAccess

public final void logAccess(String method,
                            Object[] arguments)
Parameters:
method - the method being accessed
arguments - the method arguments

logExit

public final LogEntry logExit(String method,
                              Throwable exception,
                              List<LogEntry> subLog)
Parameters:
method - the method being exited
exception - the exception, if any
subLog - the sub-log, if any
Returns:
the LogEntry

logExit

public final LogEntry logExit(String method,
                              Throwable exception,
                              List<LogEntry> subLog,
                              String exitMessage)
Parameters:
method - the method being exited
exception - the exception, if any
subLog - the sub-log, if any
exitMessage - the exit message
Returns:
the LogEntry

isEnabled

public final boolean isEnabled()
Returns:
true if this logger is enabled

setEnabled

public final void setEnabled(boolean enabled)
Parameters:
enabled - true to enable this logger

getMethodArgumentAsString

protected String getMethodArgumentAsString(Object argument)
Parameters:
argument - the argument
Returns:
a String representation of the given argument

argumentArrayToString

protected final String argumentArrayToString(Object[] arguments)