Class CManagedFile

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

public class CManagedFile extends Object
This class is used to manage files with bookmarks.

Every file has an associated bookmark file residing in the same directory. Classes using CManagedFile have control over the placement of bookmarks with respect to the content of the managed file.

  • Field Details

    • m_debugLevel

      protected static int m_debugLevel
    • m_scratchDir

      protected File m_scratchDir
      This member is used for storing the scratch directory, where bookmark files are kept.
    • m_iLogger

      protected LoggerIfc m_iLogger
      This member is used for reporting errors and warnings.
    • m_file

      protected File m_file
      This member represents the file to be managed
    • m_bookmarkFile

      protected File m_bookmarkFile
      This member represents the bookmark-file associated to the managed file.
    • m_inputStream

      protected FileInputStream m_inputStream
      This member represents the input stream opened on the managed file.
    • m_reader

      protected BufferedReader m_reader
      This member represents the buffered reader to read characters from.
    • m_bookmarkStream

      protected RandomAccessFile m_bookmarkStream
      This member represents the input/output stream opened on the bookmark file.
  • Constructor Details

    • CManagedFile

      public CManagedFile(File file, File scratchDir, LoggerIfc iLogger) throws Exception
      This constructor opens the specified file, checks if there is an associated bookmark (checkpoint) file and if there is one, retrieves the position to start reading from.
      Throws:
      Exception
  • Method Details

    • getDebugLevel

      public static int getDebugLevel()
    • getFile

      public File getFile()
    • getFilename

      public String getFilename()
      Returns:
      The name of the current file
    • read

      public char read() throws Exception
      Returns:
      A character read from the stream If EOF is reached, the file is closed, as well as the associated bookmark, if there is one.
      Throws:
      Exception
    • readLine

      public String readLine() throws Exception
      Throws:
      Exception
    • read

      public int read(char[] buf, int len) throws Exception
      Throws:
      Exception
    • setBookmark

      public boolean setBookmark(int lineNo)
      This function is called to set a bookmark in the bookmark-file associated to the managed file. If the bookmark-file doesn't exist, then it's created. The bookmarks consists of the current position in the input stream opened on the managed file.
    • setDebugLevel

      public static void setDebugLevel(int debugLevel)
    • error

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

      protected void debug(String fName, String msg)