adams.data.featuregenerator
Class AbstractFeatureGenerator

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.data.featuregenerator.AbstractFeatureGenerator
All Implemented Interfaces:
Debuggable, Destroyable, OptionHandler, ShallowCopySupporter<AbstractFeatureGenerator>, SizeOfHandler, Serializable, Comparable
Direct Known Subclasses:
AbstractDatabaseConnectionFeatureGenerator, Max, Mean, Median, Min, PassThrough

public abstract class AbstractFeatureGenerator
extends AbstractOptionHandler
implements Comparable, ShallowCopySupporter<AbstractFeatureGenerator>

Abstract base class for feature generators.

Version:
$Revision: 6880 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  String m_Prefix
          the prefix for the feature fields.
static String PREFIX_FEATURE
          the default prefix for the feature fields.
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
AbstractFeatureGenerator()
           
 
Method Summary
protected  Double addFeature(Heatmap data, double value)
          Adds the specified feature.
protected  Double addFeature(Heatmap data, String suffix, double value)
          Adds the specified feature.
protected  void checkData(Heatmap 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.
 boolean equals(Object o)
          Returns whether the two objects are the same.
static AbstractFeatureGenerator forCommandLine(String cmdline)
          Instantiates the generator from the given commandline (i.e., classname and optional options).
static AbstractFeatureGenerator forName(String classname, String[] options)
          Instantiates the generator with the given options.
 Heatmap generate(Heatmap data)
          Generates the features and adds them to the report.
protected  String getDefaultPrefix()
          Returns the default prefix for the generated features.
static String[] getGenerators()
          Returns a list with classnames of generators.
 String getPrefix()
          Returns the prefix in use for the generated features.
 String prefixTipText()
          Returns the tip text for this property.
protected abstract  Heatmap processData(Heatmap data)
          Performs the actual feature generation.
protected  void reset()
          Resets the generator.
 void setPrefix(String value)
          Sets the prefix to use for the generated features.
 AbstractFeatureGenerator shallowCopy()
          Returns a shallow copy of itself, i.e., based on the commandline options.
 AbstractFeatureGenerator 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, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, globalInfo, initialize, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PREFIX_FEATURE

public static final String PREFIX_FEATURE
the default prefix for the feature fields.

See Also:
Constant Field Values

m_Prefix

protected String m_Prefix
the prefix for the feature fields.

Constructor Detail

AbstractFeatureGenerator

public AbstractFeatureGenerator()
Method Detail

reset

protected void reset()
Resets the generator. Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.

Overrides:
reset in class AbstractOptionHandler

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractOptionHandler

getDefaultPrefix

protected String getDefaultPrefix()
Returns the default prefix for the generated features.

Returns:
the default prefix

setPrefix

public void setPrefix(String value)
Sets the prefix to use for the generated features.

Parameters:
value - the prefix to use

getPrefix

public String getPrefix()
Returns the prefix in use for the generated features.

Returns:
the prefix in use

prefixTipText

public String prefixTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the gui

cleanUp

public void cleanUp()
Cleans up data structures, frees up memory.


generate

public Heatmap generate(Heatmap data)
Generates the features and adds them to the report.

Parameters:
data - the data to process
Returns:
the processed data

checkData

protected void checkData(Heatmap data)
The default implementation only checks whether there is any data set.

Parameters:
data - the data to process

addFeature

protected Double addFeature(Heatmap data,
                            double value)
Adds the specified feature. Uses the class name (without packages) as feature suffix.

Parameters:
data - the heatmap to add the feature to
value - the value of the feature
Returns:
the previous value for this feature if any, otherwise null

addFeature

protected Double addFeature(Heatmap data,
                            String suffix,
                            double value)
Adds the specified feature. Uses an explicit suffix for the feature.

Parameters:
data - the heatmap to add the feature to
suffix - the suffix of the feature
value - the value of the feature
Returns:
the previous value for this feature if any, otherwise null

processData

protected abstract Heatmap processData(Heatmap data)
Performs the actual feature generation.

Parameters:
data - the data to process
Returns:
the processed 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 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 AbstractFeatureGenerator shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.

Specified by:
shallowCopy in interface ShallowCopySupporter<AbstractFeatureGenerator>
Returns:
the shallow copy

shallowCopy

public AbstractFeatureGenerator shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.

Specified by:
shallowCopy in interface ShallowCopySupporter<AbstractFeatureGenerator>
Parameters:
expand - whether to expand variables to their current values
Returns:
the shallow copy

getGenerators

public static String[] getGenerators()
Returns a list with classnames of generators.

Returns:
the generator classnames

forName

public static AbstractFeatureGenerator forName(String classname,
                                               String[] options)
Instantiates the generator with the given options.

Parameters:
classname - the classname of the generator to instantiate
options - the options for the generator
Returns:
the instantiated generator or null if an error occurred

forCommandLine

public static AbstractFeatureGenerator forCommandLine(String cmdline)
Instantiates the generator from the given commandline (i.e., classname and optional options).

Parameters:
cmdline - the classname (and optional options) of the generator to instantiate
Returns:
the instantiated generator or null if an error occurred


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.