Package adams.data.statistics
Class AbstractDataStatistic<T extends DataContainer>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.data.statistics.AbstractDataStatistic<T>
-
- Type Parameters:
T
- the type of data the statistic processes
- All Implemented Interfaces:
CleanUpHandler
,LoggingSupporter
,SizeOfHandler
,SpreadSheetSupporter
,InformativeStatistic
,Serializable
- Direct Known Subclasses:
TimeseriesStatistic
public abstract class AbstractDataStatistic<T extends DataContainer> extends LoggingObject implements InformativeStatistic, CleanUpHandler
A class for statistics about data.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Calculated
indicates whether statistics have been calculated.protected T
m_Data
the underlying chromatogram.protected List<String>
m_Names
contains the ordered names.protected Hashtable<String,Double>
m_Statistics
contains the statistics.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractDataStatistic()
Initializes the statistic.AbstractDataStatistic(T data)
Initializes the statistic.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(String name, double value)
Adds the name/value pair to the internal list.protected void
calculate()
Re-calculates the statistics.void
cleanUp()
Cleans up data structures, frees up memory.protected void
clear()
Removes the stored content.T
getData()
Returns the currently stored data container.double
getStatistic(String name)
Returns the statistical value for the given statistic name.abstract String
globalInfo()
Returns a string describing the object.protected double
numberToDouble(Number value)
Returns a double primitive from the given Number.void
setData(T value)
Sets the data to use as basis for the calculations.Iterator<String>
statisticNames()
Returns all the names of the available statistical values.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.String
toString()
Returns the container as string.-
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.data.statistics.InformativeStatistic
getStatisticDescription
-
-
-
-
Field Detail
-
m_Calculated
protected boolean m_Calculated
indicates whether statistics have been calculated.
-
m_Data
protected T extends DataContainer m_Data
the underlying chromatogram.
-
-
Constructor Detail
-
AbstractDataStatistic
public AbstractDataStatistic()
Initializes the statistic.
-
AbstractDataStatistic
public AbstractDataStatistic(T data)
Initializes the statistic.- Parameters:
data
- the data to initialize with
-
-
Method Detail
-
globalInfo
public abstract String globalInfo()
Returns a string describing the object.- Returns:
- a description suitable for displaying in the gui
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
clear
protected void clear()
Removes the stored content.
-
calculate
protected void calculate()
Re-calculates the statistics. Derived classes must override this method if they want to return anything via statisticNames() or getStatistic(String), the default implementation does nothing.- See Also:
statisticNames()
,getStatistic(String)
,m_Names
,m_Statistics
-
setData
public void setData(T value)
Sets the data to use as basis for the calculations.- Parameters:
value
- the data to use, can be null
-
getData
public T getData()
Returns the currently stored data container.- Returns:
- the data, can be null
-
add
public void add(String name, double value)
Adds the name/value pair to the internal list.- Parameters:
name
- the name of the statisticvalue
- the corresponding value
-
numberToDouble
protected double numberToDouble(Number value)
Returns a double primitive from the given Number. In case of null, Double.NaN is returned.- Parameters:
value
- the number to get the double value from- Returns:
- the double value
-
statisticNames
public Iterator<String> statisticNames()
Returns all the names of the available statistical values.- Specified by:
statisticNames
in interfaceInformativeStatistic
- Returns:
- the enumeration of names
-
getStatistic
public double getStatistic(String name)
Returns the statistical value for the given statistic name.- Specified by:
getStatistic
in interfaceInformativeStatistic
- Parameters:
name
- the name of the statistical value- Returns:
- the corresponding value
-
toString
public String toString()
Returns the container as string.
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceSpreadSheetSupporter
- Returns:
- the content
-
-