Package gov.nasa.pds.objectAccess
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 Summary
Fields Modifier and Type Field Description protected ByteWiseFileAccessoraccessor -
Constructor Summary
Constructors Constructor Description TableReader(Object table, File dataFile)TableReader(Object table, URL dataFile)Constructs aTableReaderinstance for reading records from a data file associated with a table object.TableReader(Object table, URL dataFile, boolean checkSize)TableReader(Object table, URL dataFile, boolean checkSize, boolean readEntireFile)TableReader(Object table, URL dataFile, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag)Constructs aTableReaderinstance for reading records from a data file associated with a table object. -
Method Summary
Modifier and Type Method Description ByteWiseFileAccessorgetAccessor()TableAdaptergetAdapter()intgetCurrentRow()Map<String,Integer>getFieldMap()FieldDescription[]getFields()Gets the field descriptions for fields in the table.longgetOffset()TableRecordgetRecord(int index)Gets access to the table record given the index.TableRecordgetRecord(int index, boolean keepQuotationsFlag)Gets access to the table record given the index.longgetRecordSize(URL dataFile, Object table)TableRecordreadNext()Reads the next record from the data file.voidsetCurrentRow(int row)Sets the current row.
-
Field Details
-
accessor
-
-
Constructor Details
-
TableReader
- Throws:
Exception
-
TableReader
Constructs aTableReaderinstance for reading records from a data file associated with a table object.- Parameters:
table- a table objectdataFile- an input data file- Throws:
NullPointerException- if table offset is nullException
-
TableReader
- 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 ExceptionConstructs aTableReaderinstance for reading records from a data file associated with a table object.- Parameters:
table- a table objectdataFile- an input data filecheckSize- 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 filekeepQuotationsFlag- flag to keep the starting/ending quotes- Throws:
NullPointerException- if table offset is nullException
-
-
Method Details
-
getAdapter
-
getFields
Gets the field descriptions for fields in the table.- Returns:
- an array of field descriptions
-
getFieldMap
- Returns:
- the field map.
-
readNext
Reads the next record from the data file.- Returns:
- the next record, or null if no further records.
- Throws:
com.opencsv.exceptions.CsvValidationExceptionIOException
-
getRecord
public TableRecord getRecord(int index) throws IllegalArgumentException, IOException, com.opencsv.exceptions.CsvValidationExceptionGets 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 numbercom.opencsv.exceptions.CsvValidationExceptionIOException
-
getRecord
public TableRecord getRecord(int index, boolean keepQuotationsFlag) throws IllegalArgumentException, IOException, com.opencsv.exceptions.CsvValidationExceptionGets 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 numbercom.opencsv.exceptions.CsvValidationExceptionIOException
-
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
-
getRecordSize
- Returns:
- the size of record (i.e. number of lines)
- Throws:
Exception
-
getOffset
public long getOffset()
-