Package adams.data.conversion
Class AbstractSpreadSheetToMatrix<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.conversion.AbstractConversion
-
- adams.data.conversion.AbstractSpreadSheetToMatrix<T>
-
- Type Parameters:
T
- the cell type of the matrix
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<AbstractConversion>
,SizeOfHandler
,Stoppable
,Conversion
,Serializable
- Direct Known Subclasses:
SpreadSheetToDoubleMatrix
,SpreadSheetToStringMatrix
public abstract class AbstractSpreadSheetToMatrix<T> extends AbstractConversion
Ancestor for conversions that turn a spreadsheet into a matrix of some data type.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SpreadSheetColumnRange
m_Columns
the range of columns to operate on.protected Range
m_Rows
the range of rows to operate on.-
Fields inherited from class adams.data.conversion.AbstractConversion
m_Input, m_Output, m_Owner, m_Stopped
-
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 AbstractSpreadSheetToMatrix()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Class
accepts()
Returns the class that is accepted as input.String
columnsTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected int[]
determineColumns(SpreadSheet sheet)
Determines all the columns to include in the matrix.protected Object
doConvert()
Performs the actual conversion.SpreadSheetColumnRange
getColumns()
Returns the range of columns to use.Range
getRows()
Returns the range of rows to use.protected abstract T
getValue(SpreadSheet sheet, Row row, int col)
Returns the cell value at the specified location.protected abstract boolean
includeColumn(SpreadSheet sheet, int col)
Determines whether to include this particular column.protected abstract T[][]
newMatrix(int rows, int cols)
Generates a new matrix.String
rowsTipText()
Returns the tip text for this property.void
setColumns(SpreadSheetColumnRange value)
Sets the range of columns to use.void
setRows(Range value)
Sets the range of rows to use.-
Methods inherited from class adams.data.conversion.AbstractConversion
checkData, cleanUp, convert, generates, getAdditionalInformation, getInput, getInput, getOutput, getOutput, getOwner, getQuickInfo, reset, setInput, setOwner, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, 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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Columns
protected SpreadSheetColumnRange m_Columns
the range of columns to operate on.
-
m_Rows
protected Range m_Rows
the range of rows to operate on.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setRows
public void setRows(Range value)
Sets the range of rows to use.- Parameters:
value
- the rows
-
getRows
public Range getRows()
Returns the range of rows to use.- Returns:
- the rows
-
rowsTipText
public String rowsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColumns
public void setColumns(SpreadSheetColumnRange value)
Sets the range of columns to use.- Parameters:
value
- the columns
-
getColumns
public SpreadSheetColumnRange getColumns()
Returns the range of columns to use.- Returns:
- the columns
-
columnsTipText
public String columnsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
accepts
public Class accepts()
Returns the class that is accepted as input.- Specified by:
accepts
in interfaceConversion
- Specified by:
accepts
in classAbstractConversion
- Returns:
- the class
-
includeColumn
protected abstract boolean includeColumn(SpreadSheet sheet, int col)
Determines whether to include this particular column.- Parameters:
sheet
- the spreadsheet to work oncol
- the column to check- Returns:
- true if to include in the matrix
-
newMatrix
protected abstract T[][] newMatrix(int rows, int cols)
Generates a new matrix.- Parameters:
rows
- the number of rowscols
- the number of columns
-
determineColumns
protected int[] determineColumns(SpreadSheet sheet)
Determines all the columns to include in the matrix.- Parameters:
sheet
- the spreadsheet to process- Returns:
- the indices (0-based)
-
getValue
protected abstract T getValue(SpreadSheet sheet, Row row, int col)
Returns the cell value at the specified location.- Parameters:
sheet
- the sheet to processrow
- the row to work oncol
- the column index in the row- Returns:
- the cell value
-
doConvert
protected Object doConvert() throws Exception
Performs the actual conversion.- Specified by:
doConvert
in classAbstractConversion
- Returns:
- the converted data
- Throws:
Exception
- if something goes wrong with the conversion
-
-