All Packages Class Hierarchy This Package Previous Next Index
Class tc.database.DatabaseQuery
java.lang.Object
|
+----tc.database.DatabaseQuery
- public abstract class DatabaseQuery
- extends Object
DatabaseQuery
is a common interface for all database queries. It
defines the methods which a database query must implement so that
DatabaseManager
can execute it.
- Version:
- 0.30, 1998/04/01
- Author:
- FRED development team, Antti Viljamaa
- See Also:
- DatabaseManager
-
databaseManager
- The database manager that executes this query.
-
parameters
- The possible parameters needed to execute the query.
-
result
- The query result.
-
DatabaseQuery()
-
-
calculate(QueryDataSet)
- Finalizes the query by possible gathering information from the given
datset (that is formed based on the SQL query that
getSQLClause
returned) or modifying the dataset.
-
doValidationCheck()
-
DatabaseManager
always calls this method before the actual
calculation.
-
getDatabaseManager()
- Gets the
DatabaseManager
of this query.
-
getParameters()
- Gets the parameters needed to execute the query.
-
getResult()
- Returns the query result.
-
getSQLClause()
- This method must return the SQL clause that is used to create a
QueryDataSet
for this query.
-
isWriteQuery()
- Determines if this query is a write query (intends to modify the data in
the database).
-
setDatabaseManager(DatabaseManager)
- Sets a
DatabaseManager
for this query.
-
setParameters(Object)
- Sets the possible parameters needed to execute the query.
-
setResult(Object)
- Sets the query result.
databaseManager
private DatabaseManager databaseManager
- The database manager that executes this query. The query can use this
reference when implementing other methods because the reference is set
before any other methods are called.
parameters
private Object parameters
- The possible parameters needed to execute the query.
result
private Object result
- The query result.
DatabaseQuery
public DatabaseQuery()
calculate
public abstract void calculate(QueryDataSet dataset) throws DataSetException, ValidationException
- Finalizes the query by possible gathering information from the given
datset (that is formed based on the SQL query that
getSQLClause
returned) or modifying the dataset.
If this query is a read query this method should create the result object
that is retuned in getResult
. Otherwise, if this query is a
write query this method should modify or remove the wanted rows in the
dataset. The dataset includes proper methods for iterating and examining
it.
- See Also:
- QueryDataSet, getResult
getDatabaseManager
public DatabaseManager getDatabaseManager()
- Gets the
DatabaseManager
of this query.
doValidationCheck
public void doValidationCheck() throws ValidationException
-
DatabaseManager
always calls this method before the actual
calculation. In this method a database query can perform an additional
check which ensures that the query can be performed. If the check fails,
the method must throw a subclass of ValidationException.
getResult
public Object getResult()
- Returns the query result.
getSQLClause
public abstract String getSQLClause()
- This method must return the SQL clause that is used to create a
QueryDataSet
for this query. The create dataset is fetched as
a parameter for the calculate
method.
- Returns:
- String A string representing the query.
- See Also:
- QueryDataSet, calculate
isWriteQuery
public abstract boolean isWriteQuery()
- Determines if this query is a write query (intends to modify the data in
the database).
setDatabaseManager
public void setDatabaseManager(DatabaseManager dbm)
- Sets a
DatabaseManager
for this query.
setResult
public void setResult(Object res)
- Sets the query result.
getParameters
protected Object getParameters()
- Gets the parameters needed to execute the query.
setParameters
protected void setParameters(Object p)
- Sets the possible parameters needed to execute the query.
All Packages Class Hierarchy This Package Previous Next Index