KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > storage > search > implementation > database > ChainedSqlHandler


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

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.5 2005/01/25 12:45:19 pierre 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 JavaDoc toSql(SearchQuery query, SqlHandler firstInChain)
45     throws SearchQueryException {
46         return successor.toSql(query, firstInChain);
47     }
48
49     // javadoc is inherited
50
public void appendQueryBodyToSql(
51     StringBuffer JavaDoc sb, SearchQuery query, SqlHandler firstInChain)
52     throws SearchQueryException {
53         successor.appendQueryBodyToSql(sb, query, firstInChain);
54     }
55
56     // javadoc is inherited
57
public void appendConstraintToSql(StringBuffer JavaDoc sb, Constraint constraint,
58     SearchQuery query, boolean inverse, boolean inComposite)
59     throws SearchQueryException {
60         successor.appendConstraintToSql(sb, constraint, query,
61         inverse, 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 JavaDoc getAllowedValue(String JavaDoc 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 }
91
Popular Tags