com.ibm.commerce.foundation.dataload.datareader
Class CSVReader
- java.lang.Object
-
- com.ibm.commerce.foundation.dataload.datareader.AbstractDataReader
-
- com.ibm.commerce.foundation.dataload.datareader.CSVReader
-
- All Implemented Interfaces:
- DataReader
public class CSVReader extends AbstractDataReader
This class
CSVReader
implements default behavior of theDataReader
interface. This class reads in the data source information from the configuration, loads the csv file data.This class is invoked by
initDataReaderConfig
method inBusinessObjectLoader
individual methods:-
init();
-
read();
-
close();
Before you call
read()
, you can call other methods to get and set additional properties if these properties are not defined in the configuration file or you want to override the value in the configuration file. To get and set configuration properties, you can call:-
getConfigProperties().getPropertyMap();
-
setConfigProperties().getPropertyMap();
-
-
Constructor Summary
Constructors Constructor and Description CSVReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
close()
Close the data source used for reading data.java.lang.String
getCurrentRecord()
java.io.File
getDataFile()
This method gets the CSV File name and then creates a File object for that particular CSV input file.java.lang.Integer
getSourcePosition()
It returns the record number in the CSV file when the last next() method is called.void
init()
It gets the input csv data file for a DataReader and gets limeDelimiter, tokenDelimeter and tokenValueDelimiter values.java.lang.Object
next()
Reads a "record" from an open file handle, tokenizes the record and returns a map of tokenized data from the record.-
Methods inherited from class com.ibm.commerce.foundation.dataload.datareader.AbstractDataReader
getConfigProperties, initConfig, setConfigProperties
-
-
-
-
Method Detail
-
init
public void init() throws DataLoadException
It gets the input csv data file for a DataReader and gets limeDelimiter, tokenDelimeter and tokenValueDelimiter values.- Specified by:
init
in interfaceDataReader
- Overrides:
init
in classAbstractDataReader
- Throws:
DataLoadException
-
getDataFile
public java.io.File getDataFile() throws DataLoadException
This method gets the CSV File name and then creates a File object for that particular CSV input file.- Returns:
- File
- Throws:
DataLoadException
-
next
public java.lang.Object next() throws DataLoadException
Reads a "record" from an open file handle, tokenizes the record and returns a map of tokenized data from the record.- Specified by:
next
in interfaceDataReader
- Specified by:
next
in classAbstractDataReader
- Returns:
- data in tokenMap, and some other meta-data
- Throws:
DataLoadException
-
getSourcePosition
public java.lang.Integer getSourcePosition()
It returns the record number in the CSV file when the last next() method is called.- Specified by:
getSourcePosition
in interfaceDataReader
- Overrides:
getSourcePosition
in classAbstractDataReader
- Returns:
- the record number in the CSV file for the data object.
-
close
public void close() throws DataLoadException
Close the data source used for reading data.
- Specified by:
close
in interfaceDataReader
- Overrides:
close
in classAbstractDataReader
- Throws:
DataLoadException
- An application exception will be thrown if there was a problem closing the data source.
-
getCurrentRecord
public java.lang.String getCurrentRecord()
- Returns:
- Full record from latest invocation of next()
-
-