Class LogReadFileHandler

  • All Implemented Interfaces:
    LogReadHandler

    public class LogReadFileHandler
    extends Object
    implements LogReadHandler
    LogReadFileHandler class implements LogReadHandler interface. This class name will be stored as a configuration parameter. LogReader will instantiate it at run time (when messages are logged into file). This class reads the disk file, applies query if any, sorts records on field name when required, collects most recent records (default option) or all records. It returns result 2D String to the caller (LogReader), it also exports a method that returns archived filename present in current set.
    • Constructor Detail

      • LogReadFileHandler

        public LogReadFileHandler()
        constructor does nothing
    • Method Detail

      • logRecRead

        public String[][] logRecRead​(String fileName,
                                     LogQuery logQuery,
                                     boolean sourceData)
                              throws IOException,
                                     NoSuchFieldException,
                                     IllegalArgumentException,
                                     RuntimeException,
                                     Exception
        LogReader calls this method method. It collects header, records, applies query (if any), sorts (if asked) the records on field, checks the max records to return, collects all the recods and returns.
        Specified by:
        logRecRead in interface LogReadHandler
        Parameters:
        fileName - is complete filename with path
        logQuery - is user specified qury chriteria with sorting requirement
        sourceData - it specifies whether return data should be original data received by logger (source) or formatted data as in file.
        Returns:
        all the matched records with query
        Throws:
        IOException - if it fails to read log records.
        NoSuchFieldException - if it fails to retrieve the name of field.
        IllegalArgumentException - if query has wrong value.
        RuntimeException - if it fails to retrieve log record.
        Exception - if it fails any of operation.
      • logRecRead

        public String[][] logRecRead​(Set fileNames,
                                     LogQuery logQuery,
                                     boolean sourceData)
                              throws IOException,
                                     NoSuchFieldException,
                                     IllegalArgumentException,
                                     RuntimeException,
                                     Exception
        LogReader calls this method method. It collects header, records, applies query (if any), sorts (if asked) the records on field, checks the max records to return, collects all the recods and returns.
        Specified by:
        logRecRead in interface LogReadHandler
        Parameters:
        fileNames - is a Set of filenames complete with path
        logQuery - is user specified qury chriteria with sorting requirement
        sourceData - it specifies whether return data should be original data received by logger (source) or formatted data as in file.
        Returns:
        all the matched records with query
        Throws:
        IOException - if it fails to read log records.
        NoSuchFieldException - if it fails to retrieve the name of field.
        IllegalArgumentException - if query has wrong value.
        RuntimeException - if it fails to retrieve log record.
        Exception - if it fails any of operation.