com.puppycrawl.tools.checkstyle

Class XMLLogger

Implemented Interfaces:
AuditListener, EventListener, Configurable, Contextualizable

public class XMLLogger
extends AutomaticBean
implements AuditListener

Simple XML logger. It outputs everything in UTF-8 (default XML encoding is UTF-8) in case we want to localize error messages or simply that filenames are localized and takes care about escaping as well.
Author:
Stephane Bailliez

Constructor Summary

XMLLogger(OutputStream aOS, boolean aCloseStream)
Creates a new XMLLogger instance.

Method Summary

void
addError(AuditEvent aEvt)
void
addException(AuditEvent aEvt, Throwable aThrowable)
void
auditFinished(AuditEvent aEvt)
void
auditStarted(AuditEvent aEvt)
String
encode(String aValue)
Escape <, > & ' and " as their entities.
void
fileFinished(AuditEvent aEvt)
void
fileStarted(AuditEvent aEvt)
boolean
isReference(String aEnt)

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Constructor Details

XMLLogger

public XMLLogger(OutputStream aOS,
                 boolean aCloseStream)
Creates a new XMLLogger instance. Sets the output to a defined stream.
Parameters:
aOS - the stream to write logs to.
aCloseStream - close aOS in auditFinished

Method Details

addError

public void addError(AuditEvent aEvt)
Specified by:
addError in interface AuditListener

addException

public void addException(AuditEvent aEvt,
                         Throwable aThrowable)
Specified by:
addException in interface AuditListener

auditFinished

public void auditFinished(AuditEvent aEvt)
Specified by:
auditFinished in interface AuditListener

auditStarted

public void auditStarted(AuditEvent aEvt)
Specified by:
auditStarted in interface AuditListener

encode

public String encode(String aValue)
Escape <, > & ' and " as their entities.
Parameters:
aValue - the value to escape.
Returns:
the escaped value if necessary.

fileFinished

public void fileFinished(AuditEvent aEvt)
Specified by:
fileFinished in interface AuditListener

fileStarted

public void fileStarted(AuditEvent aEvt)
Specified by:
fileStarted in interface AuditListener

isReference

public boolean isReference(String aEnt)
Parameters:
aEnt - the possible entity to look for.
Returns:
whether the given argument a character or entity reference