Package adams.data.io.input
Class AccessSpreadSheetReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractSpreadSheetReader
-
- adams.data.io.input.AccessSpreadSheetReader
-
- All Implemented Interfaces:
AdditionalInformationHandler,Destroyable,ErrorProvider,GlobalInfoSupporter,EncodingSupporter,FileFormatHandler,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Stoppable,StoppableWithFeedback,ChunkedSpreadSheetReader,SpreadSheetReader,WindowedSpreadSheetReader,DataRowTypeHandler,SpreadSheetTypeHandler,Serializable
public class AccessSpreadSheetReader extends AbstractSpreadSheetReader implements ChunkedSpreadSheetReader, WindowedSpreadSheetReader
Allows the reading of MS Access databases.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-data-row-type <adams.data.spreadsheet.DataRow> (property: dataRowType) The type of row to use for the data. default: adams.data.spreadsheet.DenseDataRow
-spreadsheet-type <adams.data.spreadsheet.SpreadSheet> (property: spreadSheetType) The type of spreadsheet to use for the data. default: adams.data.spreadsheet.SpreadSheet
-missing <java.lang.String> (property: missingValue) The placeholder for missing values. default: ?
-table <java.lang.String> (property: table) The table to read from the database. default: MyTable
-first-row <int> (property: firstRow) The index of the first row to retrieve (1-based). default: 1 minimum: 1
-num-rows <int> (property: numRows) The number of data rows to retrieve; use -1 for unlimited. default: -1 minimum: -1
-chunk-size <int> (property: chunkSize) The maximum number of rows per chunk; using -1 will read put all data into a single spreadsheet object. default: -1 minimum: -1
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAccessSpreadSheetReader.ChunkReaderReads data from the table in chunks.-
Nested classes/interfaces inherited from class adams.data.io.input.AbstractSpreadSheetReader
AbstractSpreadSheetReader.InputType
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_ChunkSizethe chunk size to use.protected intm_FirstRowthe first row to retrieve (1-based).protected intm_NumRowsthe number of rows to retrieve (less than 1 = unlimited).protected AccessSpreadSheetReader.ChunkReaderm_Readerthe reader.protected Stringm_Tablethe table to read.-
Fields inherited from class adams.data.io.input.AbstractSpreadSheetReader
m_DataRowType, m_Encoding, m_LastError, m_SpreadSheetType, m_Stopped, OPTION_INPUT, OPTION_OUTPUT
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AccessSpreadSheetReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringchunkSizeTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected SpreadSheetdoRead(File file)Performs the actual reading.StringfirstRowTipText()Returns the tip text for this property.intgetChunkSize()Returns the current chunk size.SpreadSheetWritergetCorrespondingWriter()Returns, if available, the corresponding writer.intgetFirstRow()Returns the first row to return.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.protected AbstractSpreadSheetReader.InputTypegetInputType()Returns how to read the data, from a file, stream or reader.intgetNumRows()Returns the number of data rows to return.StringgetTable()Returns the table to read from.StringglobalInfo()Returns a string describing the object.booleanhasMoreChunks()Checks whether there is more data to read.static voidmain(String[] args)Runs the reader from the command-line.SpreadSheetnextChunk()Returns the next chunk.StringnumRowsTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetChunkSize(int value)Sets the maximum chunk size.voidsetFirstRow(int value)Sets the first row to return.voidsetNumRows(int value)Sets the number of data rows to return.voidsetTable(String value)Sets the table to read from.StringtableTipText()Returns the tip text for this property.-
Methods inherited from class adams.data.io.input.AbstractSpreadSheetReader
canDecompress, check, dataRowTypeTipText, doRead, doRead, encodingTipText, getAdditionalInformation, getDataRowType, getDefaultDataRowType, getDefaultFormatExtension, getDefaultSpreadSheet, getEncoding, getLastError, getReaders, getSpreadSheetType, hasLastError, initialize, isStopped, read, read, read, read, runReader, setDataRowType, setEncoding, setLastError, setSpreadSheetType, spreadSheetTypeTipText, stopExecution, supportsCompressedInput
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
Methods inherited from interface adams.data.io.input.SpreadSheetReader
dataRowTypeTipText, getDataRowType, getDefaultFormatExtension, getLastError, getSpreadSheetType, hasLastError, isStopped, read, read, read, read, setDataRowType, setSpreadSheetType, spreadSheetTypeTipText, stopExecution
-
-
-
-
Field Detail
-
m_Table
protected String m_Table
the table to read.
-
m_FirstRow
protected int m_FirstRow
the first row to retrieve (1-based).
-
m_NumRows
protected int m_NumRows
the number of rows to retrieve (less than 1 = unlimited).
-
m_ChunkSize
protected int m_ChunkSize
the chunk size to use.
-
m_Reader
protected AccessSpreadSheetReader.ChunkReader m_Reader
the reader.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractSpreadSheetReader
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classAbstractOptionHandler
-
setTable
public void setTable(String value)
Sets the table to read from.- Parameters:
value- the table
-
getTable
public String getTable()
Returns the table to read from.- Returns:
- the table
-
tableTipText
public String tableTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFirstRow
public void setFirstRow(int value)
Sets the first row to return.- Specified by:
setFirstRowin interfaceWindowedSpreadSheetReader- Parameters:
value- the first row (1-based), greater than 0
-
getFirstRow
public int getFirstRow()
Returns the first row to return.- Specified by:
getFirstRowin interfaceWindowedSpreadSheetReader- Returns:
- the first row (1-based), greater than 0
-
firstRowTipText
public String firstRowTipText()
Returns the tip text for this property.- Specified by:
firstRowTipTextin interfaceWindowedSpreadSheetReader- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumRows
public void setNumRows(int value)
Sets the number of data rows to return.- Specified by:
setNumRowsin interfaceWindowedSpreadSheetReader- Parameters:
value- the number of rows, -1 for unlimited
-
getNumRows
public int getNumRows()
Returns the number of data rows to return.- Specified by:
getNumRowsin interfaceWindowedSpreadSheetReader- Returns:
- the number of rows, -1 for unlimited
-
numRowsTipText
public String numRowsTipText()
Returns the tip text for this property.- Specified by:
numRowsTipTextin interfaceWindowedSpreadSheetReader- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setChunkSize
public void setChunkSize(int value)
Sets the maximum chunk size.- Specified by:
setChunkSizein interfaceChunkedSpreadSheetReader- Parameters:
value- the size of the chunks, < 1 denotes infinity
-
getChunkSize
public int getChunkSize()
Returns the current chunk size.- Specified by:
getChunkSizein interfaceChunkedSpreadSheetReader- Returns:
- the size of the chunks, < 1 denotes infinity
-
chunkSizeTipText
public String chunkSizeTipText()
Returns the tip text for this property.- Specified by:
chunkSizeTipTextin interfaceChunkedSpreadSheetReader- Returns:
- tip text for this property suitable for displaying in the gui
-
getCorrespondingWriter
public SpreadSheetWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Specified by:
getCorrespondingWriterin interfaceSpreadSheetReader- Returns:
- the writer, null if none available
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceFileFormatHandler- Specified by:
getFormatDescriptionin interfaceSpreadSheetReader- Specified by:
getFormatDescriptionin classAbstractSpreadSheetReader- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceFileFormatHandler- Specified by:
getFormatExtensionsin interfaceSpreadSheetReader- Specified by:
getFormatExtensionsin classAbstractSpreadSheetReader- Returns:
- the extension (without the dot!)
-
getInputType
protected AbstractSpreadSheetReader.InputType getInputType()
Returns how to read the data, from a file, stream or reader.- Specified by:
getInputTypein classAbstractSpreadSheetReader- Returns:
- how to read the data
-
doRead
protected SpreadSheet doRead(File file)
Performs the actual reading.- Overrides:
doReadin classAbstractSpreadSheetReader- Parameters:
file- the file to read from- Returns:
- the spreadsheet or null in case of an error
- See Also:
AbstractSpreadSheetReader.getInputType(),AbstractSpreadSheetReader.supportsCompressedInput()
-
hasMoreChunks
public boolean hasMoreChunks()
Checks whether there is more data to read.- Specified by:
hasMoreChunksin interfaceChunkedSpreadSheetReader- Returns:
- true if there is more data available
-
nextChunk
public SpreadSheet nextChunk()
Returns the next chunk.- Specified by:
nextChunkin interfaceChunkedSpreadSheetReader- Returns:
- the next chunk, null if no data available
-
main
public static void main(String[] args)
Runs the reader from the command-line. Use the optionAbstractSpreadSheetReader.OPTION_INPUTto specify the input file. If the optionAbstractSpreadSheetReader.OPTION_OUTPUTis specified then the read sheet gets output as .csv files in that directory.- Parameters:
args- the command-line options to use
-
-