Class XMLLogger

    • Field Detail

      • ENTITIES

        private static final java.lang.String[] ENTITIES
        Some known entities to detect.
      • closeStream

        private final boolean closeStream
        Close output stream in auditFinished.
      • writerLock

        private final java.lang.Object writerLock
        The writer lock object.
      • writer

        private final java.io.PrintWriter writer
        Helper writer that allows easy encoding and printing.
    • Constructor Detail

      • XMLLogger

        public XMLLogger​(java.io.OutputStream outputStream,
                         AutomaticBean.OutputStreamOptions outputStreamOptions)
        Creates a new XMLLogger instance. Sets the output to a defined stream.
        Parameters:
        outputStream - the stream to write logs to.
        outputStreamOptions - if CLOSE stream should be closed in auditFinished()
        Throws:
        java.lang.IllegalArgumentException - if outputStreamOptions is null.
      • XMLLogger

        public XMLLogger​(java.io.OutputStream outputStream,
                         AbstractAutomaticBean.OutputStreamOptions outputStreamOptions)
        Creates a new XMLLogger instance. Sets the output to a defined stream.
        Parameters:
        outputStream - the stream to write logs to.
        outputStreamOptions - if CLOSE stream should be closed in auditFinished()
        Throws:
        java.lang.IllegalArgumentException - if outputStreamOptions is null.
    • Method Detail

      • writeFileMessages

        private void writeFileMessages​(java.lang.String fileName,
                                       XMLLogger.FileMessages messages)
        Prints 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.
      • writeFileOpeningTag

        private void writeFileOpeningTag​(java.lang.String fileName)
        Prints the "file" opening tag with the given filename.
        Parameters:
        fileName - The filename to output.
      • writeFileError

        private void writeFileError​(AuditEvent event)
        Outputs the given event to the writer.
        Parameters:
        event - An event to print.
      • addException

        public void addException​(AuditEvent event,
                                 java.lang.Throwable throwable)
        Description copied from interface: AuditListener
        Notify that an exception happened while performing audit.
        Specified by:
        addException in interface AuditListener
        Parameters:
        event - the event details
        throwable - details of the exception
      • writeException

        private void writeException​(java.lang.Throwable throwable)
        Writes the exception event to the print writer.
        Parameters:
        throwable - The
      • encode

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

        public static boolean isReference​(java.lang.String ent)
        Finds 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