qflib 0.98.0

de.qfs.lib.log
Class AbstractLogUser

java.lang.Object
  |
  +--de.qfs.lib.log.AbstractLogUser
All Implemented Interfaces:
LogFilter, LogUser
Direct Known Subclasses:
LevelFilter, TreeFilter

public abstract class AbstractLogUser
extends java.lang.Object
implements LogUser

This class provides a default implementation of the LogUser interface that reduces the effort of writing a new LogFilter to implementing the isUseful method.

The filter methods are implemented according to the filter mode setting as documented in LogUser.

Useful messages are passed to a LogWriter that can be set via setLogWriter.

Since:
0.98.0
Version:
$Revision: 1.1 $
Author:
Gregor Schmid

Field Summary
protected  int mode
          The LogUser mode.
 
Fields inherited from interface de.qfs.lib.log.LogUser
FILTER_ALL, FILTER_NONE, FILTER_UNUSED, FILTER_USED
 
Constructor Summary
AbstractLogUser(int mode, LogWriter writer)
          Create a new AbstractLogUser.
 
Method Summary
 boolean filter(LogEntry entry)
          Filter a LogEntry and possibly write it to the LogWriter.
 LogEntry[] filter(LogEntry[] entries)
          Filter an array of LogEntries, possibly writing some of them to the LogWriter.
 LogWriter getLogWriter()
          Get the LogWriter of the AbstractLogUser.
protected abstract  boolean isUseful(LogEntry entry)
          Decide whether a log message is useful and should be passed to the LogWriter.
 void setFilterMode(int mode)
          Configure the AbstractLogUser's filter mode.
 void setLogWriter(LogWriter writer)
          Set the LogWriter of the AbstractLogUser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mode

protected int mode
The LogUser mode.
Constructor Detail

AbstractLogUser

public AbstractLogUser(int mode,
                       LogWriter writer)
Create a new AbstractLogUser.
Parameters:
mode - The LogUser mode.
writer - The LogWriter to write entries to.
Method Detail

getLogWriter

public final LogWriter getLogWriter()
Get the LogWriter of the AbstractLogUser.
Returns:
The writer of the AbstractLogUser.

setLogWriter

public final void setLogWriter(LogWriter writer)
Set the LogWriter of the AbstractLogUser.
Parameters:
writer - The writer to set.

filter

public boolean filter(LogEntry entry)
Filter a LogEntry and possibly write it to the LogWriter.
Specified by:
filter in interface LogFilter
Parameters:
logEntry - The entry to filter.
Returns:
True if the entry should be passed on to the next filter.

filter

public LogEntry[] filter(LogEntry[] entries)
Filter an array of LogEntries, possibly writing some of them to the LogWriter.
Specified by:
filter in interface LogFilter
Parameters:
entries - The entries to filter.

setFilterMode

public void setFilterMode(int mode)
Configure the AbstractLogUser's filter mode.
Specified by:
setFilterMode in interface LogUser
Parameters:
mode - The mode to set.

isUseful

protected abstract boolean isUseful(LogEntry entry)
Decide whether a log message is useful and should be passed to the LogWriter.
Parameters:
entry - The LogEntry to check.
Returns:
True if the entry is considered useful, false to skip it.

qflib 0.98.0