Class AbstractCleaner

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.ShallowCopySupporter<AbstractCleaner>, adams.core.SizeOfHandler, Serializable, Comparable
    Direct Known Subclasses:
    AbstractDatabaseConnectionCleaner, AbstractSerializableCleaner, MinMax, PassThrough

    public abstract class AbstractCleaner
    extends adams.core.option.AbstractOptionHandler
    implements Comparable, adams.core.ShallowCopySupporter<AbstractCleaner>
    Abstract base class for cleaners handling Spectrum objects. Derived classes only have to override the check(Spectrum) method. The reset() method can be used to reset an algorithms internal state, e.g., after setting options.
    Version:
    $Revision: 2355 $
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected adams.data.filter.Filter m_ActualPreFilter
      the actual pre-filter to use.
      protected adams.flow.core.Actor m_FlowContext
      the flow context.
      protected adams.data.filter.Filter m_PreFilter
      the pre-filter to use.
      • 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
      AbstractCleaner()  
    • Field Detail

      • m_PreFilter

        protected adams.data.filter.Filter m_PreFilter
        the pre-filter to use.
      • m_ActualPreFilter

        protected adams.data.filter.Filter m_ActualPreFilter
        the actual pre-filter to use.
      • m_FlowContext

        protected transient adams.flow.core.Actor m_FlowContext
        the flow context.
    • Constructor Detail

      • AbstractCleaner

        public AbstractCleaner()
    • Method Detail

      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • reset

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class adams.core.option.AbstractOptionHandler
      • setPreFilter

        public void setPreFilter​(adams.data.filter.Filter value)
        Sets the filter to use for pre-filtering the data.
        Parameters:
        value - the filter
      • getPreFilter

        public adams.data.filter.Filter getPreFilter()
        Returns the filter to use for pre-filtering the data.
        Returns:
        the filter
      • preFilterTipText

        public String preFilterTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFlowContent

        public void setFlowContent​(adams.flow.core.Actor value)
        Sets the flow context.
        Parameters:
        value - the context
      • getFlowContext

        public adams.flow.core.Actor getFlowContext()
        Returns the flow context.
        Returns:
        the context, null if not available
      • preFilter

        protected Spectrum preFilter​(Spectrum data)
        Performs the filtering.
        Parameters:
        data - the data to filter
      • preCheck

        protected void preCheck​(Spectrum data)
        Performs the some pre-checks whether the data is actually suitable.
        Parameters:
        data - the spectrum to check
      • performCheck

        protected abstract String performCheck​(Spectrum data)
        Performs the actual check.
        Parameters:
        data - the spectrum to check
        Returns:
        null if ok, otherwise error message
      • check

        public String check​(Spectrum data)
        Performs the check.
        Parameters:
        data - the spectrum to check
        Returns:
        null if ok, otherwise error message
      • 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 interface Comparable
        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.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • shallowCopy

        public AbstractCleaner shallowCopy()
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Specified by:
        shallowCopy in interface adams.core.ShallowCopySupporter<AbstractCleaner>
        Returns:
        the shallow copy
      • shallowCopy

        public AbstractCleaner shallowCopy​(boolean expand)
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Specified by:
        shallowCopy in interface adams.core.ShallowCopySupporter<AbstractCleaner>
        Parameters:
        expand - whether to expand variables to their current values
        Returns:
        the shallow copy
      • getCleaners

        public static String[] getCleaners()
        Returns a list with classnames of filters.
        Returns:
        the filter classnames
      • forName

        public static AbstractCleaner forName​(String classname,
                                              String[] options)
        Instantiates the filter with the given options.
        Parameters:
        classname - the classname of the filter to instantiate
        options - the options for the filter
        Returns:
        the instantiated filter or null if an error occurred
      • forCommandLine

        public static AbstractCleaner 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