Package com.nt.udc.node.util
Class CManagedFile
java.lang.Object
com.nt.udc.node.util.CManagedFile
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 Summary
FieldsModifier and TypeFieldDescriptionprotected File
This member represents the bookmark-file associated to the managed file.protected RandomAccessFile
This member represents the input/output stream opened on the bookmark file.protected static int
protected File
This member represents the file to be managedprotected LoggerIfc
This member is used for reporting errors and warnings.protected FileInputStream
This member represents the input stream opened on the managed file.protected BufferedReader
This member represents the buffered reader to read characters from.protected File
This member is used for storing the scratch directory, where bookmark files are kept. -
Constructor Summary
ConstructorsConstructorDescriptionCManagedFile
(File file, File scratchDir, LoggerIfc iLogger) 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. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
static int
getFile()
char
read()
int
read
(char[] buf, int len) readLine()
boolean
setBookmark
(int lineNo) This function is called to set a bookmark in the bookmark-file associated to the managed file.static void
setDebugLevel
(int debugLevel)
-
Field Details
-
m_debugLevel
protected static int m_debugLevel -
m_scratchDir
This member is used for storing the scratch directory, where bookmark files are kept. -
m_iLogger
This member is used for reporting errors and warnings. -
m_file
This member represents the file to be managed -
m_bookmarkFile
This member represents the bookmark-file associated to the managed file. -
m_inputStream
This member represents the input stream opened on the managed file. -
m_reader
This member represents the buffered reader to read characters from. -
m_bookmarkStream
This member represents the input/output stream opened on the bookmark file.
-
-
Constructor Details
-
CManagedFile
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
-
getFilename
- Returns:
- The name of the current file
-
read
- 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
- Throws:
Exception
-
read
- 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
-
debug
-