Package com.nt.udc.io

Class CDataSourceFileMgr

java.lang.Object
com.nt.udc.io.CDataSourceFileMgr
All Implemented Interfaces:
IDataSource

public class CDataSourceFileMgr extends Object implements IDataSource
This class is used for retrieving data from files specified by a filter, that reside in an input directory.
Since:
JDK1.1.7
  • Field Details

    • m_debugLevel

      protected static int m_debugLevel
    • m_iLogger

      protected ILogger m_iLogger
      This member is used for reporting errors and warnings.
    • m_fileMgr

      protected CFileMgr m_fileMgr
      This member is used to manage files to be processed
    • m_crtFile

      protected CManagedFile m_crtFile
      This member represents the file currently being processed.
    • m_reporter

      protected COSARReporter m_reporter
      This member is used to send reports to.
  • Constructor Details

    • CDataSourceFileMgr

      public CDataSourceFileMgr(String inputDir, String scratchDir, FilenameFilter filter, ILogger iLogger) throws Exception
      Parameters:
      inputDir - - directory to monitor for input files
      scratchDir - - scratch directory
      filter - - identifies files to return
      iLogger - - object to handle errors and warnings
      Throws:
      Exception
  • Method Details

    • getDebugLevel

      public static int getDebugLevel()
    • COSARReporter

      public COSARReporter COSARReporter()
    • setDebugLevel

      public static void setDebugLevel(int debugLevel)
    • setReporter

      public void setReporter(COSARReporter reporter)
    • setDoneFilePrefix

      public void setDoneFilePrefix(String prefix)
    • setDoneFileSuffix

      public void setDoneFileSuffix(String suffix)
    • getSourceName

      public String getSourceName()
      Specified by:
      getSourceName in interface IDataSource
      Returns:
      The current filename
    • hasMoreData

      public boolean hasMoreData()
      Specified by:
      hasMoreData in interface IDataSource
      Returns:
      true if there are more any files to process.
    • nextChar

      public char nextChar() throws Exception
      Function called to read a character from the input medium

      If there is a current file to process, the character is retrieved from this file, otherwise the next file is selected for processing.

      Specified by:
      nextChar in interface IDataSource
      Returns:
      A valid character if successful, IDataSource.EOF if the end-of-file was reached or if unsuccessful
      Throws:
      Exception
    • read

      public int read(char[] buf, int len) throws Exception
      Description copied from interface: IDataSource
      This function reads a given number of characters from the source.
      Specified by:
      read in interface IDataSource
      Returns:
      The number of characters actually read.
      Throws:
      Exception
    • initialize

      public boolean initialize()
      This function is used to initialize the data source.
      Specified by:
      initialize in interface IDataSource
    • terminate

      public boolean terminate()
      This function is used to terminate the data source.
      Specified by:
      terminate in interface IDataSource
    • start

      public boolean start()
      Function called to start reading
      Specified by:
      start in interface IDataSource
      Returns:
      true if successful, false otherwise
    • end

      public boolean end()
      Function called to end reading. cleanupCrtFile (which generates the "done"-file) is called only if the current file has been processed completely.
      Specified by:
      end in interface IDataSource
      Returns:
      true if successful, false otherwise
    • setBookmark

      public boolean setBookmark(int lineNo)
      Function used to mark a position in the input medium
      Specified by:
      setBookmark in interface IDataSource
      Returns:
      true if successful, false otherwise
    • cleanupCrtFile

      public boolean cleanupCrtFile()
      Returns:
      true if successful, false otherwise
    • isHealthy

      public boolean isHealthy()
      Specified by:
      isHealthy in interface IDataSource
      Returns:
      true if the data source is OK, false otherwise.
    • initFileMgr

      protected boolean initFileMgr(String inputDir, String scratchDir, FilenameFilter filter)
      This function initializes the file manager. To be overridden if necessary.
      Returns:
      true if successful, false otherwise
    • checkDir

      protected boolean checkDir(String dir)
    • error

      protected void error(String fName, String msg)
    • debug

      protected void debug(String fName, String msg)