Class TableReader

java.lang.Object
gov.nasa.pds.objectAccess.TableReader

public class TableReader
extends Object
The TableReader class defines methods for reading table records.
  • Field Details

  • Constructor Details

    • TableReader

      public TableReader​(Object table, File dataFile) throws Exception
      Throws:
      Exception
    • TableReader

      public TableReader​(Object table, URL dataFile) throws Exception
      Constructs a TableReader instance for reading records from a data file associated with a table object.
      Parameters:
      table - a table object
      dataFile - an input data file
      Throws:
      NullPointerException - if table offset is null
      Exception
    • TableReader

      public TableReader​(Object table, URL dataFile, boolean checkSize) throws Exception
      Throws:
      Exception
    • TableReader

      public TableReader​(Object table, URL dataFile, boolean checkSize, boolean readEntireFile) throws Exception
      Throws:
      Exception
    • TableReader

      public TableReader​(Object table, URL dataFile, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag) throws Exception
      Constructs a TableReader instance for reading records from a data file associated with a table object.
      Parameters:
      table - a table object
      dataFile - an input data file
      checkSize - check that the size of the data file is equal to the size of the table (length * records) + offset.
      readEntireFile - flag to read an entire file
      keepQuotationsFlag - flag to keep the starting/ending quotes
      Throws:
      NullPointerException - if table offset is null
      Exception
  • Method Details

    • getAdapter

      public TableAdapter getAdapter()
    • getFields

      public FieldDescription[] getFields()
      Gets the field descriptions for fields in the table.
      Returns:
      an array of field descriptions
    • getFieldMap

      public Map<String,​Integer> getFieldMap()
      Returns:
      the field map.
    • readNext

      public TableRecord readNext() throws IOException, com.opencsv.exceptions.CsvValidationException
      Reads the next record from the data file.
      Returns:
      the next record, or null if no further records.
      Throws:
      com.opencsv.exceptions.CsvValidationException
      IOException
    • getRecord

      public TableRecord getRecord​(int index) throws IllegalArgumentException, IOException, com.opencsv.exceptions.CsvValidationException
      Gets access to the table record given the index. The current row is set to this index, thus, subsequent call to readNext() gets the next record from this position.
      Parameters:
      index - the record index (1-relative)
      Returns:
      an instance of TableRecord
      Throws:
      IllegalArgumentException - if index is greater than the record number
      com.opencsv.exceptions.CsvValidationException
      IOException
    • getRecord

      public TableRecord getRecord​(int index, boolean keepQuotationsFlag) throws IllegalArgumentException, IOException, com.opencsv.exceptions.CsvValidationException
      Gets access to the table record given the index. The current row is set to this index, thus, subsequent call to readNext() gets the next record from this position.
      Parameters:
      index - the record index (1-relative)
      keepQuotationsFlag - flag to keep the starting/ending quotes or not.
      Returns:
      an instance of TableRecord
      Throws:
      IllegalArgumentException - if index is greater than the record number
      com.opencsv.exceptions.CsvValidationException
      IOException
    • setCurrentRow

      public void setCurrentRow​(int row)
      Sets the current row.
      Parameters:
      row - The row to set.
    • getCurrentRow

      public int getCurrentRow()
      Returns:
      the current row.
    • getAccessor

      public ByteWiseFileAccessor getAccessor()
    • getRecordSize

      public long getRecordSize​(URL dataFile, Object table) throws Exception
      Returns:
      the size of record (i.e. number of lines)
      Throws:
      Exception
    • getOffset

      public long getOffset()