public class XMLLogger extends AutomaticBean implements AuditListener
Modifier and Type | Field and Description |
---|---|
private static int |
BASE_10
Decimal radix.
|
private static int |
BASE_16
Hex radix.
|
private boolean |
closeStream
Close output stream in auditFinished.
|
private static java.lang.String[] |
ENTITIES
Some known entities to detect.
|
private java.io.PrintWriter |
writer
Helper writer that allows easy encoding and printing.
|
Constructor and Description |
---|
XMLLogger(java.io.OutputStream outputStream,
boolean closeStream)
Creates a new
XMLLogger instance. |
Modifier and Type | Method and Description |
---|---|
void |
addError(AuditEvent event)
Notify that an audit error was discovered on a specific file.
|
void |
addException(AuditEvent event,
java.lang.Throwable throwable)
Notify that an exception happened while performing audit.
|
void |
auditFinished(AuditEvent event)
Notify that the audit is finished.
|
void |
auditStarted(AuditEvent event)
Notify that the audit is about to start.
|
static java.lang.String |
encode(java.lang.String value)
Escape <, > & ' and " as their entities.
|
private static java.lang.String |
encodeAmpersand(java.lang.String value,
int ampPosition)
Encodes ampersand in value at required position.
|
void |
fileFinished(AuditEvent event)
Notify that audit is finished on a specific file.
|
void |
fileStarted(AuditEvent event)
Notify that audit is about to start on a specific file.
|
static boolean |
isReference(java.lang.String ent)
Finds whether the given argument is character or entity reference.
|
private void |
setOutputStream(java.io.OutputStream outputStream)
Sets the OutputStream.
|
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
private static final int BASE_10
private static final int BASE_16
private static final java.lang.String[] ENTITIES
private final boolean closeStream
private java.io.PrintWriter writer
public XMLLogger(java.io.OutputStream outputStream, boolean closeStream)
XMLLogger
instance.
Sets the output to a defined stream.outputStream
- the stream to write logs to.closeStream
- close oS in auditFinishedprivate void setOutputStream(java.io.OutputStream outputStream)
outputStream
- the OutputStream to usepublic void auditStarted(AuditEvent event)
AuditListener
auditStarted
in interface AuditListener
event
- the event detailspublic void auditFinished(AuditEvent event)
AuditListener
auditFinished
in interface AuditListener
event
- the event detailspublic void fileStarted(AuditEvent event)
AuditListener
fileStarted
in interface AuditListener
event
- the event detailspublic void fileFinished(AuditEvent event)
AuditListener
fileFinished
in interface AuditListener
event
- the event detailspublic void addError(AuditEvent event)
AuditListener
addError
in interface AuditListener
event
- the event detailspublic void addException(AuditEvent event, java.lang.Throwable throwable)
AuditListener
addException
in interface AuditListener
event
- the event detailsthrowable
- details of the exceptionpublic static java.lang.String encode(java.lang.String value)
value
- the value to escape.public static boolean isReference(java.lang.String ent)
ent
- the possible entity to look for.private static java.lang.String encodeAmpersand(java.lang.String value, int ampPosition)
value
- string value, which contains ampersandampPosition
- position of ampersand in value