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 SummaryFields Modifier and Type Field Description protected ByteWiseFileAccessoraccessor
- 
Constructor SummaryConstructors 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 SummaryModifier 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
 
- 
TableReaderConstructs aTableReaderinstance 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- Throws:
- Exception
 
- 
TableReaderpublic TableReader(Object table, URL dataFile, boolean checkSize, boolean readEntireFile) throws Exception- Throws:
- Exception
 
- 
TableReaderpublic 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 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
- 
getFieldsGets the field descriptions for fields in the table.- Returns:
- an array of field descriptions
 
- 
getFieldMap- Returns:
- the field map.
 
- 
readNextReads the next record from the data file.- Returns:
- the next record, or null if no further records.
- Throws:
- com.opencsv.exceptions.CsvValidationException
- IOException
 
- 
getRecordpublic 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 number
- com.opencsv.exceptions.CsvValidationException
- IOException
 
- 
getRecordpublic 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 number
- com.opencsv.exceptions.CsvValidationException
- IOException
 
- 
setCurrentRowpublic void setCurrentRow(int row)Sets the current row.- Parameters:
- row- The row to set.
 
- 
getCurrentRowpublic int getCurrentRow()- Returns:
- the current row.
 
- 
getAccessor
- 
getRecordSize- Returns:
- the size of record (i.e. number of lines)
- Throws:
- Exception
 
- 
getOffsetpublic long getOffset()
 
-