01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.storage.search.implementation.database;
11:
12: import org.mmbase.storage.search.*;
13:
14: /**
15: * Baseclass for <em>chained sql handlers</em>, these are
16: * {@link org.mmbase.storage.search.implementation.database.SqlHandler SqlHandler}
17: * implementations that wrap <code>SqlHandler</code> objects to create a chain
18: * of handlers, following the <em>Chain Of Responsibility</em> design pattern.
19: * <p>
20: * This class is provided as a baseclass to for chained handlers.
21: * It implements all <code>SqlHandler</code> methods by delegating to
22: * its <em>successor</em>, i.e. the next handler in the chain.
23: *
24: * @author Rob van Maris
25: * @version $Id: ChainedSqlHandler.java,v 1.6 2007/06/12 10:59:41 michiel Exp $
26: * @since MMBase-1.7
27: * @see org.mmbase.storage.search.implementation.database.SqlHandler
28: */
29: public class ChainedSqlHandler implements SqlHandler {
30:
31: /** Successor in chain or responsibility. */
32: private SqlHandler successor = null;
33:
34: /**
35: * Creates a new instance of ChainedSqlHandler.
36: *
37: * @param successor Successor in chain of responsibility.
38: */
39: public ChainedSqlHandler(SqlHandler successor) {
40: this .successor = successor;
41: }
42:
43: // javadoc is inherited
44: public String toSql(SearchQuery query, SqlHandler firstInChain)
45: throws SearchQueryException {
46: return successor.toSql(query, firstInChain);
47: }
48:
49: // javadoc is inherited
50: public void appendQueryBodyToSql(StringBuilder sb,
51: SearchQuery query, SqlHandler firstInChain)
52: throws SearchQueryException {
53: successor.appendQueryBodyToSql(sb, query, firstInChain);
54: }
55:
56: // javadoc is inherited
57: public void appendConstraintToSql(StringBuilder sb,
58: Constraint constraint, SearchQuery query, boolean inverse,
59: boolean inComposite) throws SearchQueryException {
60: successor.appendConstraintToSql(sb, constraint, query, inverse,
61: inComposite);
62: }
63:
64: // javadoc is inherited
65: public int getSupportLevel(int feature, SearchQuery query)
66: throws SearchQueryException {
67: return successor.getSupportLevel(feature, query);
68: }
69:
70: // javadoc is inherited
71: public int getSupportLevel(Constraint constraint, SearchQuery query)
72: throws SearchQueryException {
73: return successor.getSupportLevel(constraint, query);
74: }
75:
76: // javadoc is inherited
77: public String getAllowedValue(String value) {
78: return successor.getAllowedValue(value);
79: }
80:
81: /**
82: * Accessor to successor in chain of responsibility.
83: *
84: * @return The successor.
85: */
86: protected SqlHandler getSuccessor() {
87: return successor;
88: }
89:
90: }
|