Package com.nt.udc.io
Class CDataSourceFileMgr
java.lang.Object
com.nt.udc.io.CDataSourceFileMgr
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprotected CManagedFile
This member represents the file currently being processed.protected static int
protected CFileMgr
This member is used to manage files to be processedprotected ILogger
This member is used for reporting errors and warnings.protected COSARReporter
This member is used to send reports to.Fields inherited from interface com.nt.udc.io.IDataSource
EOF
-
Constructor Summary
ConstructorsConstructorDescriptionCDataSourceFileMgr
(String inputDir, String scratchDir, FilenameFilter filter, ILogger iLogger) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
protected void
boolean
end()
Function called to end reading.protected void
static int
boolean
protected boolean
initFileMgr
(String inputDir, String scratchDir, FilenameFilter filter) This function initializes the file manager.boolean
This function is used to initialize the data source.boolean
char
nextChar()
Function called to read a character from the input mediumint
read
(char[] buf, int len) This function reads a given number of characters from the source.boolean
setBookmark
(int lineNo) Function used to mark a position in the input mediumstatic void
setDebugLevel
(int debugLevel) void
setDoneFilePrefix
(String prefix) void
setDoneFileSuffix
(String suffix) void
setReporter
(COSARReporter reporter) boolean
start()
Function called to start readingboolean
This function is used to terminate the data source.
-
Field Details
-
m_debugLevel
protected static int m_debugLevel -
m_iLogger
This member is used for reporting errors and warnings. -
m_fileMgr
This member is used to manage files to be processed -
m_crtFile
This member represents the file currently being processed. -
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 filesscratchDir
- - scratch directoryfilter
- - identifies files to returniLogger
- - object to handle errors and warnings- Throws:
Exception
-
-
Method Details
-
getDebugLevel
public static int getDebugLevel() -
COSARReporter
-
setDebugLevel
public static void setDebugLevel(int debugLevel) -
setReporter
-
setDoneFilePrefix
-
setDoneFileSuffix
-
getSourceName
- Specified by:
getSourceName
in interfaceIDataSource
- Returns:
- The current filename
-
hasMoreData
public boolean hasMoreData()- Specified by:
hasMoreData
in interfaceIDataSource
- Returns:
- true if there are more any files to process.
-
nextChar
Function called to read a character from the input mediumIf 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 interfaceIDataSource
- Returns:
- A valid character if successful, IDataSource.EOF if the end-of-file was reached or if unsuccessful
- Throws:
Exception
-
read
Description copied from interface:IDataSource
This function reads a given number of characters from the source.- Specified by:
read
in interfaceIDataSource
- 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 interfaceIDataSource
-
terminate
public boolean terminate()This function is used to terminate the data source.- Specified by:
terminate
in interfaceIDataSource
-
start
public boolean start()Function called to start reading- Specified by:
start
in interfaceIDataSource
- 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 interfaceIDataSource
- 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 interfaceIDataSource
- Returns:
- true if successful, false otherwise
-
cleanupCrtFile
public boolean cleanupCrtFile()- Returns:
- true if successful, false otherwise
-
isHealthy
public boolean isHealthy()- Specified by:
isHealthy
in interfaceIDataSource
- Returns:
- true if the data source is OK, false otherwise.
-
initFileMgr
This function initializes the file manager. To be overridden if necessary.- Returns:
- true if successful, false otherwise
-
checkDir
-
error
-
debug
-