Package adams.data.io.input
Class Mat5SpreadSheetReader
-
- All Implemented Interfaces:
AdditionalInformationHandler
,Destroyable
,ErrorProvider
,GlobalInfoSupporter
,EncodingSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,MultiSheetSpreadSheetReader<SheetRange>
,SpreadSheetReader
,DataRowTypeHandler
,SpreadSheetTypeHandler
,Serializable
public class Mat5SpreadSheetReader extends AbstractMultiSheetSpreadSheetReader<SheetRange>
Reads Matlab .mat files (format 5)
-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.DefaultSpreadSheet
-sheets <adams.core.Range> (property: sheetRange) The range of sheets to load. default: first example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; the following placeholders can be used as well: first, second, third, last_2, last_1, last
-entry-name <java.lang.String> (property: entryName) The name of the entry to retrieve, takes precedence over range. default:
-field-name <java.lang.String> (property: fieldName) The name of the field to retrieve from the struct. default:
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.data.io.input.AbstractSpreadSheetReader
AbstractSpreadSheetReader.InputType
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_EntryName
the name of the entry to retrieve (the first one if empty).protected String
m_FieldName
the name of the field to retrieve from the struct.-
Fields inherited from class adams.data.io.input.AbstractMultiSheetSpreadSheetReader
m_SheetRange
-
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 Mat5SpreadSheetReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SpreadSheet
convert(us.hebi.matlab.mat.types.Array array)
Converts the array.void
defineOptions()
Adds options to the internal list of options.protected SpreadSheet
doRead(File file)
Performs the actual reading.protected List<SpreadSheet>
doReadRange(File file)
Performs the actual reading.String
entryNameTipText()
Returns the tip text for this property.String
fieldNameTipText()
Returns the tip text for this property.SpreadSheetWriter
getCorrespondingWriter()
Returns, if available, the corresponding writer.protected SheetRange
getDefaultSheetRange()
Returns the default sheet range.String
getEntryName()
Returns the name of the entry to retrieve, takes precedence over range.String
getFieldName()
Returns the name of the field to retrieve to retrieve from the struct.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.String
globalInfo()
Returns a string describing the object.static void
main(String[] args)
Runs the reader from the command-line.void
setEntryName(String value)
Sets the name of the entry to retrieve, takes precedence over range.void
setFieldName(String value)
Sets the name of the field to retrieve to retrieve from the struct.-
Methods inherited from class adams.data.io.input.AbstractMultiSheetSpreadSheetReader
doRead, doRead, doReadRange, doReadRange, getSheetRange, readRange, readRange, readRange, readRange, setSheetRange, sheetRangeTipText
-
Methods inherited from class adams.data.io.input.AbstractSpreadSheetReader
canDecompress, check, dataRowTypeTipText, 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
-
-
-
-
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 classAbstractMultiSheetSpreadSheetReader<SheetRange>
-
getDefaultSheetRange
protected SheetRange getDefaultSheetRange()
Returns the default sheet range.- Specified by:
getDefaultSheetRange
in classAbstractMultiSheetSpreadSheetReader<SheetRange>
- Returns:
- the default
-
setEntryName
public void setEntryName(String value)
Sets the name of the entry to retrieve, takes precedence over range.- Parameters:
value
- the name
-
getEntryName
public String getEntryName()
Returns the name of the entry to retrieve, takes precedence over range.- Returns:
- the name
-
entryNameTipText
public String entryNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFieldName
public void setFieldName(String value)
Sets the name of the field to retrieve to retrieve from the struct.- Parameters:
value
- the name
-
getFieldName
public String getFieldName()
Returns the name of the field to retrieve to retrieve from the struct.- Returns:
- the name
-
fieldNameTipText
public String fieldNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
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.- Returns:
- the writer, null if none available
-
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
-
convert
protected SpreadSheet convert(us.hebi.matlab.mat.types.Array array) throws Exception
Converts the array.- Parameters:
array
- the array to convert- Returns:
- the generated spreadsheet
- Throws:
Exception
- if conversion failed
-
doRead
protected SpreadSheet doRead(File file)
Performs the actual reading. Must handle compression itself, ifAbstractSpreadSheetReader.supportsCompressedInput()
returns true.- Overrides:
doRead
in classAbstractMultiSheetSpreadSheetReader<SheetRange>
- Parameters:
file
- the file to read from- Returns:
- the spreadsheet or null in case of an error
- See Also:
AbstractSpreadSheetReader.getInputType()
-
doReadRange
protected List<SpreadSheet> doReadRange(File file)
Performs the actual reading.- Overrides:
doReadRange
in classAbstractMultiSheetSpreadSheetReader<SheetRange>
- Parameters:
file
- the file to read from- Returns:
- the spreadsheets or null in case of an error
- See Also:
getInputType()
-
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
-
-