public class DatabaseResultListener extends DatabaseUtils implements ResultListener
Modifier and Type | Field and Description |
---|---|
protected FastVector |
m_Cache
Stores the cached values
|
protected Object[] |
m_CacheKey
Stores the key for which the cache is valid
|
protected int |
m_CacheKeyIndex
Stores the index of the key column holding the cache key data
|
protected String |
m_CacheKeyName
Holds the name of the key field to cache upon, or null if no caching
|
protected boolean |
m_Debug
True if debugging output should be printed
|
protected ResultProducer |
m_ResultProducer
The ResultProducer to listen to
|
protected String |
m_ResultsTableName
The name of the current results table
|
BOOL, BYTE, DATE, DOUBLE, DRIVERS, DRIVERS_ERRORS, EXP_INDEX_TABLE, EXP_RESULT_COL, EXP_RESULT_PREFIX, EXP_SETUP_COL, EXP_TYPE_COL, FLOAT, INTEGER, LONG, m_checkForLowerCaseNames, m_checkForUpperCaseNames, m_Connection, m_createIndex, m_DatabaseURL, m_doubleType, m_intType, m_Keywords, m_KeywordsMaskChar, m_password, m_PreparedStatement, m_setAutoCommit, m_stringType, m_userName, PROPERTIES, PROPERTY_FILE, SHORT, STRING, TEXT, TIME
Constructor and Description |
---|
DatabaseResultListener()
Sets up the database drivers
|
Modifier and Type | Method and 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
|
protected boolean |
isCacheValid(Object[] key)
Checks whether the current cache contents are valid for the supplied
key.
|
protected boolean |
isKeyInCache(ResultProducer rp,
Object[] key)
Returns true if the supplied key is in the key cache (and thus
we do not need to execute a database query).
|
boolean |
isResultRequired(ResultProducer rp,
Object[] key)
Always says a result is required.
|
protected void |
loadCache(ResultProducer rp,
Object[] key)
Executes a database query to fill the key cache
|
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.
|
protected void |
updateResultsTableName(ResultProducer rp)
Determines the table name that results will be inserted into.
|
arrayToString, attributeCaseFix, close, close, connectToDatabase, createExperimentIndex, createExperimentIndexEntry, createResultsTable, databaseURLTipText, debugTipText, disconnectFromDatabase, execute, experimentIndexExists, getDatabaseURL, getDebug, getKeywords, getKeywordsMaskChar, getPassword, getResultFromTable, getResultSet, getResultsTableName, getSupportedCursorScrollType, getUsername, isConnected, isCursorScrollable, isCursorScrollSensitive, isKeyInTable, isKeyword, maskKeyword, passwordTipText, processKeyString, putResultInTable, select, setDatabaseURL, setDebug, setKeywords, setKeywordsMaskChar, setPassword, setUsername, tableExists, translateDBColumnType, typeName, update, usernameTipText
protected ResultProducer m_ResultProducer
protected String m_ResultsTableName
protected boolean m_Debug
protected String m_CacheKeyName
protected int m_CacheKeyIndex
protected Object[] m_CacheKey
protected FastVector m_Cache
public String globalInfo()
public void preProcess(ResultProducer rp) throws Exception
preProcess
in interface ResultListener
rp
- the ResultProducer that will generate the resultsException
- if an error occurs during preprocessing.public void postProcess(ResultProducer rp) throws Exception
postProcess
in interface ResultListener
rp
- the ResultProducer that generated the resultsException
- if an error occurspublic String[] determineColumnConstraints(ResultProducer rp) throws Exception
determineColumnConstraints
in interface ResultListener
rp
- the ResultProducer to which the constraints will applyException
- if an error occurs.public void acceptResult(ResultProducer rp, Object[] key, Object[] result) throws Exception
acceptResult
in interface ResultListener
rp
- the ResultProducer that generated the resultkey
- The key for the results.result
- The actual results.Exception
- if the result couldn't be sent to the databasepublic boolean isResultRequired(ResultProducer rp, Object[] key) throws Exception
isResultRequired
in interface ResultListener
rp
- the ResultProducer wanting to generate the resultkey
- The key for which a result may be needed.Exception
- if the database couldn't be queriedprotected void updateResultsTableName(ResultProducer rp) throws Exception
rp
- the ResultProducerException
- if an error occurspublic String cacheKeyNameTipText()
public String getCacheKeyName()
public void setCacheKeyName(String newCacheKeyName)
newCacheKeyName
- Value to assign to CacheKeyName.protected boolean isCacheValid(Object[] key)
key
- the results keyprotected boolean isKeyInCache(ResultProducer rp, Object[] key) throws Exception
rp
- the ResultProducer the key belongs to.key
- the result keyException
- if an error occursprotected void loadCache(ResultProducer rp, Object[] key) throws Exception
rp
- the ResultProducer the key belongs tokey
- the keyException
- if an error occurspublic String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class DatabaseUtils
Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.