Package adams.data.io.input
Class SqlDumpSpreadSheetReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractSpreadSheetReader
-
- adams.data.io.input.SqlDumpSpreadSheetReader
-
- All Implemented Interfaces:
AdditionalInformationHandler
,Destroyable
,ErrorProvider
,GlobalInfoSupporter
,EncodingSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,ChunkedSpreadSheetReader
,SpreadSheetReader
,DataRowTypeHandler
,SpreadSheetTypeHandler
,Serializable
public class SqlDumpSpreadSheetReader extends AbstractSpreadSheetReader implements ChunkedSpreadSheetReader
Reads in SQL dump files.
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-data-row-type <DENSE|SPARSE> (property: dataRowType) The type of row to use for the data. default: DENSE
-custom-column-headers <java.lang.String> (property: customColumnHeaders) The custom headers to use for the columns (comma-separated list). default:
-time-zone <java.util.TimeZone> (property: timeZone) The time zone to use for interpreting dates/times; default is the system-wide defined one.
-use-backslashes (property: useBackslashes) If enabled, any output file that exists when the writer is executed for the first time won't get replaced with the current header; useful when outputting data in multiple locations in the flow, but one needs to be cautious as to not stored mixed content (eg varying number of columns, etc).
-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 class
SqlDumpSpreadSheetReader.ChunkReader
Reads CSV files chunk by chunk.-
Nested classes/interfaces inherited from class adams.data.io.input.AbstractSpreadSheetReader
AbstractSpreadSheetReader.InputType
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_ChunkSize
the chunk size to use.protected String
m_CustomColumnHeaders
the comma-separated list of column header names.protected SqlDumpSpreadSheetReader.ChunkReader
m_Reader
for reading the actual data.protected TimeZone
m_TimeZone
the timezone to use.protected boolean
m_UseBackslashes
whether to use backslashes for escaping.-
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 SqlDumpSpreadSheetReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
chunkSizeTipText()
Returns the tip text for this property.String
customColumnHeadersTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected SpreadSheet
doRead(Reader r)
Performs the actual reading.int
getChunkSize()
Returns the current chunk size.SpreadSheetWriter
getCorrespondingWriter()
Returns, if available, the corresponding writer.String
getCustomColumnHeaders()
Returns whether the file contains a header row or not.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.protected AbstractSpreadSheetReader.InputType
getInputType()
Returns how to read the data, from a file, stream or reader.TimeZone
getTimeZone()
Returns the time zone in use.boolean
getUseBackslashes()
Returns whether to use backslashes for escaping quotes rather than doubling them.String
globalInfo()
Returns a string describing the object.boolean
hasMoreChunks()
Checks whether there is more data to read.static void
main(String[] args)
Runs the reader from the command-line.SpreadSheet
nextChunk()
Returns the next chunk.void
setChunkSize(int value)
Sets the maximum chunk size.void
setCustomColumnHeaders(String value)
Sets the custom headers to use.void
setTimeZone(TimeZone value)
Sets the time zone to use.void
setUseBackslashes(boolean value)
Sets whether to use backslashes for escaping quotes rather than doubling them.String
timeZoneTipText()
Returns the tip text for this property.String
useBackslashesTipText()
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, reset, 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_CustomColumnHeaders
protected String m_CustomColumnHeaders
the comma-separated list of column header names.
-
m_TimeZone
protected TimeZone m_TimeZone
the timezone to use.
-
m_ChunkSize
protected int m_ChunkSize
the chunk size to use.
-
m_UseBackslashes
protected boolean m_UseBackslashes
whether to use backslashes for escaping.
-
m_Reader
protected SqlDumpSpreadSheetReader.ChunkReader m_Reader
for reading the actual data.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractSpreadSheetReader
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Specified by:
getFormatDescription
in interfaceSpreadSheetReader
- Specified by:
getFormatDescription
in classAbstractSpreadSheetReader
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Specified by:
getFormatExtensions
in interfaceSpreadSheetReader
- Specified by:
getFormatExtensions
in classAbstractSpreadSheetReader
- Returns:
- the extension (without the dot!)
-
getCorrespondingWriter
public SpreadSheetWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Specified by:
getCorrespondingWriter
in interfaceSpreadSheetReader
- Returns:
- the writer, null if none available
-
setCustomColumnHeaders
public void setCustomColumnHeaders(String value)
Sets the custom headers to use.- Parameters:
value
- the comma-separated list
-
getCustomColumnHeaders
public String getCustomColumnHeaders()
Returns whether the file contains a header row or not.- Returns:
- the comma-separated list
-
customColumnHeadersTipText
public String customColumnHeadersTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setTimeZone
public void setTimeZone(TimeZone value)
Sets the time zone to use.- Parameters:
value
- the time zone
-
getTimeZone
public TimeZone getTimeZone()
Returns the time zone in use.- Returns:
- the time zone
-
timeZoneTipText
public String timeZoneTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setUseBackslashes
public void setUseBackslashes(boolean value)
Sets whether to use backslashes for escaping quotes rather than doubling them.- Parameters:
value
- if true then backslashes are used
-
getUseBackslashes
public boolean getUseBackslashes()
Returns whether to use backslashes for escaping quotes rather than doubling them.- Returns:
- true if backslashes are used
-
useBackslashesTipText
public String useBackslashesTipText()
Returns the tip text for this property.- 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:
setChunkSize
in interfaceChunkedSpreadSheetReader
- Parameters:
value
- the size of the chunks, < 1 denotes infinity
-
getChunkSize
public int getChunkSize()
Returns the current chunk size.- Specified by:
getChunkSize
in interfaceChunkedSpreadSheetReader
- Parameters:
value
- the size of the chunks, < 1 denotes infinity- Returns:
- the size of the chunks, < 1 denotes infinity
-
chunkSizeTipText
public String chunkSizeTipText()
Returns the tip text for this property.- Specified by:
chunkSizeTipText
in interfaceChunkedSpreadSheetReader
- Returns:
- tip text for this property suitable for displaying in the gui
-
getInputType
protected AbstractSpreadSheetReader.InputType getInputType()
Returns how to read the data, from a file, stream or reader.- Specified by:
getInputType
in classAbstractSpreadSheetReader
- Returns:
- how to read the data
-
doRead
protected SpreadSheet doRead(Reader r)
Performs the actual reading.- Overrides:
doRead
in classAbstractSpreadSheetReader
- Parameters:
r
- the reader to read from- Returns:
- the spreadsheet or null in case of an error
- See Also:
AbstractSpreadSheetReader.getInputType()
-
hasMoreChunks
public boolean hasMoreChunks()
Checks whether there is more data to read.- Specified by:
hasMoreChunks
in interfaceChunkedSpreadSheetReader
- Returns:
- true if there is more data available
-
nextChunk
public SpreadSheet nextChunk()
Returns the next chunk.- Specified by:
nextChunk
in 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_INPUT
to specify the input file. If the optionAbstractSpreadSheetReader.OPTION_OUTPUT
is specified then the read sheet gets output as .csv files in that directory.- Parameters:
args
- the command-line options to use
-
-