|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcmsc433.p1.BasicFilterLog
public class BasicFilterLog
A basic implementation of FilterLog. Wraps an underlying log,
applying the current filter. Functions flush and getAll apply to the
underlying log as a whole, not just records added through the
BasicFilterLog add method.
This class should be thread-safe.
| Constructor Summary | |
|---|---|
BasicFilterLog()
Empty constructor creates a new BasicLog of unlimited
size as the underlying Log for this object. |
|
BasicFilterLog(Log log)
Constructor takes one argument, a log to be filtered. |
|
| Method Summary | |
|---|---|
void |
add(LogRecord record)
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> listener)
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. |
void |
setFilter(java.lang.String strPat)
Sets a regular-expression filter that governs which events are stored. |
void |
unregister(Listener<LogRecord> listener)
Removes a previously-registered listener. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BasicFilterLog(Log log)
log - public BasicFilterLog()
BasicLog of unlimited
size as the underlying Log for this object.
| Method Detail |
|---|
public void add(LogRecord record)
Log
add in interface Logpublic java.util.List<LogRecord> getAll(long windowMS)
Log
getAll in interface LogwindowMS - return all records from the last [windowMS]
milliseconds.public java.util.List<LogRecord> flush()
Log
flush in interface Logpublic void setFilter(java.lang.String strPat)
FilterLog
setFilter in interface FilterLogstrPat - is a regular expression to match against; if a
LogRecord is added with an event portion
matching this expression, then the LogRecord is retained.
Otherwise, the LogRecord is ignored.public void register(Listener<LogRecord> listener)
Log
register in interface Loglistener - The listener to register.public void unregister(Listener<LogRecord> listener)
Log
unregister in interface Loglistener - The listener to remove. If this listener is
not present, then unregister behaves as a no-op.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||