Package weka.experiment

# Class DatabaseResultListener

java.lang.Object
weka.experiment.DatabaseUtils
weka.experiment.DatabaseResultListener

All Implemented Interfaces:
  `Serializable`, `RevisionHandler`, `ResultListener`

Direct Known Subclasses:
  `DatabaseResultProducer`

public class DatabaseResultListener extends DatabaseUtils implements ResultListener
Takes results from a result producer and sends them to a database.

Version:
  $Revision: 11247 $
Author:
  Len Trigg (trigg@cs.waikato.ac.nz)
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class weka.experiment.DatabaseUtils

  `BOOL, BYTE, DATE, DOUBLE, EXP_INDEX_TABLE, EXP_RESULT_COL, EXP_RESULT_PREFIX, EXP_SETUP_COL, EXP_TYPE_COL, FLOAT, INTEGER, LONG, PROPERTY_FILE, SHORT, STRING, TEXT, TIME, TIMESTAMP`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DatabaseResultListener()`
  Sets up the database drivers

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `acceptResult(ResultProducer rp, Object[] key, Object[] result)`
  Submit the result to the appropriate table of the database
  `String`
  `cacheKeyNameTipText()`
  Returns the tip text for this property
  `String[]`
  `determineColumnConstraints(ResultProducer rp)`
  Determines if there are any constraints (imposed by the destination) on any additional measures produced by resultProducers.
  `String`
  `getCacheKeyName()`
  Get the value of CacheKeyName.
  `String`
  `getRevision()`
  Returns the revision string.
  `String`
  `globalInfo()`
  Returns a string describing this result listener
  `boolean`
  `isResultRequired(ResultProducer rp, Object[] key)`
  Always says a result is required.
  `void`
  `postProcess(ResultProducer rp)`
  Perform any postprocessing.
  `void`
  `preProcess(ResultProducer rp)`
  Prepare for the results to be received.
  `void`
  `setCacheKeyName(String newCacheKeyName)`
  Set the value of CacheKeyName.

  ### Methods inherited from class weka.experiment.DatabaseUtils

  `arrayToString, attributeCaseFix, close, close, connectToDatabase, createExperimentIndex, createExperimentIndexEntry, createResultsTable, databaseURLTipText, debugTipText, disconnectFromDatabase, execute, experimentIndexExists, getDatabaseURL, getDebug, getKeywords, getKeywordsMaskChar, getPassword, getResultFromTable, getResultSet, getResultsTableName, getSupportedCursorScrollType, getUsername, initialize, initialize, isConnected, isCursorScrollable, isCursorScrollSensitive, isKeyword, maskKeyword, passwordTipText, processKeyString, putResultInTable, select, setDatabaseURL, setDebug, setKeywords, setKeywordsMaskChar, setPassword, setUsername, tableExists, translateDBColumnType, typeName, update, usernameTipText`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DatabaseResultListener

    public DatabaseResultListener() throws Exception
    Sets up the database drivers
    Throws:
      `Exception` - if an error occurs

- ## Method Details

  - ### globalInfo

    public String globalInfo()
    Returns a string describing this result listener
    Returns:
      a description of the result listener suitable for displaying in the explorer/experimenter gui

  - ### preProcess

    public void preProcess(ResultProducer rp) throws Exception
    Prepare for the results to be received.
    Specified by:
      `preProcess` in interface `ResultListener`
    Parameters:
      `rp` - the ResultProducer that will generate the results
    Throws:
      `Exception` - if an error occurs during preprocessing.

  - ### postProcess

    public void postProcess(ResultProducer rp) throws Exception
    Perform any postprocessing. When this method is called, it indicates that no more results will be sent that need to be grouped together in any way.
    Specified by:
      `postProcess` in interface `ResultListener`
    Parameters:
      `rp` - the ResultProducer that generated the results
    Throws:
      `Exception` - if an error occurs

  - ### determineColumnConstraints

    public String[] determineColumnConstraints(ResultProducer rp) throws Exception
    Determines if there are any constraints (imposed by the destination) on any additional measures produced by resultProducers. Null should be returned if there are NO constraints, otherwise a list of column names should be returned as an array of Strings. In the case of DatabaseResultListener, the structure of an existing database will impose constraints.
    Specified by:
      `determineColumnConstraints` in interface `ResultListener`
    Parameters:
      `rp` - the ResultProducer to which the constraints will apply
    Returns:
      an array of column names to which resutltProducer's results will be restricted.
    Throws:
      `Exception` - if an error occurs.

  - ### acceptResult

    public void acceptResult(ResultProducer rp, Object[] key, Object[] result) throws Exception
    Submit the result to the appropriate table of the database
    Specified by:
      `acceptResult` in interface `ResultListener`
    Parameters:
      `rp` - the ResultProducer that generated the result
      `key` - The key for the results.
      `result` - The actual results.
    Throws:
      `Exception` - if the result couldn't be sent to the database

  - ### isResultRequired

    public boolean isResultRequired(ResultProducer rp, Object[] key) throws Exception
    Always says a result is required. If this is the first call, prints out the header for the Database output.
    Specified by:
      `isResultRequired` in interface `ResultListener`
    Parameters:
      `rp` - the ResultProducer wanting to generate the result
      `key` - The key for which a result may be needed.
    Returns:
      true if the result should be calculated.
    Throws:
      `Exception` - if the database couldn't be queried

  - ### cacheKeyNameTipText

    public String cacheKeyNameTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getCacheKeyName

    public String getCacheKeyName()
    Get the value of CacheKeyName.
    Returns:
      Value of CacheKeyName.

  - ### setCacheKeyName

    public void setCacheKeyName(String newCacheKeyName)
    Set the value of CacheKeyName.
    Parameters:
      `newCacheKeyName` - Value to assign to CacheKeyName.

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Overrides:
      `getRevision` in class `DatabaseUtils`
    Returns:
      the revision