| org.mmbase.storage.search.implementation.database.SqlHandler
All known Subclasses: org.mmbase.storage.search.implementation.database.PostgreSqlSqlHandler, org.mmbase.storage.search.implementation.database.ChainedSqlHandler, org.mmbase.storage.search.implementation.database.BasicSqlHandler, org.mmbase.storage.search.implementation.database.InformixSqlHandler, org.mmbase.storage.search.implementation.database.informix.excalibur.EtxSqlHandler, org.mmbase.storage.search.implementation.database.functions.FunctionSqlHandler, org.mmbase.storage.search.implementation.database.MySqlSqlHandler, org.mmbase.storage.search.implementation.database.MSSqlSqlHandler, org.mmbase.storage.search.implementation.database.HSqlSqlHandler,
SqlHandler | public interface SqlHandler (Code) | | Interface for handler classes that are used to create SQL string
representations of
SearchQuery SearchQuery objects.
A number of SqlHandler objects can create a chain of handlers,
following the Chain Of Responsibility design pattern.
In short:
- A chain is formed of
SqlHandler objects, where each
element in the chain, except the last one, is called a chained
handler.
Each chained handler has a successor, which is the next element
in the chain.
- The first element receives all requests first (a request =
call of one of the methods in the interface).
When a chained element receives a request, it can either handle it or pass
it on to its successor.
- The last element in the chain, handles all remaining requests.
Each handler in the chain adds functionality to its successor(s),
in a way similar to subclassing. The chained design
enables a chain of handlers to be configured and created
at runtime.
In addition to the methods defined in the interface, the concrete
SqlHandler class for the last element in the chain
is required to have a constructor with this signature:
public <constructor>(Map disallowedValues) { .. }
where disallowedValues is a map that maps disallowed
table/fieldnames to allowed alternatives.
The concrete SqlHandler class for the other, chained,
elements in the chain are required to have a constructor
with this signature:
public <constructor>(SqlHandler successor) { .. }
where successor is the successor in the chain
of responsibility.
author: Rob van Maris version: $Id: SqlHandler.java,v 1.8 2007/06/12 10:59:41 michiel Exp $ since: MMBase-1.7 |
Method Summary | |
void | appendConstraintToSql(StringBuilder sb, Constraint constraint, SearchQuery query, boolean inverse, boolean inComposite) Represents Constraint object, that is not a CompositeConstraint,
as a constraint in SQL format, appending the result to a stringbuffer. | public void | appendQueryBodyToSql(StringBuilder sb, SearchQuery query, SqlHandler firstInChain) Represents body of a SearchQuery object as a string in SQL format,
using the database configuration. | public String | getAllowedValue(String value) Maps string to value that is allowed as table or field name.
org.mmbase.storage.StorageManagerFactory.getStorageIdentifier Parameters: value - The string value. | public int | getSupportLevel(int feature, SearchQuery query) Gets the level at which a feature is supported for a query
by this handler. | public int | getSupportLevel(Constraint constraint, SearchQuery query) Gets the level at which a constraint is supported for a query
by this handler. | String | toSql(SearchQuery query, SqlHandler firstInChain) Represents a SearchQuery object as a string in SQL format,
using the database configuration.
Parameters: query - The searchquery. Parameters: firstInChain - The first element in the chain of handlers.At some point appendQueryBodyToSql() will haveto be called on this handler, to generate the body of the query. |
appendConstraintToSql | void appendConstraintToSql(StringBuilder sb, Constraint constraint, SearchQuery query, boolean inverse, boolean inComposite) throws SearchQueryException(Code) | | Represents Constraint object, that is not a CompositeConstraint,
as a constraint in SQL format, appending the result to a stringbuffer.
When it is part of a composite expression, it will be surrounded by
parenthesis when needed.
Parameters: sb - The stringbuffer to append to. Parameters: constraint - The (non-composite) constraint. Parameters: query - The searchquery containing the constraint. Parameters: inverse - True when the inverse constraint must be represented,false otherwise. Parameters: inComposite - True when the constraint is part ofa composite expression. |
appendQueryBodyToSql | public void appendQueryBodyToSql(StringBuilder sb, SearchQuery query, SqlHandler firstInChain) throws SearchQueryException(Code) | | Represents body of a SearchQuery object as a string in SQL format,
using the database configuration. Appends this to a stringbuffer.
The body of the SQL query string is defined as the substring containing
fields, tables, constraints and orders.
Parameters: sb - The stringbuffer to append to. Parameters: query - The searchquery. Parameters: firstInChain - The first element in the chain of handlers.At some point appendConstraintToSql() will haveto be called on this handler, to generate the constraints inthe query. |
getSupportLevel | public int getSupportLevel(int feature, SearchQuery query) throws SearchQueryException(Code) | | Gets the level at which a feature is supported for a query
by this handler. This is one of either:
Given the choice, the query handler with the highest level of support is prefered.
|
getSupportLevel | public int getSupportLevel(Constraint constraint, SearchQuery query) throws SearchQueryException(Code) | | Gets the level at which a constraint is supported for a query
by this handler. This is one of either:
Given the choice, the query handler with the highest level of support is prefered.
|
toSql | String toSql(SearchQuery query, SqlHandler firstInChain) throws SearchQueryException(Code) | | Represents a SearchQuery object as a string in SQL format,
using the database configuration.
Parameters: query - The searchquery. Parameters: firstInChain - The first element in the chain of handlers.At some point appendQueryBodyToSql() will haveto be called on this handler, to generate the body of the query. SQL string representation of the query. |
|
|