01: package net.sourceforge.squirrel_sql.client.session.sqlfilter;
02:
03: /*
04: * Copyright (C) 2003-2004 Maury Hammel
05: * mjhammel@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.io.Serializable;
22: import java.util.HashMap;
23:
24: /**
25: * This class contains the information used to build the Where and Order By
26: * clauses used by the database query triggered by selecting the Contents tab
27: * in the Session internal frame.
28: *
29: */
30: public class SQLFilterClauses implements Serializable {
31: private static final long serialVersionUID = 1L;
32:
33: /** The container for the SQL filter information */
34: HashMap<String, HashMap<String, String>> _sqlClauseInformation;
35:
36: /**
37: * Creates a new instance of SQLFilterClauses.
38: */
39: public SQLFilterClauses() {
40: _sqlClauseInformation = new HashMap<String, HashMap<String, String>>();
41: }
42:
43: /**
44: * Return the value of the SQL filter information
45: *
46: * @param clauseName The name of the clause for which the information is
47: * required.
48: * @param tableName The database table name for which the information is required.
49: *
50: * @return A string value containing the requested information
51: */
52: public String get(String clauseName, String tableName) {
53: HashMap<String, String> filterData = _sqlClauseInformation
54: .get(tableName);
55: return (filterData == null) ? null : filterData.get(clauseName);
56: }
57:
58: /**
59: * Update (or create) SQL Filter information for a session.
60: *
61: * @param clauseName The name of the clause for which the information pertains.
62: * @param tableName The name of the database table for the filter information.
63: *
64: * @param clauseInformation The SQL filter information to be saved.
65: */
66: public void put(String clauseName, String tableName,
67: String clauseInformation) {
68: HashMap<String, String> filterData = _sqlClauseInformation
69: .get(tableName);
70: if (filterData == null) {
71: filterData = new HashMap<String, String>();
72: }
73: filterData.put(clauseName, clauseInformation);
74: _sqlClauseInformation.put(tableName, filterData);
75: }
76: }
|