Class CSVParser

  • All Implemented Interfaces:
    ParserInterface, VersionInfoInterface

    public class CSVParser
    extends ParserImpl
    A class reading and writing Entries in a simple one-line-per-Entry format. CSV is short for comma-separated values, and this format is popular for storing tabular data in text form. The separator does not need to be a comma, it can be any single character.
    See Also:
    Connector
    • Constructor Detail

      • CSVParser

        public CSVParser()
        Default constructor;
      • CSVParser

        public CSVParser​(java.io.Reader in,
                         java.io.Writer out)
        Class constructor
        Parameters:
        in - : Input stream to read from;
        out - : Output stream to write to;
    • Method Detail

      • initParser

        public void initParser()
        This method is called by the hosting component (e.g. connector) to initialize the parser.
        Specified by:
        initParser in interface ParserInterface
        Overrides:
        initParser in class ParserImpl
      • readEntry

        public Entry readEntry()
                        throws java.io.IOException
        Return the next entry from the current input stream.
        Returns:
        The next entry from the input stream
        Throws:
        java.io.IOException - if error during reading next Entry occurs.
      • nextEntry

        public java.util.ArrayList<java.lang.String> nextEntry()
                                                        throws java.io.IOException
        The method retrieves the values for the next Entry
        Returns:
        List holding the values for the Entry
        Throws:
        java.io.IOException
      • writeEntry

        public void writeEntry​(Entry entry)
                        throws java.lang.Exception
        Write an Entry to the current output stream.
        Parameters:
        entry - The entry to write
        Throws:
        java.lang.Exception
      • quote

        public java.lang.String quote​(java.lang.String src)
        Quotes the provided expression.
        Parameters:
        src - source String
        Returns:
        the quoted expression
      • setHeadersWritten

        public void setHeadersWritten​(boolean value)
        Sets if header should be written
        Parameters:
        value - If false, the headers need to be written. If true, the headers are already written, and should not be written again.
      • getVersion

        public java.lang.String getVersion()
        Version information.
        Returns:
        version information.
      • querySchema

        public java.lang.Object querySchema​(java.lang.Object schema)
        Discover the schema for the Parser. For example, a XML Parser could return a representation of the XML Schema or the DTD referenced in a XML file.
        Specified by:
        querySchema in interface ParserInterface
        Overrides:
        querySchema in class ParserImpl
        Parameters:
        schema - The object on which to discover schema
        Returns:
        A Vector of com.ibm.di.entry.Entry objects describing each entity
      • getLine

        public java.lang.String getLine()
        Returns the last line that was read or written. If nothing has been read or written yet, returns null.
        Returns:
        the last line that was read or written
        Since:
        7.2