cmsc433.p1
Class NullLog

java.lang.Object
  extended by cmsc433.p1.NullLog
All Implemented Interfaces:
Log

public class NullLog
extends java.lang.Object
implements Log

A Log that discards all elements added to it. However, listeners should be notified when the add method is called. This class should be thread-safe.


Constructor Summary
NullLog()
           
 
Method Summary
 void add(LogRecord l)
          Stores a LogRecord in the Log.
 java.util.List<LogRecord> flush()
          Returns all LogRecords kept in the log, emptying the log.
 java.util.List<LogRecord> getAll(long windowMS)
          Returns all LogRecords whose timestamps are within a window of time.
 void register(Listener<LogRecord> l)
          Registers a listener that whose notify() method will be called whenever a record is added to this log; the first argument of notify() is the log itself, and the second is the LogRecord that was added.
 java.lang.String toString()
           
 void unregister(Listener<LogRecord> l)
          Removes a previously-registered listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NullLog

public NullLog()
Method Detail

add

public void add(LogRecord l)
Description copied from interface: Log
Stores a LogRecord in the Log. Implementations may choose to only add some logs (e.g. logs matching a given pattern).

Specified by:
add in interface Log

getAll

public java.util.List<LogRecord> getAll(long windowMS)
Description copied from interface: Log
Returns all LogRecords whose timestamps are within a window of time. Note that inclusion is based on the timestamp of the LogRecord, not the time at which the record was stored in the Log. This is non-destructive; all records remain in the Log.

Specified by:
getAll in interface Log
Parameters:
windowMS - return all records from the last [windowMS] milliseconds.

flush

public java.util.List<LogRecord> flush()
Description copied from interface: Log
Returns all LogRecords kept in the log, emptying the log.

Specified by:
flush in interface Log

register

public void register(Listener<LogRecord> l)
Description copied from interface: Log
Registers a listener that whose notify() method will be called whenever a record is added to this log; the first argument of notify() is the log itself, and the second is the LogRecord that was added.

Specified by:
register in interface Log
Parameters:
l - The listener to register.

unregister

public void unregister(Listener<LogRecord> l)
Description copied from interface: Log
Removes a previously-registered listener.

Specified by:
unregister in interface Log
Parameters:
l - The listener to remove. If this listener is not present, then unregister behaves as a no-op.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object