public class ChainedSqlHandler extends Object implements SqlHandler
SqlHandler
implementations that wrap SqlHandler objects to create a chain
of handlers, following the Chain Of Responsibility design pattern.
This class is provided as a baseclass to for chained handlers.
It implements all SqlHandler methods by delegating to
its successor, i.e. the next handler in the chain.
SqlHandler| Constructor and Description |
|---|
ChainedSqlHandler(SqlHandler successor)
Creates a new instance of ChainedSqlHandler.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
void |
appendQueryBodyToSql(StringBuilder sb,
SearchQuery query,
SqlHandler firstInChain)
Represents body of a SearchQuery object as a string in SQL format,
using the database configuration.
|
String |
getAllowedValue(String value)
Maps string to value that is allowed as table or field name.
|
protected SqlHandler |
getSuccessor()
Accessor to successor in chain of responsibility.
|
int |
getSupportLevel(Constraint constraint,
SearchQuery query)
Gets the level at which a constraint is supported for a query
by this handler.
|
int |
getSupportLevel(int feature,
SearchQuery query)
Gets the level at which a feature 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.
|
public ChainedSqlHandler(SqlHandler successor)
successor - Successor in chain of responsibility.public String toSql(SearchQuery query, SqlHandler firstInChain) throws SearchQueryException
SqlHandlertoSql in interface SqlHandlerquery - The searchquery.firstInChain - The first element in the chain of handlers.
At some point appendQueryBodyToSql() will have
to be called on this handler, to generate the body of the query.SearchQueryExceptionpublic void appendQueryBodyToSql(StringBuilder sb, SearchQuery query, SqlHandler firstInChain) throws SearchQueryException
SqlHandlerappendQueryBodyToSql in interface SqlHandlersb - The stringbuffer to append to.query - The searchquery.firstInChain - The first element in the chain of handlers.
At some point appendConstraintToSql() will have
to be called on this handler, to generate the constraints in
the query.SearchQueryExceptionpublic void appendConstraintToSql(StringBuilder sb, Constraint constraint, SearchQuery query, boolean inverse, boolean inComposite) throws SearchQueryException
SqlHandlerappendConstraintToSql in interface SqlHandlersb - The stringbuffer to append to.constraint - The (non-composite) constraint.query - The searchquery containing the constraint.inverse - True when the inverse constraint must be represented,
false otherwise.inComposite - True when the constraint is part of
a composite expression.SearchQueryExceptionpublic int getSupportLevel(int feature,
SearchQuery query)
throws SearchQueryException
SqlHandlergetSupportLevel in interface SqlHandlerSearchQueryExceptionpublic int getSupportLevel(Constraint constraint, SearchQuery query) throws SearchQueryException
SqlHandlergetSupportLevel in interface SqlHandlerSearchQueryExceptionpublic String getAllowedValue(String value)
SqlHandlergetAllowedValue in interface SqlHandlervalue - The string value.protected SqlHandler getSuccessor()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}