Class IoLogger<T>

  • Type Parameters:
    T - The type of the Record instances managed by the Logger.
    All Implemented Interfaces:
    org.refcodes.logger.Logger<T>, org.refcodes.mixin.DelimiterAccessor, org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<IoLogger<T>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamMutator, org.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator, org.refcodes.mixin.TrimAccessor, org.refcodes.mixin.TrimAccessor.TrimBuilder<IoLogger<T>>, org.refcodes.mixin.TrimAccessor.TrimMutator, org.refcodes.mixin.TrimAccessor.TrimProperty, org.refcodes.textual.CsvEscapeModeAccessor, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<IoLogger<T>>, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty

    public class IoLogger<T>
    extends java.lang.Object
    implements org.refcodes.logger.Logger<T>, org.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator, org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamMutator, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<IoLogger<T>>, org.refcodes.mixin.TrimAccessor.TrimProperty, org.refcodes.mixin.TrimAccessor.TrimBuilder<IoLogger<T>>, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty, org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<IoLogger<T>>
    The IoLogger implements the Logger interface for providing logging functionality for I/O output (e.g. via System.out and System.err by default).
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.textual.CsvEscapeModeAccessor

        org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<B extends org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<?>>, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor

        org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.TrimAccessor

        org.refcodes.mixin.TrimAccessor.TrimBuilder<B extends org.refcodes.mixin.TrimAccessor.TrimBuilder<B>>, org.refcodes.mixin.TrimAccessor.TrimMutator, org.refcodes.mixin.TrimAccessor.TrimProperty
    • Constructor Summary

      Constructors 
      Constructor Description
      IoLogger()
      Constructs a IoLogger.
      IoLogger​(java.io.File aFile)
      Constructs a IoLogger.
      IoLogger​(java.io.File aInputFile, java.io.File aErrorFile)
      Constructs a IoLogger.
      IoLogger​(java.io.OutputStream aOutputStream)
      Constructs a IoLogger.
      IoLogger​(java.io.OutputStream aOutputStream, java.io.OutputStream aErrorStream)
      Constructs a IoLogger.
      IoLogger​(java.io.PrintStream aPrintStream)
      Constructs a IoLogger.
      IoLogger​(java.io.PrintStream aOutputStream, java.io.PrintStream aErrorStream)
      Constructs a IoLogger.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, char aCsvDelimiter)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.File aFile)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.File aFile, char aCsvDelimiter)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.File aInputFile, java.io.File aErrorFile)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.OutputStream aOutputStream)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.OutputStream aOutputStream, char aCsvDelimiter)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.OutputStream aOutputStream, java.io.OutputStream aErrorStream)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.PrintStream aPrintStream)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.PrintStream aPrintStream, char aCsvDelimiter)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.PrintStream aOutputStream, java.io.PrintStream aErrorStream)
      Constructs a IoLogger with the given header for logging.
      IoLogger​(org.refcodes.tabular.Header<T> aHeader, java.io.PrintStream aOutputStream, java.io.PrintStream aErrorStream, char aCsvDelimiter)
      Constructs a IoLogger with the given header for logging.
    • Field Detail

      • PROPERTY_ERROR_STREAM

        public static final java.lang.String PROPERTY_ERROR_STREAM
        See Also:
        Constant Field Values
      • PROPERTY_OUTPUT_STREAM

        public static final java.lang.String PROPERTY_OUTPUT_STREAM
        See Also:
        Constant Field Values
      • _header

        protected org.refcodes.tabular.Header<T> _header
      • _errorStream

        protected java.io.PrintStream _errorStream
      • _outputStream

        protected java.io.PrintStream _outputStream
      • _csvBuilder

        protected org.refcodes.textual.CsvBuilder _csvBuilder
    • Constructor Detail

      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.File aFile)
                 throws java.io.FileNotFoundException
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aFile - The File to be used for printing.
        Throws:
        java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.File aFile,
                        char aCsvDelimiter)
                 throws java.io.FileNotFoundException
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aFile - The File to be used for printing.
        aCsvDelimiter - The separator to be used when separating the CSV values in the log output.
        Throws:
        java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
      • IoLogger

        public IoLogger​(java.io.File aInputFile,
                        java.io.File aErrorFile)
                 throws java.io.FileNotFoundException
        Constructs a IoLogger.
        Parameters:
        aInputFile - The File to be used for printing output.
        aErrorFile - The File to be used for printing errors.
        Throws:
        java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.File aInputFile,
                        java.io.File aErrorFile)
                 throws java.io.FileNotFoundException
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aInputFile - The File to be used for printing output.
        aErrorFile - The File to be used for printing errors.
        Throws:
        java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
      • IoLogger

        public IoLogger​(java.io.File aFile)
                 throws java.io.FileNotFoundException
        Constructs a IoLogger.
        Parameters:
        aFile - The File to be used for writing to.
        Throws:
        java.io.FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.OutputStream aOutputStream)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aOutputStream - The OutputStream to be used for printing.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.OutputStream aOutputStream,
                        char aCsvDelimiter)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aOutputStream - The OutputStream to be used for printing.
        aCsvDelimiter - The separator to be used when separating the CSV values in the log output.
      • IoLogger

        public IoLogger​(java.io.OutputStream aOutputStream,
                        java.io.OutputStream aErrorStream)
        Constructs a IoLogger.
        Parameters:
        aOutputStream - The OutputStream to be used for printing output.
        aErrorStream - The OutputStream to be used for printing errors.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.OutputStream aOutputStream,
                        java.io.OutputStream aErrorStream)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aOutputStream - The OutputStream to be used for printing output.
        aErrorStream - The OutputStream to be used for printing errors.
      • IoLogger

        public IoLogger​(java.io.OutputStream aOutputStream)
        Constructs a IoLogger.
        Parameters:
        aOutputStream - The OutputStream to be used for printing.
      • IoLogger

        public IoLogger​(java.io.PrintStream aPrintStream)
        Constructs a IoLogger.
        Parameters:
        aPrintStream - The PrintStream to be used for printing.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.PrintStream aPrintStream)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aPrintStream - The PrintStream to be used for printing.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.PrintStream aPrintStream,
                        char aCsvDelimiter)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aPrintStream - The PrintStream to be used for printing.
        aCsvDelimiter - The separator to be used when separating the CSV values in the log output.
      • IoLogger

        public IoLogger​(java.io.PrintStream aOutputStream,
                        java.io.PrintStream aErrorStream)
        Constructs a IoLogger.
        Parameters:
        aOutputStream - The PrintStream to be used for printing output.
        aErrorStream - The PrintStream to be used for printing errors.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.PrintStream aOutputStream,
                        java.io.PrintStream aErrorStream)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aOutputStream - The PrintStream to be used for printing output.
        aErrorStream - The PrintStream to be used for printing errors.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        java.io.PrintStream aOutputStream,
                        java.io.PrintStream aErrorStream,
                        char aCsvDelimiter)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aOutputStream - The PrintStream to be used for printing output.
        aErrorStream - The PrintStream to be used for printing errors.
        aCsvDelimiter - The separator to be used when separating the CSV values in the log output.
      • IoLogger

        public IoLogger()
        Constructs a IoLogger.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
      • IoLogger

        public IoLogger​(org.refcodes.tabular.Header<T> aHeader,
                        char aCsvDelimiter)
        Constructs a IoLogger with the given header for logging.
        Parameters:
        aHeader - The header used for logging in the correct format.
        aCsvDelimiter - The separator to be used when separating the CSV values in the log output.
    • Method Detail

      • getCsvEscapeMode

        public org.refcodes.textual.CsvEscapeMode getCsvEscapeMode()
        Specified by:
        getCsvEscapeMode in interface org.refcodes.textual.CsvEscapeModeAccessor
      • isTrim

        public boolean isTrim()
        Specified by:
        isTrim in interface org.refcodes.mixin.TrimAccessor
      • getDelimiter

        public char getDelimiter()
        Specified by:
        getDelimiter in interface org.refcodes.mixin.DelimiterAccessor
      • setTrim

        public void setTrim​(boolean isTrim)
        Specified by:
        setTrim in interface org.refcodes.mixin.TrimAccessor.TrimMutator
      • setDelimiter

        public void setDelimiter​(char aDelimiter)
        Specified by:
        setDelimiter in interface org.refcodes.mixin.DelimiterAccessor.DelimiterMutator
      • withTrim

        public IoLogger<T> withTrim​(boolean isTrimRecords)
        Specified by:
        withTrim in interface org.refcodes.mixin.TrimAccessor.TrimBuilder<T>
      • withCsvEscapeMode

        public IoLogger<T> withCsvEscapeMode​(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
        Specified by:
        withCsvEscapeMode in interface org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<T>
      • withDelimiter

        public IoLogger<T> withDelimiter​(char aDelimiterChar)
        Specified by:
        withDelimiter in interface org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<T>
      • setCsvEscapeMode

        public void setCsvEscapeMode​(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
        Specified by:
        setCsvEscapeMode in interface org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator
      • log

        public void log​(org.refcodes.tabular.Record<? extends T> aRecord)
                 throws org.refcodes.logger.IllegalRecordRuntimeException,
                        org.refcodes.logger.UnexpectedLogRuntimeException
        Specified by:
        log in interface org.refcodes.logger.Logger<T>
        Throws:
        org.refcodes.logger.IllegalRecordRuntimeException
        org.refcodes.logger.UnexpectedLogRuntimeException
      • setErrorPrintStream

        public void setErrorPrintStream​(java.io.PrintStream aErrorStream)
        Specified by:
        setErrorPrintStream in interface org.refcodes.mixin.ErrorPrintStreamAccessor.ErrorPrintStreamMutator
      • setPrintStream

        public void setPrintStream​(java.io.PrintStream aOutputStream)
        Specified by:
        setPrintStream in interface org.refcodes.mixin.PrintStreamAccessor.PrintStreamMutator
      • getHeader

        protected org.refcodes.tabular.Header<T> getHeader()
        Returns the Header used by the IoLogger for usage by sub-classes.
        Returns:
        The Header used by the IoLogger.