Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.preprocessing
Class PreprocessorHandler<O extends DatabaseObject,P extends Preprocessor<O>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.preprocessing.PreprocessorHandler<O,P>
Type Parameters:
O - the type of DatabaseObject to run the Preprocessor on
P - the type of Preprocessor used
All Implemented Interfaces:
DatabaseListener, Parameterizable

public class PreprocessorHandler<O extends DatabaseObject,P extends Preprocessor<O>>
extends AbstractParameterizable
implements DatabaseListener

Handler class for all objects (e.g. distance functions) using a preprocessor running on a certain database.

Author:
Elke Achtert

Field Summary
private  AssociationID<?> associationID
          The association ID for the association to be set by the preprocessor.
private  Database<O> database
          The database to run the preprocessor on.
private  boolean omit
          Holds the value of OMIT_PREPROCESSING_FLAG.
private  Flag OMIT_PREPROCESSING_FLAG
          Flag to omit (a new) preprocessing if for each object the association has already been set.
static OptionID OMIT_PREPROCESSING_ID
          OptionID for OMIT_PREPROCESSING_FLAG
private  P preprocessor
          Holds the instance of the preprocessor specified by PREPROCESSOR_PARAM.
static OptionID PREPROCESSOR_ID
          OptionID for PREPROCESSOR_PARAM
private  ClassParameter<P> PREPROCESSOR_PARAM
          Parameter to specify the preprocessor to be used, must extend at least Preprocessor.
private  boolean time
          Indicates if the time flag is set for preprocessing.
private  boolean verbose
          Indicates if the verbose flag is set for preprocessing.
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
PreprocessorHandler(PreprocessorClient<P,O> preprocessorClient)
          Provides a handler class for all objects using a preprocessor, adding parameter PREPROCESSOR_PARAM and flag OMIT_PREPROCESSING_FLAG to the option handler additionally to parameters of super class.
 
Method Summary
 P getPreprocessor()
          Returns the preprocessor.
 void objectsChanged(DatabaseEvent e)
          Invoked after objects of the database have been updated in some way.
 void objectsInserted(DatabaseEvent e)
          Invoked after an object has been inserted into the database.
 void objectsRemoved(DatabaseEvent e)
          Invoked after an object has been deleted from the database.
 void runPreprocessor(Database<O> database, boolean verbose, boolean time)
          Runs the preprocessor on the database if the omit flag is not set or the database does contain the association id neither for any id nor as global association.
 List<String> setParameters(List<String> args)
          Calls AbstractParameterizable#setParameters and sets additionally the value of flag OMIT_PREPROCESSING_FLAG and instantiates preprocessor according to the value of parameter PREPROCESSOR_PARAM The remaining parameters are passed to the preprocessor.
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable, shortDescription
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREPROCESSOR_ID

public static final OptionID PREPROCESSOR_ID
OptionID for PREPROCESSOR_PARAM


PREPROCESSOR_PARAM

private final ClassParameter<P extends Preprocessor<O>> PREPROCESSOR_PARAM
Parameter to specify the preprocessor to be used, must extend at least Preprocessor.

Key: -distancefunction.preprocessor


preprocessor

private P extends Preprocessor<O> preprocessor
Holds the instance of the preprocessor specified by PREPROCESSOR_PARAM.


OMIT_PREPROCESSING_ID

public static final OptionID OMIT_PREPROCESSING_ID
OptionID for OMIT_PREPROCESSING_FLAG


OMIT_PREPROCESSING_FLAG

private final Flag OMIT_PREPROCESSING_FLAG
Flag to omit (a new) preprocessing if for each object the association has already been set.

Key: -distancefunction.omitPreprocessing


omit

private boolean omit
Holds the value of OMIT_PREPROCESSING_FLAG.


associationID

private AssociationID<?> associationID
The association ID for the association to be set by the preprocessor.


verbose

private boolean verbose
Indicates if the verbose flag is set for preprocessing.


time

private boolean time
Indicates if the time flag is set for preprocessing.


database

private Database<O extends DatabaseObject> database
The database to run the preprocessor on.

Constructor Detail

PreprocessorHandler

public PreprocessorHandler(PreprocessorClient<P,O> preprocessorClient)
Provides a handler class for all objects using a preprocessor, adding parameter PREPROCESSOR_PARAM and flag OMIT_PREPROCESSING_FLAG to the option handler additionally to parameters of super class.

Parameters:
preprocessorClient - the class using this handler
Method Detail

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Calls AbstractParameterizable#setParameters and sets additionally the value of flag OMIT_PREPROCESSING_FLAG and instantiates preprocessor according to the value of parameter PREPROCESSOR_PARAM The remaining parameters are passed to the preprocessor.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
a list containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting

objectsChanged

public void objectsChanged(DatabaseEvent e)
Invoked after objects of the database have been updated in some way. Runs the preprocessor if OMIT_PREPROCESSING_FLAG is not set.

Specified by:
objectsChanged in interface DatabaseListener
Parameters:
e - unused

objectsInserted

public void objectsInserted(DatabaseEvent e)
Invoked after an object has been inserted into the database. Runs the preprocessor if OMIT_PREPROCESSING_FLAG is not set.

Specified by:
objectsInserted in interface DatabaseListener
Parameters:
e - unused

objectsRemoved

public void objectsRemoved(DatabaseEvent e)
Invoked after an object has been deleted from the database. Runs the preprocessor if OMIT_PREPROCESSING_FLAG is not set.

Specified by:
objectsRemoved in interface DatabaseListener
Parameters:
e - unused

getPreprocessor

public P getPreprocessor()
Returns the preprocessor.

Returns:
the instance of the preprocessor specified by PREPROCESSOR_PARAM

runPreprocessor

public void runPreprocessor(Database<O> database,
                            boolean verbose,
                            boolean time)
Runs the preprocessor on the database if the omit flag is not set or the database does contain the association id neither for any id nor as global association.

Parameters:
database - the database to run the preprocessor on
verbose - flag to allow verbose messages while performing the method
time - flag to request output of performance time

Release 0.2 (2009-07-06_1820)