Class AbstractSpreadSheetRowGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.spreadsheetrowgenerator.AbstractSpreadSheetRowGenerator
-
- All Implemented Interfaces:
adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.ShallowCopySupporter<AbstractSpreadSheetRowGenerator>
,adams.core.SizeOfHandler
,Serializable
,Comparable
- Direct Known Subclasses:
SampleDataOnlyRowGenerator
,SimpleRowGenerator
public abstract class AbstractSpreadSheetRowGenerator extends adams.core.option.AbstractOptionHandler implements Comparable, adams.core.CleanUpHandler, adams.core.ShallowCopySupporter<AbstractSpreadSheetRowGenerator>
Abstract base class for schemes that turn spectra into spreadsheet row objects.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
COL_DBID
static String
COL_SAMPLEID
protected boolean
m_AddDatabaseID
whether to add the database ID.protected boolean
m_AddSampleID
whether to add the sample ID.protected adams.data.spreadsheet.SpreadSheet
m_OutputHeader
the generated header.protected boolean
m_TolerateHeaderChanges
whether to tolerate header changes.
-
Constructor Summary
Constructors Constructor Description AbstractSpreadSheetRowGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
addDatabaseIDTipText()
Returns the tip text for this property.String
addSampleIDTipText()
Returns the tip text for this property.protected abstract void
checkHeader(Spectrum data)
Checks whether the number of waves are the same.protected void
checkInput(Spectrum data)
Checks the input spectrum.String
checkSetup()
Checks whether the setup is consistent.void
cleanUp()
Cleans up data structures, frees up memory.int
compareTo(Object o)
Compares this object with the specified object for order.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.boolean
equals(Object o)
Returns whether the two objects are the same.adams.data.spreadsheet.Row
generate(Spectrum data)
Returns the generated data, generates it if necessary.protected abstract void
generateHeader(Spectrum data)
Generates the header of the output data.protected abstract adams.data.spreadsheet.Row
generateOutput(Spectrum data)
Generates the actual data.boolean
getAddDatabaseID()
Returns whether the database ID is added.boolean
getAddSampleID()
Returns whether the sample ID is added.adams.data.spreadsheet.SpreadSheet
getOutputHeader()
Returns the current header.boolean
getTolerateHeaderChanges()
Returns whether to tolerate header changes and merely re-generating the header instead of throwing an exception.protected String
interpretePosition(adams.data.spreadsheet.SpreadSheet data, String position)
Interpretes the position string based on the given dataset.protected void
postProcessHeader(Spectrum data)
Adds IDs, notes, additional fields to header.protected adams.data.spreadsheet.Row
postProcessOutput(Spectrum data, adams.data.spreadsheet.Row row)
For adding IDs, notes, additional fields to the data.protected void
reset()
Resets the generator (but does not clear the input data!).void
setAddDatabaseID(boolean value)
Sets whether the database ID is added to the data or not.void
setAddSampleID(boolean value)
Sets whether the sample ID is added to the data or not.void
setTolerateHeaderChanges(boolean value)
Sets whether to tolerate header changes and merely re-generating the header instead of throwing an exception.AbstractSpreadSheetRowGenerator
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractSpreadSheetRowGenerator
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.String
tolerateHeaderChangesTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
COL_DBID
public static final String COL_DBID
- See Also:
- Constant Field Values
-
COL_SAMPLEID
public static final String COL_SAMPLEID
- See Also:
- Constant Field Values
-
m_OutputHeader
protected adams.data.spreadsheet.SpreadSheet m_OutputHeader
the generated header.
-
m_AddDatabaseID
protected boolean m_AddDatabaseID
whether to add the database ID.
-
m_AddSampleID
protected boolean m_AddSampleID
whether to add the sample ID.
-
m_TolerateHeaderChanges
protected boolean m_TolerateHeaderChanges
whether to tolerate header changes.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
reset
protected void reset()
Resets the generator (but does not clear the input data!). Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.- Overrides:
reset
in classadams.core.option.AbstractOptionHandler
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory. Sets the input data to null.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Calls cleanUp() and cleans up the options.- Specified by:
destroy
in interfaceadams.core.Destroyable
- Overrides:
destroy
in classadams.core.option.AbstractOptionHandler
-
setAddDatabaseID
public void setAddDatabaseID(boolean value)
Sets whether the database ID is added to the data or not.- Parameters:
value
- true if database ID should be added
-
getAddDatabaseID
public boolean getAddDatabaseID()
Returns whether the database ID is added.- Returns:
- true if database ID is added
-
addDatabaseIDTipText
public String addDatabaseIDTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAddSampleID
public void setAddSampleID(boolean value)
Sets whether the sample ID is added to the data or not.- Parameters:
value
- true if sample ID should be added
-
getAddSampleID
public boolean getAddSampleID()
Returns whether the sample ID is added.- Returns:
- true if sample ID is added
-
addSampleIDTipText
public String addSampleIDTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTolerateHeaderChanges
public void setTolerateHeaderChanges(boolean value)
Sets whether to tolerate header changes and merely re-generating the header instead of throwing an exception.- Parameters:
value
- true if to tolerate header changes
-
getTolerateHeaderChanges
public boolean getTolerateHeaderChanges()
Returns whether to tolerate header changes and merely re-generating the header instead of throwing an exception.- Returns:
- true if to tolerate header changes
-
tolerateHeaderChangesTipText
public String tolerateHeaderChangesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getOutputHeader
public adams.data.spreadsheet.SpreadSheet getOutputHeader()
Returns the current header.- Returns:
- the header, can be null
-
checkSetup
public String checkSetup()
Checks whether the setup is consistent.
Default implementation does nothing.- Returns:
- null if everything OK, otherwise the error message
-
generate
public adams.data.spreadsheet.Row generate(Spectrum data)
Returns the generated data, generates it if necessary.- Parameters:
data
- the spectrum to turn into a row- Returns:
- the generated data
-
checkInput
protected void checkInput(Spectrum data)
Checks the input spectrum.
The default implementation only checks whether there is any data set.- Parameters:
data
- the data to process
-
checkHeader
protected abstract void checkHeader(Spectrum data)
Checks whether the number of waves are the same.- Parameters:
data
- the input data
-
generateHeader
protected abstract void generateHeader(Spectrum data)
Generates the header of the output data.- Parameters:
data
- the input data
-
interpretePosition
protected String interpretePosition(adams.data.spreadsheet.SpreadSheet data, String position)
Interpretes the position string based on the given dataset. "first", "second", "third", "last-2", "last-1" and "last" and "last+1" are valid as well.- Parameters:
data
- the data to base the intepretation onposition
- the position string- Returns:
- the numeric position string
-
postProcessHeader
protected void postProcessHeader(Spectrum data)
Adds IDs, notes, additional fields to header.- Parameters:
data
- the input data
-
generateOutput
protected abstract adams.data.spreadsheet.Row generateOutput(Spectrum data)
Generates the actual data.- Parameters:
data
- the input data to transform- Returns:
- the generated data
-
postProcessOutput
protected adams.data.spreadsheet.Row postProcessOutput(Spectrum data, adams.data.spreadsheet.Row row)
For adding IDs, notes, additional fields to the data.- Parameters:
data
- the input datarow
- the generated row- Returns:
- the processed row
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
shallowCopy
public AbstractSpreadSheetRowGenerator shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractSpreadSheetRowGenerator>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractSpreadSheetRowGenerator shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractSpreadSheetRowGenerator>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
-