Package com.puppycrawl.tools.checkstyle
Class XMLLogger
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.XMLLogger
- All Implemented Interfaces:
- AuditListener,- Configurable,- Contextualizable,- EventListener
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 file names are
 localized and takes care about escaping as well.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprivate static final classThe registered file messages.Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanAbstractAutomaticBean.OutputStreamOptions
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate static final intDecimal radix.private static final intHex radix.private final booleanClose output stream in auditFinished.private static final String[]Some known entities to detect.private final Map<String,XMLLogger.FileMessages> Holds all messages for the given file.private final PrintWriterHelper writer that allows easy encoding and printing.
- 
Constructor SummaryConstructorsConstructorDescriptionXMLLogger(OutputStream outputStream, AbstractAutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newXMLLoggerinstance.XMLLogger(OutputStream outputStream, AutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newXMLLoggerinstance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddError(AuditEvent event) Notify that an audit error was discovered on a specific file.voidaddException(AuditEvent event, Throwable throwable) Notify that an exception happened while performing audit.voidauditFinished(AuditEvent event) Notify that the audit is finished.voidauditStarted(AuditEvent event) Notify that the audit is about to start.static StringEscape <, > & ' and " as their entities.voidfileFinished(AuditEvent event) Notify that audit is finished on a specific file.voidfileStarted(AuditEvent event) Notify that audit is about to start on a specific file.protected voidProvides a hook to finish the part of this component's setup that was not handled by the bean introspection.static booleanisReference(String ent) Finds whether the given argument is character or entity reference.private voidReturns the version string printed.private voidwriteException(Throwable throwable) Writes the exception event to the print writer.private voidPrints the "file" closing tag.private voidwriteFileError(AuditEvent event) Outputs the given event to the writer.private voidwriteFileMessages(String fileName, XMLLogger.FileMessages messages) Prints the file section with all file errors and exceptions.private voidwriteFileOpeningTag(String fileName) Prints the "file" opening tag with the given filename.Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanconfigure, contextualize, getConfiguration, setupChild
- 
Field Details- 
BASE_10Decimal radix.- See Also:
 
- 
BASE_16Hex radix.- See Also:
 
- 
ENTITIESSome known entities to detect.
- 
closeStreamClose output stream in auditFinished.
- 
fileMessagesHolds all messages for the given file.
- 
writerHelper writer that allows easy encoding and printing.
 
- 
- 
Constructor Details- 
XMLLoggerCreates a newXMLLoggerinstance. Sets the output to a defined stream.- Parameters:
- outputStream- the stream to write logs to.
- outputStreamOptions- if- CLOSEstream should be closed in auditFinished()
- Throws:
- IllegalArgumentException- if outputStreamOptions is null.
 
- 
XMLLoggerpublic XMLLogger(OutputStream outputStream, AbstractAutomaticBean.OutputStreamOptions outputStreamOptions) Creates a newXMLLoggerinstance. Sets the output to a defined stream.- Parameters:
- outputStream- the stream to write logs to.
- outputStreamOptions- if- CLOSEstream should be closed in auditFinished()
- Throws:
- IllegalArgumentException- if outputStreamOptions is null.
 
 
- 
- 
Method Details- 
finishLocalSetupDescription copied from class:AbstractAutomaticBeanProvides a hook to finish the part of this component's setup that was not handled by the bean introspection.The default implementation does nothing. - Specified by:
- finishLocalSetupin class- AbstractAutomaticBean
 
- 
printVersionStringReturns the version string printed.
- 
auditStartedDescription copied from interface:AuditListenerNotify that the audit is about to start.- Specified by:
- auditStartedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
auditFinishedDescription copied from interface:AuditListenerNotify that the audit is finished.- Specified by:
- auditFinishedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
fileStartedDescription copied from interface:AuditListenerNotify that audit is about to start on a specific file.- Specified by:
- fileStartedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
fileFinishedDescription copied from interface:AuditListenerNotify that audit is finished on a specific file.- Specified by:
- fileFinishedin interface- AuditListener
- Parameters:
- event- the event details
 
- 
writeFileMessagesPrints the file section with all file errors and exceptions.- Parameters:
- fileName- The file name, as should be printed in the opening file tag.
- messages- The file messages.
 
- 
writeFileOpeningTagPrints the "file" opening tag with the given filename.- Parameters:
- fileName- The filename to output.
 
- 
writeFileClosingTagPrints the "file" closing tag.
- 
addErrorDescription copied from interface:AuditListenerNotify that an audit error was discovered on a specific file.- Specified by:
- addErrorin interface- AuditListener
- Parameters:
- event- the event details
 
- 
writeFileErrorOutputs the given event to the writer.- Parameters:
- event- An event to print.
 
- 
addExceptionDescription copied from interface:AuditListenerNotify that an exception happened while performing audit.- Specified by:
- addExceptionin interface- AuditListener
- Parameters:
- event- the event details
- throwable- details of the exception
 
- 
writeExceptionWrites the exception event to the print writer.- Parameters:
- throwable- The
 
- 
encodeEscape <, > & ' and " as their entities.- Parameters:
- value- the value to escape.
- Returns:
- the escaped value if necessary.
 
- 
isReferenceFinds whether the given argument is character or entity reference.- Parameters:
- ent- the possible entity to look for.
- Returns:
- whether the given argument a character or entity reference
 
 
-