01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.rdbm;
07:
08: import java.sql.SQLException;
09: import java.util.Hashtable;
10: import java.util.Map;
11:
12: /**
13: * Partial implemenation of {@link IJoinQueryString} which provides
14: * the implemention of storing and retrieving join queries. It also
15: * requires a test query be specified.
16: *
17: * @author Eric Dalquist <a href="mailto:edalquist@unicon.net">edalquist@unicon.net</a>
18: * @version $Revision: 34769 $ $Date: 2004-10-17 12:43:50 -0700 (Sun, 17 Oct 2004) $
19: */
20: public abstract class JoinQueryString implements IJoinQueryString {
21:
22: final private Map queryStrings = new Hashtable();
23:
24: final private String testJoin;
25:
26: /**
27: * Creates a new {@link JoinQueryString}.
28: *
29: * @param testQuery The query to use to test if joins in the class are supported.
30: */
31: protected JoinQueryString(final String testQuery) {
32: if (testQuery == null)
33: throw new IllegalArgumentException(
34: "testQuery must not be null");
35:
36: testJoin = testQuery;
37: }
38:
39: /**
40: * Gets the query to use to test if joins in this class are supported.
41: *
42: * @return The query to use to test if joins in this class are supported.
43: */
44: protected String getTestJoin() {
45: return testJoin;
46: }
47:
48: /**
49: * @see org.jasig.portal.rdbm.IJoinQueryString#getQuery(java.lang.String)
50: */
51: public String getQuery(final String key) throws SQLException {
52: final String query = (String) queryStrings.get(key);
53:
54: if (query == null) {
55: throw new SQLException("Missing query");
56: }
57:
58: return query;
59: }
60:
61: /**
62: * @see org.jasig.portal.rdbm.IJoinQueryString#addQuery(java.lang.String, java.lang.String)
63: */
64: public void addQuery(final String key, final String value)
65: throws SQLException {
66: queryStrings.put(key, value);
67: }
68: }
|