de.hunsicker.jalopy.plugin
Class AbstractAppender

java.lang.Object
  |
  +--org.apache.log4j.AppenderSkeleton
        |
        +--de.hunsicker.jalopy.plugin.AbstractAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler, SwingAppender

public abstract class AbstractAppender
extends org.apache.log4j.AppenderSkeleton
implements SwingAppender

Skeleton implementation of an appender which outputs messages in a visual component.

Version:
$Revision: 1.4.2.2 $
Author:
Marco Hunsicker

Field Summary
static int POS_COLUMN
          Position of the message text in the regex result.
static int POS_FILENAME
          Position of the filename in the regex result.
static int POS_LINE
          Position of the lineno in the regex result.
static int POS_TEXT
          Position of the message text in the regex result.
protected  java.util.regex.Pattern regex
          The regex to parse the messages.
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
AbstractAppender()
          Creates a new AbstractAppender object.
 
Method Summary
abstract  void append(org.apache.log4j.spi.LoggingEvent ev)
          Does the actual outputting.
protected  boolean checkEntryConditions()
          
 void close()
          
 void done()
          Notifies the appender that a run was finished.
 java.util.regex.Matcher parseMessage(org.apache.log4j.spi.LoggingEvent ev)
          Parses the given message.
 boolean requiresLayout()
          
 void setName(java.lang.String name)
          Sets the name of the appender.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.hunsicker.jalopy.plugin.SwingAppender
clear
 
Methods inherited from interface org.apache.log4j.Appender
addFilter, clearFilters, doAppend, getErrorHandler, getFilter, getLayout, getName, setErrorHandler, setLayout
 

Field Detail

POS_FILENAME

public static final int POS_FILENAME
Position of the filename in the regex result.

See Also:
Constant Field Values

POS_LINE

public static final int POS_LINE
Position of the lineno in the regex result.

See Also:
Constant Field Values

POS_TEXT

public static final int POS_TEXT
Position of the message text in the regex result.

See Also:
Constant Field Values

POS_COLUMN

public static final int POS_COLUMN
Position of the message text in the regex result.

See Also:
Constant Field Values

regex

protected final java.util.regex.Pattern regex
The regex to parse the messages. If messages have a format similiar to Emacs messages (filename:lineno:text) the pattern will match.

Constructor Detail

AbstractAppender

public AbstractAppender()
Creates a new AbstractAppender object.

Throws:
ChainingRuntimeException - If an error occurs
Method Detail

append

public abstract void append(org.apache.log4j.spi.LoggingEvent ev)
Does the actual outputting.

Specified by:
append in class org.apache.log4j.AppenderSkeleton
Parameters:
ev - logging event.

setName

public final void setName(java.lang.String name)
Sets the name of the appender. Overidden so that the initial name can't be changed.

Specified by:
setName in interface org.apache.log4j.Appender
Overrides:
setName in class org.apache.log4j.AppenderSkeleton
Parameters:
name - appender name (ignored).

close

public void close()

Specified by:
close in interface org.apache.log4j.Appender

done

public void done()
Notifies the appender that a run was finished.

Specified by:
done in interface SwingAppender

parseMessage

public java.util.regex.Matcher parseMessage(org.apache.log4j.spi.LoggingEvent ev)
Parses the given message. To access the parsed information one may typically use:
 MatchResult result = parseMessage(message);
 if (result == null)
 {
     // handle plain message
     ...
 }
 else
 {
     // this is an Emacs style message, you can easily access the
     // information
     String filename = result.group(POS_FILENAME);
     String line = result.group(POS_LINE);
     String column = result.group(POS_COLUMN);
     String text = result.group(POS_TEXT);
     ...
 }
 

Parameters:
ev - logging event.
Returns:
parsing result. Returns null if the message doesn't match the Emacs format filename:line:column:text.

requiresLayout

public boolean requiresLayout()

Specified by:
requiresLayout in interface org.apache.log4j.Appender
Returns:
always true.

checkEntryConditions

protected boolean checkEntryConditions()

Returns:
always true.


Copyright © 1997-2005 Jalopy. All Rights Reserved.