Package gov.nasa.pds.objectAccess
Class TableReader
java.lang.Object
gov.nasa.pds.objectAccess.TableReader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
RawTableReader
The
TableReader class defines methods for reading table records.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTableReader(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, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag) TableReader(Object table, URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag, RandomAccessFile raf, InputStream inputStream) Constructs aTableReaderinstance for reading records from a data file associated with a table object. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longGets the field descriptions for fields in the table.longgetRecord(int index) Gets access to the table record given the index.getRecord(long index, boolean keepQuotationsFlag) Gets access to the table record given the index.longgetRecordSize(URL dataFile, Object table) readNext()Reads the next record from the data file.voidsetCurrentRow(int row) Sets the current row.voidsetCurrentRow(long row) Sets the current row.voidsetDataObjectLocation(DataObjectLocation dataObjectLocation)
-
Field Details
-
accessor
-
dataObjectLocation
-
-
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
public TableReader(Object table, URL dataFile, boolean checkSize) throws InvalidTableException, Exception - Throws:
InvalidTableExceptionException
-
TableReader
public TableReader(Object table, URL dataFile, boolean checkSize, boolean readEntireFile) throws InvalidTableException, Exception - Throws:
InvalidTableExceptionException
-
TableReader
public TableReader(Object table, URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag) throws InvalidTableException, Exception - Throws:
InvalidTableExceptionException
-
TableReader
public TableReader(Object table, URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag, RandomAccessFile raf, InputStream inputStream) throws InvalidTableException, Exception Constructs 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 nullInvalidTableExceptionException
-
-
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.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 numbercom.opencsv.exceptions.CsvValidationExceptionIOException
-
getRecord
public TableRecord getRecord(long 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 numbercom.opencsv.exceptions.CsvValidationExceptionIOException
-
setCurrentRow
public void setCurrentRow(int row) Sets the current row.- Parameters:
row- The row to set.
-
setCurrentRow
public void setCurrentRow(long row) Sets the current row.- Parameters:
row- The row to set.
-
getCurrentRow
public long getCurrentRow()- Returns:
- the current row.
-
getAccessor
-
getInputStream
-
getRecordSize
- Returns:
- the size of record (i.e. number of lines)
- Throws:
Exception
-
getOffset
public long getOffset() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getDataObjectLocation
-
setDataObjectLocation
-