Class CFileMgr

java.lang.Object
com.nt.udc.node.util.CFileMgr

public class CFileMgr extends Object
This class manages files stored in an input directory. It is used to return files to process.
Since:
JDK1.2.1
  • Field Details

    • m_debugLevel

      protected static int m_debugLevel
    • m_iLogger

      protected LoggerIfc m_iLogger
      This member is used to report errors and warnings
    • m_inputDir

      protected File m_inputDir
      This is the input directory
    • m_inputFileCache

      protected File[] m_inputFileCache
      This is the cache of input files. It is used to retrieve the files to process.
    • m_inputFileIndex

      protected int m_inputFileIndex
      This is the position of the next file to process in m_inputFileCache.
    • m_scratchDir

      protected File m_scratchDir
      This is the scratch directory. Work-files are stored here.
    • m_filenameFilter

      protected FilenameFilter m_filenameFilter
      This is the filter used to select files to process.
    • m_doneFilePrefix

      protected String m_doneFilePrefix
      This is the "done" marker-file prefix.
    • m_doneFileSuffix

      protected String m_doneFileSuffix
      This is the "done" marker-file suffix.
    • m_deleteProcessedFiles

      protected boolean m_deleteProcessedFiles
  • Constructor Details

    • CFileMgr

      public CFileMgr(LoggerIfc iLogger)
  • Method Details

    • getDebugLevel

      public static int getDebugLevel()
    • getInputDir

      public String getInputDir()
    • getScratchDir

      public String getScratchDir()
    • getFilenameFilter

      public FilenameFilter getFilenameFilter()
    • getDoneFilePrefix

      public String getDoneFilePrefix()
    • getDoneFileSuffix

      public String getDoneFileSuffix()
    • getDeleteProcessedFiles

      public boolean getDeleteProcessedFiles()
    • setDeleteProcessedFiles

      public void setDeleteProcessedFiles(boolean m_deleteProcessedFiles)
    • setDebugLevel

      public static void setDebugLevel(int debugLevel)
    • setInputDir

      public void setInputDir(String inputDirName)
    • setScratchDir

      public void setScratchDir(String scratchDirName)
    • setFilenameFilter

      public void setFilenameFilter(FilenameFilter filenameFilter)
    • setDoneFilePrefix

      public void setDoneFilePrefix(String doneFilePrefix)
    • setDoneFileSuffix

      public void setDoneFileSuffix(String doneFileSuffix)
    • hasMoreFilesToProcess

      public boolean hasMoreFilesToProcess()
      This function is used to check if more files are available for processing.

      We search the input file cache first. If no file is found, we try to update the cache and do the search again. If a file is found, it is guaranteed that the input file index remains positioned on a valid candidate.

      Returns:
      true if more files are available for processing, false otherwise.
    • getFileToProcess

      public CManagedFile getFileToProcess()
      This function is used to select a file to process.

      We search the input directory for files to be processed. The oldest successful candidate is returned. A cache of input files, sorted by last-modification time is used to avoid frequent disk-accesses.

      Returns:
      A valid managed file to process if successful, null if no file to process or not successful
    • finishedProcessing

      public boolean finishedProcessing(CManagedFile file)
      This function is called after a file has been processed.

      A marker file is created in the input directory.

      Returns:
      true if successul, false otherwise
    • selectFileForProcessing

      protected boolean selectFileForProcessing(File inputFile)
      This function is used to check whether an inputFile may be selected for processing.
      Returns:
      true if inputFile is to be selected, false otherwise
    • error

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

      protected void debug(String fName, String msg)