Holger's
Java API

com.antelmann.util.logging
Class AbstractLogWriter<T>

java.lang.Object
  extended by com.antelmann.util.logging.AbstractLogWriter<T>
All Implemented Interfaces:
Filter<LogEntry>, LogWriter
Direct Known Subclasses:
BinaryFileLog, ConsoleLog, ExceptionDialogWriter, FileLog, JDBCLogWriter, JTextComponentLog, LogFile, LogNetPropagator, SocketWriter, StackTraceFileWriter, StringBufferLog, XMLLogWriter

public abstract class AbstractLogWriter<T>
extends Object
implements LogWriter

provides filtering capabilities for a LogWriter. Extending classes only need to implement writeLogPattern(Object).

Author:
Holger Antelmann

Field Summary
protected  Filter<LogEntry> filter
          may be null (in which case all LogEntry objects are written)
 
Constructor Summary
protected AbstractLogWriter(LogEntryFormatter<T> formatter)
           
protected AbstractLogWriter(LogEntryFormatter<T> formatter, Filter<LogEntry> filter)
           
 
Method Summary
 boolean accept(LogEntry entry)
          returns true if either the filter is null or the filter accepts the given entry
 Filter<LogEntry> getLogFilter()
           
 LogEntryFormatter<T> getLogFormatter()
           
 void setLogFilter(Filter<LogEntry> filter)
           
protected  void setLogFormatter(LogEntryFormatter<T> formatter)
          formatter must not be null
 void write(LogEntry entry)
          normally not to be overridden; checks the filter and calls writeLogPattern
protected abstract  void writeLogPattern(T pattern)
          writes the pattern to the log entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

protected Filter<LogEntry> filter
may be null (in which case all LogEntry objects are written)

Constructor Detail

AbstractLogWriter

protected AbstractLogWriter(LogEntryFormatter<T> formatter)

AbstractLogWriter

protected AbstractLogWriter(LogEntryFormatter<T> formatter,
                            Filter<LogEntry> filter)
Method Detail

getLogFilter

public Filter<LogEntry> getLogFilter()

setLogFilter

public void setLogFilter(Filter<LogEntry> filter)

accept

public boolean accept(LogEntry entry)
returns true if either the filter is null or the filter accepts the given entry

Specified by:
accept in interface Filter<LogEntry>

write

public void write(LogEntry entry)
           throws LogException
normally not to be overridden; checks the filter and calls writeLogPattern

Specified by:
write in interface LogWriter
Throws:
LogException - if an error occurred while writing the log

writeLogPattern

protected abstract void writeLogPattern(T pattern)
                                 throws LogException
writes the pattern to the log entity. If the LogEntryFormatter is null, the pattern is the LogEntry object itself; otherwise, the pattern is the result of formatting the LogEntry with the given LogEntryFormatter.

Throws:
LogException

getLogFormatter

public LogEntryFormatter<T> getLogFormatter()

setLogFormatter

protected void setLogFormatter(LogEntryFormatter<T> formatter)
formatter must not be null



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads