public final class Reader
extends java.lang.Object
implements java.io.Closeable
A .BIG file contains one or more worksheets of data, where a worksheet is essentially a row and column representation of data. An individual data value is found at the intersection of three zero-based indices: a worksheet index, a row index, and a column index.
Data in Exponam .BIG files are strongly typed on a per-column basis. Depending on how the .BIG file was generated, a column may contain empty values. Depending on how data values are accessed via Reader, an empty value will be represented as either null or Optional.empty().
Non-empty values are eligible to be returned to you in a variety of forms. If you request the String representation of a value, it will e returned to you respecting any display formats that were applied when the .BIG file was generated. If you request an alternate type, type conversion will be applied if required and the value returned. In the event that no conversion is available, an unchecked Exception will be thrown.
For example, if you request that a value for a Boolean column be returned as a Date, you will receive an IllegalArgumentException.
Note that Reader is Closeable. Failure to call close() can result in dangling references to underlying structures.
| Modifier and Type | Class and Description |
|---|---|
static class |
Reader.ColumnTypes
The types of columns that are supported in a .BIG file
|
| Constructor and Description |
|---|
Reader(java.io.File bigFile,
java.util.function.Supplier<java.lang.String> passwordSupplier)
Constructs an object that can read from an Exponam .BIG file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the Reader when through, allowing underlying resources to be properly released.
|
int |
getColumnCount(int worksheetIndex)
The number of columns contained in a worksheet.
|
java.lang.String |
getColumnName(int worksheetIndex,
int columnIndex)
The name of a given column in a worksheet.
|
Reader.ColumnTypes |
getColumnType(int worksheetIndex,
int columnIndex)
The type of data held in a given column in a worksheet.
|
int |
getRowCount(int worksheetIndex)
The number of rows contained in a worksheet.
|
void |
getRowValues(int worksheetIndex,
int startRow,
int endRow,
int[] columnIndexes,
java.lang.reflect.Type[] desiredClassForColumns,
java.util.function.BiConsumer<java.lang.Integer,java.lang.Object[]> rowConsumer)
This method is recommended for reading large numbers of row-wise data.
|
<T> T |
getValue(int worksheetIndex,
int rowIndex,
int columnIndex,
java.lang.reflect.Type desiredClass)
A data value held within a .BIG file, at the intersection of a worksheet index,
row index, and column index, returned as an instance of desiredClass.
|
int |
getWorksheetCount()
The number of worksheets contained in the file.
|
java.lang.String |
getWorksheetName(int worksheetIndex)
The name given for a specific worksheet.
|
public Reader(java.io.File bigFile,
java.util.function.Supplier<java.lang.String> passwordSupplier)
throws java.io.IOException,
com.exponam.core.reader.BigReader.UnsupportedFileVersionException
bigFile - the Exponam .BIG file to be accessedpasswordSupplier - a caller-supplier function returning the password for the BigFile; can be null or return an empty String for unencrypted filesjava.io.IOException - if there is a problem accessing the fileBigReader.UnsupportedFileVersionException - if the file version is more recent than supported by this version of the APIpublic int getWorksheetCount()
public java.lang.String getWorksheetName(int worksheetIndex)
worksheetIndex - the zero-based worksheet indexpublic int getRowCount(int worksheetIndex)
worksheetIndex - the zero-based worksheet indexpublic int getColumnCount(int worksheetIndex)
worksheetIndex - the zero-based worksheet indexpublic java.lang.String getColumnName(int worksheetIndex,
int columnIndex)
worksheetIndex - the zero-based worksheet indexcolumnIndex - the zero-based column indexpublic Reader.ColumnTypes getColumnType(int worksheetIndex, int columnIndex)
worksheetIndex - the zero-based worksheet indexcolumnIndex - the zero-based column indexpublic <T> T getValue(int worksheetIndex,
int rowIndex,
int columnIndex,
java.lang.reflect.Type desiredClass)
The supported data type conversions are:
T - the type to be returned, must match the desiredClassworksheetIndex - the zero-based worksheet indexrowIndex - the zero-based row indexcolumnIndex - the zero-based column indexdesiredClass - the desired type for the valuepublic void getRowValues(int worksheetIndex,
int startRow,
int endRow,
int[] columnIndexes,
java.lang.reflect.Type[] desiredClassForColumns,
java.util.function.BiConsumer<java.lang.Integer,java.lang.Object[]> rowConsumer)
worksheetIndex - the zero-based worksheet indexstartRow - the zero-based index for the first row in the range of rows to be retrievedendRow - the zero-based index for the last row in the range of rows to be retrievedcolumnIndexes - array of the zero-based column indexes for the columns to be retrieveddesiredClassForColumns - array of the desired type for for each of the columns to be retrievedrowConsumer - the callback invoked for each row that is retrievedpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - exception