cmsc433.p1
Class LogRecord

java.lang.Object
  extended by cmsc433.p1.LogRecord

public class LogRecord
extends java.lang.Object

A LogRecord describes a logged event. A LogRecord consists of an event name, an event identifier number, and the time at which the event took place. The identifier number is taken from an internal counter, which starts at 0 and is incremented each time a LogRecord is created. LogRecords are immutable. That is, once created, they are never changed. This class should be thread-safe.


Constructor Summary
LogRecord(java.lang.String event)
          Constructor specifying a string description of an event; events are not allowed to contain "newlines" \n.
 
Method Summary
 java.lang.String getEvent()
          Returns the event portion of the LogRecord.
 java.util.Date getTimestamp()
          Returns the time when this LogRecord was created.
 java.lang.String toString()
          Creates a string representation of the LogRecord suitable for printing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogRecord

public LogRecord(java.lang.String event)
Constructor specifying a string description of an event; events are not allowed to contain "newlines" \n. In addition to storing the string, it will store the current time (using the java.util.Date class) and a unique numeric ID, drawn from the internal counter, which starts at 0 and is incremented each time a LogRecord is created.

Method Detail

getEvent

public java.lang.String getEvent()
Returns the event portion of the LogRecord.


getTimestamp

public java.util.Date getTimestamp()
Returns the time when this LogRecord was created.


toString

public java.lang.String toString()
Creates a string representation of the LogRecord suitable for printing. The string is formatted as: timestamp + " / #" + eventID + " / " + event_string where timestamp is the string representation of the Date object storing the time associated with the event, eventID is the unique ID associated with this event, and event_string is the string that was passed into the constructor when this event was created.

Overrides:
toString in class java.lang.Object