Package gov.nasa.pds.objectAccess
Class TableReader
- java.lang.Object
- 
- gov.nasa.pds.objectAccess.TableReader
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable
 - Direct Known Subclasses:
- RawTableReader
 
 public class TableReader extends java.lang.Object implements java.io.CloseableTheTableReaderclass defines methods for reading table records.
- 
- 
Field SummaryFields Modifier and Type Field Description protected ByteWiseFileAccessoraccessorprotected DataObjectLocationdataObjectLocation
 - 
Constructor SummaryConstructors Constructor Description TableReader(java.lang.Object table, java.io.File dataFile)TableReader(java.lang.Object table, java.net.URL dataFile)Constructs aTableReaderinstance for reading records from a data file associated with a table object.TableReader(java.lang.Object table, java.net.URL dataFile, boolean checkSize)TableReader(java.lang.Object table, java.net.URL dataFile, boolean checkSize, boolean readEntireFile)TableReader(java.lang.Object table, java.net.URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag)TableReader(java.lang.Object table, java.net.URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag, java.io.RandomAccessFile raf, java.io.InputStream inputStream)Constructs aTableReaderinstance for reading records from a data file associated with a table object.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ByteWiseFileAccessorgetAccessor()TableAdaptergetAdapter()longgetCurrentRow()DataObjectLocationgetDataObjectLocation()java.util.Map<java.lang.String,java.lang.Integer>getFieldMap()FieldDescription[]getFields()Gets the field descriptions for fields in the table.java.io.InputStreamgetInputStream()longgetOffset()TableRecordgetRecord(int index)Gets access to the table record given the index.TableRecordgetRecord(long index, boolean keepQuotationsFlag)Gets access to the table record given the index.longgetRecordSize(java.net.URL dataFile, java.lang.Object table)TableRecordreadNext()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 Detail- 
accessorprotected ByteWiseFileAccessor accessor 
 - 
dataObjectLocationprotected DataObjectLocation dataObjectLocation 
 
- 
 - 
Constructor Detail- 
TableReaderpublic TableReader(java.lang.Object table, java.io.File dataFile) throws java.lang.Exception- Throws:
- java.lang.Exception
 
 - 
TableReaderpublic TableReader(java.lang.Object table, java.net.URL dataFile) throws java.lang.ExceptionConstructs aTableReaderinstance for reading records from a data file associated with a table object.- Parameters:
- table- a table object
- dataFile- an input data file
- Throws:
- java.lang.NullPointerException- if table offset is null
- java.lang.Exception
 
 - 
TableReaderpublic TableReader(java.lang.Object table, java.net.URL dataFile, boolean checkSize) throws InvalidTableException, java.lang.Exception- Throws:
- InvalidTableException
- java.lang.Exception
 
 - 
TableReaderpublic TableReader(java.lang.Object table, java.net.URL dataFile, boolean checkSize, boolean readEntireFile) throws InvalidTableException, java.lang.Exception- Throws:
- InvalidTableException
- java.lang.Exception
 
 - 
TableReaderpublic TableReader(java.lang.Object table, java.net.URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag) throws InvalidTableException, java.lang.Exception- Throws:
- InvalidTableException
- java.lang.Exception
 
 - 
TableReaderpublic TableReader(java.lang.Object table, java.net.URL dataFile, DataObjectLocation location, boolean checkSize, boolean readEntireFile, boolean keepQuotationsFlag, java.io.RandomAccessFile raf, java.io.InputStream inputStream) throws InvalidTableException, java.lang.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:
- java.lang.NullPointerException- if table offset is null
- InvalidTableException
- java.lang.Exception
 
 
- 
 - 
Method Detail- 
getAdapterpublic TableAdapter getAdapter() 
 - 
getFieldspublic FieldDescription[] getFields() Gets the field descriptions for fields in the table.- Returns:
- an array of field descriptions
 
 - 
getFieldMappublic java.util.Map<java.lang.String,java.lang.Integer> getFieldMap() - Returns:
- the field map.
 
 - 
readNextpublic TableRecord readNext() throws java.io.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
- java.io.IOException
 
 - 
getRecordpublic TableRecord getRecord(int index) throws java.lang.IllegalArgumentException, java.io.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:
- java.lang.IllegalArgumentException- if index is greater than the record number
- com.opencsv.exceptions.CsvValidationException
- java.io.IOException
 
 - 
getRecordpublic TableRecord getRecord(long index, boolean keepQuotationsFlag) throws java.lang.IllegalArgumentException, java.io.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:
- java.lang.IllegalArgumentException- if index is greater than the record number
- com.opencsv.exceptions.CsvValidationException
- java.io.IOException
 
 - 
setCurrentRowpublic void setCurrentRow(int row) Sets the current row.- Parameters:
- row- The row to set.
 
 - 
setCurrentRowpublic void setCurrentRow(long row) Sets the current row.- Parameters:
- row- The row to set.
 
 - 
getCurrentRowpublic long getCurrentRow() - Returns:
- the current row.
 
 - 
getAccessorpublic ByteWiseFileAccessor getAccessor() 
 - 
getInputStreampublic java.io.InputStream getInputStream() 
 - 
getRecordSizepublic long getRecordSize(java.net.URL dataFile, java.lang.Object table) throws java.lang.Exception- Returns:
- the size of record (i.e. number of lines)
- Throws:
- java.lang.Exception
 
 - 
getOffsetpublic long getOffset() 
 - 
closepublic void close() throws java.io.IOException- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Throws:
- java.io.IOException
 
 - 
getDataObjectLocationpublic DataObjectLocation getDataObjectLocation() 
 - 
setDataObjectLocationpublic void setDataObjectLocation(DataObjectLocation dataObjectLocation) 
 
- 
 
-