Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.database.connection
Class AbstractDatabaseConnection<O extends DatabaseObject>

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.database.connection.AbstractDatabaseConnection<O>
Type Parameters:
O - the type of DatabaseObject to be provided by the implementing class as element of the supplied database
All Implemented Interfaces:
DatabaseConnection<O>, Parameterizable
Direct Known Subclasses:
InputStreamDatabaseConnection, MultipleFileBasedDatabaseConnection

public abstract class AbstractDatabaseConnection<O extends DatabaseObject>
extends AbstractParameterizable
implements DatabaseConnection<O>

Abstract super class for all database connections. AbstractDatabaseConnection already provides the setting of the database according to parameters.

Author:
Elke Achtert

Field Summary
static OptionID CLASS_LABEL_CLASS_ID
          OptionID for CLASS_LABEL_CLASS_PARAM
private  ClassParameter<ClassLabel> CLASS_LABEL_CLASS_PARAM
          Parameter to specify the association of occurring class labels, must extend ClassLabel.
static OptionID CLASS_LABEL_INDEX_ID
          OptionID for CLASS_LABEL_INDEX_PARAM
private  IntParameter CLASS_LABEL_INDEX_PARAM
          Optional parameter that specifies the index of the label to be used as class label, must be an integer equal to or greater than 0.
private  String classLabelClass
          Holds the value of CLASS_LABEL_CLASS_PARAM.
protected  Integer classLabelIndex
          Holds the value of CLASS_LABEL_INDEX_PARAM, null if no class label is specified.
(package private)  Database<O> database
          Holds the instance of the database specified by DATABASE_PARAM.
static OptionID DATABASE_ID
          OptionID for DATABASE_PARAM
private  ClassParameter<Database<O>> DATABASE_PARAM
          Parameter to specify the database to be provided by the parse method, must extend Database.
static OptionID EXTERNAL_ID_INDEX_ID
          OptionID for EXTERNAL_ID_INDEX_PARAM
private  IntParameter EXTERNAL_ID_INDEX_PARAM
          Optional parameter that specifies the index of the label to be used as an external id, must be an integer equal to or greater than 0.
private  Integer externalIDIndex
          Holds the value of EXTERNAL_ID_INDEX_PARAM.
(package private)  boolean forceExternalID
          True, if an external label needs to be set.
static String LABEL_CONCATENATION
          A sign to separate components of a label.
 
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 AbstractDatabaseConnection()
          Adds parameters DATABASE_PARAM, CLASS_LABEL_INDEX_PARAM, CLASS_LABEL_CLASS_PARAM, and EXTERNAL_ID_INDEX_PARAM, to the option handler additionally to parameters of super class.
 
Method Summary
protected  List<Pair<O,Associations>> normalizeAndTransformLabels(List<Pair<O,List<String>>> objectAndLabelsList, Normalization<O> normalization)
          Normalizes and transforms the specified list of objects and their labels into a list of objects and their associations.
 List<String> setParameters(List<String> args)
          Calls the super method and sets additionally the value of the parameters CLASS_LABEL_INDEX_PARAM, CLASS_LABEL_CLASS_PARAM, and EXTERNAL_ID_INDEX_PARAM and instantiates database according to the value of parameter DATABASE_PARAM.
private  List<Pair<O,Associations>> transformLabels(List<Pair<O,List<String>>> objectAndLabelsList)
          Transforms the specified list of objects and their labels into a list of objects and their associations.
 
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
 
Methods inherited from interface de.lmu.ifi.dbs.elki.database.connection.DatabaseConnection
getDatabase
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters, shortDescription
 

Field Detail

LABEL_CONCATENATION

public static final String LABEL_CONCATENATION
A sign to separate components of a label.

See Also:
Constant Field Values

DATABASE_ID

public static final OptionID DATABASE_ID
OptionID for DATABASE_PARAM


DATABASE_PARAM

private final ClassParameter<Database<O extends DatabaseObject>> DATABASE_PARAM
Parameter to specify the database to be provided by the parse method, must extend Database.

Default value: SequentialDatabase

Key: -dbc.database


database

Database<O extends DatabaseObject> database
Holds the instance of the database specified by DATABASE_PARAM.


CLASS_LABEL_INDEX_ID

public static final OptionID CLASS_LABEL_INDEX_ID
OptionID for CLASS_LABEL_INDEX_PARAM


CLASS_LABEL_INDEX_PARAM

private final IntParameter CLASS_LABEL_INDEX_PARAM
Optional parameter that specifies the index of the label to be used as class label, must be an integer equal to or greater than 0.

Key: -dbc.classLabelIndex


classLabelIndex

protected Integer classLabelIndex
Holds the value of CLASS_LABEL_INDEX_PARAM, null if no class label is specified.


CLASS_LABEL_CLASS_ID

public static final OptionID CLASS_LABEL_CLASS_ID
OptionID for CLASS_LABEL_CLASS_PARAM


CLASS_LABEL_CLASS_PARAM

private final ClassParameter<ClassLabel> CLASS_LABEL_CLASS_PARAM
Parameter to specify the association of occurring class labels, must extend ClassLabel.

Default value: SimpleClassLabel

Key: -dbc.classLabelClass


classLabelClass

private String classLabelClass
Holds the value of CLASS_LABEL_CLASS_PARAM.


EXTERNAL_ID_INDEX_ID

public static final OptionID EXTERNAL_ID_INDEX_ID
OptionID for EXTERNAL_ID_INDEX_PARAM


EXTERNAL_ID_INDEX_PARAM

private final IntParameter EXTERNAL_ID_INDEX_PARAM
Optional parameter that specifies the index of the label to be used as an external id, must be an integer equal to or greater than 0.

Key: -dbc.externalIDIndex


externalIDIndex

private Integer externalIDIndex
Holds the value of EXTERNAL_ID_INDEX_PARAM.


forceExternalID

boolean forceExternalID
True, if an external label needs to be set. Default is false.

Constructor Detail

AbstractDatabaseConnection

protected AbstractDatabaseConnection()
Adds parameters DATABASE_PARAM, CLASS_LABEL_INDEX_PARAM, CLASS_LABEL_CLASS_PARAM, and EXTERNAL_ID_INDEX_PARAM, to the option handler additionally to parameters of super class.

Method Detail

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Calls the super method and sets additionally the value of the parameters CLASS_LABEL_INDEX_PARAM, CLASS_LABEL_CLASS_PARAM, and EXTERNAL_ID_INDEX_PARAM and instantiates database according to the value of parameter DATABASE_PARAM. The remaining parameters are passed to the database.

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

normalizeAndTransformLabels

protected List<Pair<O,Associations>> normalizeAndTransformLabels(List<Pair<O,List<String>>> objectAndLabelsList,
                                                                 Normalization<O> normalization)
                                                                                 throws NonNumericFeaturesException
Normalizes and transforms the specified list of objects and their labels into a list of objects and their associations.

Parameters:
objectAndLabelsList - the list of object and their labels to be transformed
normalization - the normalization to be applied
Returns:
a list of normalized objects and their associations
Throws:
NonNumericFeaturesException - if any exception occurs during normalization

transformLabels

private List<Pair<O,Associations>> transformLabels(List<Pair<O,List<String>>> objectAndLabelsList)
Transforms the specified list of objects and their labels into a list of objects and their associations.

Parameters:
objectAndLabelsList - the list of object and their labels to be transformed
Returns:
a list of objects and their associations

Release 0.2 (2009-07-06_1820)