Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.application
Class AbstractApplication

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.application.AbstractApplication
All Implemented Interfaces:
Parameterizable
Direct Known Subclasses:
CacheDoubleDistanceInOnDiskMatrix, CacheFloatDistanceInOnDiskMatrix, KDDTask, KNNExplorer, StandAloneApplication

public abstract class AbstractApplication
extends AbstractParameterizable

AbstractApplication sets the values for flags verbose and help.

Any Wrapper class that makes use of these flags may extend this class. Beware to make correct use of parameter settings via optionHandler as commented with constructor and methods.

Author:
Elke Achtert, Erich Schubert

Field Summary
private  ClassParameter<Parameterizable> DESCRIPTION_PARAM
          Optional Parameter to specify a class to obtain a description for, must extend Parameterizable .
private  Flag HELP_FLAG
          Flag to obtain help-message.
private  Flag HELP_LONG_FLAG
          Flag to obtain help-message.
static String INFORMATION
          Information for citation and version.
private static String NEWLINE
          The newline string according to system.
private  List<String> remainingParameters
          The remaining parameters after the option handler grabbed the options for this application.
private  boolean verbose
          Value of verbose flag.
private  Flag VERBOSE_FLAG
          Flag to allow verbose messages while running the application.
 
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
protected AbstractApplication()
          Adds the flags VERBOSE_FLAG and HELP_FLAG to the option handler.
 
Method Summary
 List<String> getRemainingParameters()
          Returns a copy of the remaining parameters after the option handler grabbed the options for this application.
 boolean isVerbose()
          Returns whether verbose messages should be printed while executing the application.
private  void printDescription()
          Print the description for the given parameter
private  void printErrorMessage(Exception e)
          Print an error message for the given error.
private  void printHelp()
          Print the help message.
abstract  void run()
          Runs the application.
 void runCLIApplication(String[] args)
          Generic command line invocation.
 List<String> setParameters(List<String> args)
          Grabs all specified options from the option handler.
 String usage()
          Returns a usage message, explaining all known options
 
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

NEWLINE

private static final String NEWLINE
The newline string according to system.


INFORMATION

public static final String INFORMATION
Information for citation and version.


HELP_FLAG

private final Flag HELP_FLAG
Flag to obtain help-message.

Key: -h


HELP_LONG_FLAG

private final Flag HELP_LONG_FLAG
Flag to obtain help-message.

Key: -help


DESCRIPTION_PARAM

private final ClassParameter<Parameterizable> DESCRIPTION_PARAM
Optional Parameter to specify a class to obtain a description for, must extend Parameterizable .

Key: -description


VERBOSE_FLAG

private final Flag VERBOSE_FLAG
Flag to allow verbose messages while running the application.

Key: -verbose


verbose

private boolean verbose
Value of verbose flag.


remainingParameters

private List<String> remainingParameters
The remaining parameters after the option handler grabbed the options for this application.

Constructor Detail

AbstractApplication

protected AbstractApplication()
Adds the flags VERBOSE_FLAG and HELP_FLAG to the option handler. Any extending class should call this constructor, then add further parameters.

Method Detail

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Description copied from class: AbstractParameterizable
Grabs all specified options from the option handler. Any extending class should call this method first and return the returned array without further changes, but after setting further required parameters. An example for overwriting this method taking advantage from the previously (in superclasses) defined options would be:

 {
   List remainingParameters = super.setParameters(args);
   // set parameters for your class
   // for example like this:
   if(isSet(MY_PARAM_VALUE_PARAM))
   {
      myParamValue = getParameterValue(MY_PARAM_VALUE_PARAM);
   }
   .
   .
   .
   return remainingParameters;
   // or in case of attributes requesting parameters themselves
   // return parameterizableAttribbute.setParameters(remainingParameters);
 }
 

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

isVerbose

public final boolean isVerbose()
Returns whether verbose messages should be printed while executing the application.

Returns:
whether verbose messages should be printed while executing the application

getRemainingParameters

public final List<String> getRemainingParameters()
Returns a copy of the remaining parameters after the option handler grabbed the options for this application.

Returns:
the remaining parameters

usage

public String usage()
Returns a usage message, explaining all known options

Returns:
a usage message explaining all known options

runCLIApplication

public void runCLIApplication(String[] args)
Generic command line invocation. Refactored to have a central place for outermost exception handling.

Parameters:
args - the arguments to run this application

printErrorMessage

private void printErrorMessage(Exception e)
Print an error message for the given error.

Parameters:
e - Error Exception.

printHelp

private void printHelp()
Print the help message.


printDescription

private void printDescription()
Print the description for the given parameter


run

public abstract void run()
                  throws UnableToComplyException
Runs the application.

Throws:
UnableToComplyException - if an error occurs during running the application

Release 0.2 (2009-07-06_1820)