java.lang.Object
com.aquima.interactions.framework.util.textdata.AbstractTextDataReader
com.aquima.interactions.framework.util.textdata.CsvReader

public class CsvReader extends AbstractTextDataReader
This class can be used to read a CSV (Comma Separated Values) resource.
Since:
6.3
Author:
Jon van Leuven
  • Field Details

    • DEFAULT_SEPARATOR

      public static final char DEFAULT_SEPARATOR
      The default separator to use if none is supplied to the constructor.
      See Also:
    • DEFAULT_QUOTE_CHARACTER

      public static final char DEFAULT_QUOTE_CHARACTER
      The default quote character to use if none is supplied to the constructor.
      See Also:
  • Constructor Details

    • CsvReader

      public CsvReader(IResource resource)
      Constructs csvReader using a comma for the separator.
      Parameters:
      resource - the resource to an underlying csv source.
      Throws:
      ResourceException - Occurs when problem reading the csv source.
    • CsvReader

      public CsvReader(IResource resource, char separator)
      Constructs csvReader with supplied separator.
      Parameters:
      resource - the resource to an underlying csv source.
      separator - the delimiter to use for separating entries.
      Throws:
      ResourceException - Occurs when problem reading the csv source.
    • CsvReader

      public CsvReader(IResource resource, char separator, char quotechar)
      Constructs csvReader with supplied separator and quote char.
      Parameters:
      resource - the resource to an underlying csv source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      Throws:
      ResourceException - Occurs when problem reading the csv source.
    • CsvReader

      public CsvReader(IResource resource, char separator, char quotechar, String charset)
      Constructs csvReader with supplied separator ,quote char and charset.
      Parameters:
      resource - the resource to an underlying csv source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      charset - the charset to use for decoding
      Throws:
      ResourceException - Occurs when problem reading the csv source.
    • CsvReader

      public CsvReader(IResource resource, char separator, char quotechar, int skipLines)
      Constructs csvReader with supplied separator and quote char.
      Parameters:
      resource - the resource to an underlying csv source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      skipLines - the line number to skip for start reading
      Throws:
      ResourceException - Occurs when problem reading the csv source.
    • CsvReader

      public CsvReader(IResource resource, char separator, char quotechar, int skipLines, String charset)
      Constructs csvReader with supplied separator ,quote char and charset.
      Parameters:
      resource - the resource to an underlying csv source.
      separator - the delimiter to use for separating entries
      quotechar - the character to use for quoted elements
      skipLines - the line number to skip for start reading
      charset - the charset to use for decoding
      Throws:
      ResourceException - Occurs when problem reading the csv source.
  • Method Details

    • parseLine

      protected String[] parseLine(String nextLine) throws IOException
      Parses an incoming String and returns an array of elements.
      Specified by:
      parseLine in class AbstractTextDataReader
      Parameters:
      nextLine - the string to parse
      Returns:
      the comma-tokenized list of elements, or null if nextLine is null
      Throws:
      IOException - if bad things happen during the read