Class CsvFile

java.lang.Object
net.sf.jailer.util.CsvFile

public class CsvFile extends Object
Parser for CSV-files.
Author:
Ralf Wisser
  • Field Details

    • BLOCK_INDICATOR

      public static String BLOCK_INDICATOR
      Indicates start of block inside a CSV file.
    • ALL_BLOCKS

      public static final String ALL_BLOCKS
      Special block-name for reading default block and cache all others.
      See Also:
  • Constructor Details

    • CsvFile

      public CsvFile(File csvFile) throws IOException
      Constructor.
      Parameters:
      csvFile - the csv file
      Throws:
      IOException
    • CsvFile

      public CsvFile(File csvFile, CsvFile.LineFilter filter) throws IOException
      Constructor.
      Parameters:
      csvFile - the csv file
      filter - optional line filter, or null to accept all lines
      Throws:
      IOException
    • CsvFile

      public CsvFile(File csvFile, String block) throws IOException
      Constructor.
      Parameters:
      csvFile - the csv file
      block - the block to read, null to read default block
      Throws:
      IOException
    • CsvFile

      public CsvFile(File csvFile, String block, CsvFile.LineFilter filter) throws IOException
      Constructor.
      Parameters:
      csvFile - the csv file
      block - the block to read, null to read default block
      filter - optional line filter, or null to accept all lines
      Throws:
      IOException
    • CsvFile

      public CsvFile(InputStream in, String block, String location, CsvFile.LineFilter filter) throws IOException
      Constructor.
      Parameters:
      in - the input stream to read from
      block - the block to read, null to read default block
      location - a description of the input source used in error messages
      filter - optional line filter, or null to accept all lines
      Throws:
      IOException
  • Method Details

    • decodeLine

      public static String[] decodeLine(String line)
      Decodes and splits a CSV line.
      Parameters:
      line - the line to decode
      Returns:
      decoded and split line as an array of cell values
    • encodeCell

      public static String encodeCell(String cell)
      Encodes a CSV cell.
      Parameters:
      cell - the cell to encode
      Returns:
      encoded cell
    • getLines

      public List<CsvFile.Line> getLines()
      Gets the list of lines.
      Returns:
      list of lists of cell-contents
    • getLines

      public List<CsvFile.Line> getLines(String block)
      Gets the list of lines of a cached block.
      Parameters:
      block - the block name, or null for the default block
      Returns:
      list of lines of the given block
      See Also:
    • contains

      public boolean contains(String[] line)
      Checks if a certain line can be found in this file.
      Parameters:
      line - the line
      Returns:
      true iff this file contains the line