org.jminor.common.model
Class LogEntry

java.lang.Object
  extended by org.jminor.common.model.LogEntry
All Implemented Interfaces:
Serializable, Comparable<LogEntry>

public final class LogEntry
extends Object
implements Serializable, Comparable<LogEntry>

A class encapsulating a log entry for logging method calls.

See Also:
Serialized Form

Constructor Summary
LogEntry()
          Instantiates a new empty log entry.
LogEntry(LogEntry entry)
          A copy constructor
LogEntry(String method, String entryMessage, long time, long nanoTime, Throwable exception)
          Initializes a new LogEntry instance
 
Method Summary
 int compareTo(LogEntry o)
          
 boolean equals(Object obj)
          
 long getDelta()
           
 String getEntryMessage()
           
 long getEntryTime()
           
 String getEntryTimeFormatted()
           
 String getExitMessage()
           
 long getExitTime()
           
 String getExitTimeFormatted()
           
 String getMethod()
           
 String getStackTrace()
           
 List<LogEntry> getSubLog()
           
 int hashCode()
          
 boolean isComplete()
           
 void reset()
          Clears all info from this entry
 void set(String method, String entryMessage, long time, long nanoTime, Throwable exception)
          Initializes this LogEntry instance
 LogEntry setException(Throwable exception)
           
 LogEntry setExitMessage(String message)
           
 LogEntry setExitTimeNano(long exitTimeNano)
           
 void setSubLog(List<LogEntry> subLog)
           
 String toString()
          
 String toString(int indentation)
          Returns a string representation of this log entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogEntry

public LogEntry()
Instantiates a new empty log entry.


LogEntry

public LogEntry(LogEntry entry)
A copy constructor

Parameters:
entry - the log entry to copy

LogEntry

public LogEntry(String method,
                String entryMessage,
                long time,
                long nanoTime,
                Throwable exception)
Initializes a new LogEntry instance

Parameters:
method - the method being logged
entryMessage - a message describing for example the method arguments
time - the time at which to log the event
nanoTime - the nano precision time at which to log the event
exception - the exception thrown by the method execution if any
Method Detail

set

public void set(String method,
                String entryMessage,
                long time,
                long nanoTime,
                Throwable exception)
Initializes this LogEntry instance

Parameters:
method - the method being logged
entryMessage - a message describing for example the method arguments
time - the time at which to log the event
nanoTime - the nano precision time at which to log the event
exception - the exception thrown by the method execution if any

reset

public void reset()
Clears all info from this entry


getEntryTime

public long getEntryTime()
Returns:
the time this entry represents

setExitTimeNano

public LogEntry setExitTimeNano(long exitTimeNano)
Parameters:
exitTimeNano - the exit time in nano precision
Returns:
the difference between the given exit time and the entry time

getExitTime

public long getExitTime()
Returns:
the exit time

getDelta

public long getDelta()
Returns:
the duration of the method call this entry represents

getEntryMessage

public String getEntryMessage()
Returns:
the entry message

getMethod

public String getMethod()
Returns:
the method name

getStackTrace

public String getStackTrace()
Returns:
the stack trace, if any

setExitMessage

public LogEntry setExitMessage(String message)
Parameters:
message - the exit message
Returns:
this log entry

getExitMessage

public String getExitMessage()
Returns:
the exit message

setException

public LogEntry setException(Throwable exception)
Parameters:
exception - the exception
Returns:
this log entry

getEntryTimeFormatted

public String getEntryTimeFormatted()
Returns:
a formatted entry time

getExitTimeFormatted

public String getExitTimeFormatted()
Returns:
a formatted exit time

getSubLog

public List<LogEntry> getSubLog()
Returns:
the sub log, if any

setSubLog

public void setSubLog(List<LogEntry> subLog)
Parameters:
subLog - the sub log

isComplete

public boolean isComplete()
Returns:
true if this entry is complete, that is, has an exit time

compareTo

public int compareTo(LogEntry o)

Specified by:
compareTo in interface Comparable<LogEntry>

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object

toString

public String toString(int indentation)
Returns a string representation of this log entry.

Parameters:
indentation - the number of tab indents to prefix the string with
Returns:
a string representation of this log entry