Package adams.data.filter
Class AbstractFilter<T extends DataContainer>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.filter.AbstractFilter<T>
-
- Type Parameters:
T
- the data type to pass through the filter
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<Filter>
,SizeOfHandler
,Filter<T>
,Serializable
,Comparable
- Direct Known Subclasses:
AbstractAutocorrelation
,AbstractBatchFilter
,AbstractDatabaseConnectionFilter
,AbstractDerivative
,AbstractEquiDistance
,AbstractFastWavelet
,AbstractFFT
,AbstractHistogram
,AbstractLOWESS
,AbstractPreFilter
,AbstractSavitzkyGolay
,AbstractSAX
,AbstractScript
,AbstractScriptedFilter
,AbstractSimpleSavitzkyGolay
,DownSample
,DownSize
,RemoveNoise
,TimeseriesChangeResolution
,TimeseriesResetTimestamps
,TimeseriesRound
,TimeseriesRowNorm
,TimeseriesSetStart
,TimeseriesShiftTimestamps
,TimeseriesShiftValues
,TimeseriesValueSubset
,TimeseriesWindow
public abstract class AbstractFilter<T extends DataContainer> extends AbstractOptionHandler implements Filter<T>
Abstract base class for filters. Derived classes only have to override theprocessData()
method. Thereset()
method can be used to reset an algorithms internal state, e.g., after setting options, which invalidate the previously generated data.- Version:
- $Revision$
- 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
AbstractFilter.FilterJob<T extends DataContainer>
A job class specific to Filters.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_DontUpdateID
whether to suppress updating of ID.-
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 AbstractFilter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkData(T data)
The default implementation only checks whether there is any data set.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.String
dontUpdateIDTipText()
Returns the tip text for this property.boolean
equals(Object o)
Returns whether the two objects are the same.T
filter(T data)
Returns the filtered data.static Filter
forCommandLine(String cmdline)
Instantiates the filter from the given commandline (i.e., classname and optional options).boolean
getDontUpdateID()
Returns whether ID update is suppressed.protected abstract T
processData(T data)
Performs the actual filtering.void
reset()
Resets the filter.void
setDontUpdateID(boolean value)
Sets whether ID update is suppressed.Filter<T>
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.Filter<T>
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.-
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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setDontUpdateID
public void setDontUpdateID(boolean value)
Sets whether ID update is suppressed.- Specified by:
setDontUpdateID
in interfaceFilter<T extends DataContainer>
- Parameters:
value
- true if to suppress
-
getDontUpdateID
public boolean getDontUpdateID()
Returns whether ID update is suppressed.- Specified by:
getDontUpdateID
in interfaceFilter<T extends DataContainer>
- Returns:
- true if suppressed
-
dontUpdateIDTipText
public String dontUpdateIDTipText()
Returns the tip text for this property.- Specified by:
dontUpdateIDTipText
in interfaceFilter<T extends DataContainer>
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
reset
public void reset()
Resets the filter. Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.- Specified by:
reset
in interfaceFilter<T extends DataContainer>
- Overrides:
reset
in classAbstractOptionHandler
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory. Sets the input and generated data to null.- Specified by:
cleanUp
in interfaceCleanUpHandler
- Specified by:
cleanUp
in interfaceFilter<T extends DataContainer>
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Calls cleanUp() and cleans up the options.- Specified by:
destroy
in interfaceDestroyable
- Specified by:
destroy
in interfaceFilter<T extends DataContainer>
- Overrides:
destroy
in classAbstractOptionHandler
- See Also:
AbstractOptionHandler.cleanUpOptions()
-
filter
public T filter(T data)
Returns the filtered data.- Specified by:
filter
in interfaceFilter<T extends DataContainer>
- Parameters:
data
- the data to filter- Returns:
- the filtered data
-
checkData
protected void checkData(T data)
The default implementation only checks whether there is any data set.- Parameters:
data
- the data to filter
-
processData
protected abstract T processData(T data)
Performs the actual filtering.- Parameters:
data
- the data to filter- Returns:
- the filtered data
-
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<T extends DataContainer>
- Specified by:
compareTo
in interfaceFilter<T extends DataContainer>
- 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 Filter<T> shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceFilter<T extends DataContainer>
- Specified by:
shallowCopy
in interfaceShallowCopySupporter<T extends DataContainer>
- Returns:
- the shallow copy
-
shallowCopy
public Filter<T> shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceFilter<T extends DataContainer>
- Specified by:
shallowCopy
in interfaceShallowCopySupporter<T extends DataContainer>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
forCommandLine
public static Filter forCommandLine(String cmdline)
Instantiates the filter from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the filter to instantiate- Returns:
- the instantiated filter or null if an error occurred
-
-