com.ibm.commerce.foundation.dataload.datareader

Class CSVReader

  • All Implemented Interfaces:
    DataReader


    public class CSVReader
    extends AbstractDataReader

    This class CSVReader implements default behavior of the DataReader interface. This class reads in the data source information from the configuration, loads the csv file data.

    This class is invoked by initDataReaderConfig method in BusinessObjectLoader individual methods:

    1. init();
    2. read();
    3. 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 java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CSVReader

        public CSVReader()
    • Method Detail

      • 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 interface DataReader
        Specified by:
        next in class AbstractDataReader
        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 interface DataReader
        Overrides:
        getSourcePosition in class AbstractDataReader
        Returns:
        the record number in the CSV file for the data object.
      • getCurrentRecord

        public java.lang.String getCurrentRecord()
        Returns:
        Full record from latest invocation of next()