KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > AbstractQueryContext


1 /**
2  * com.mckoi.database.AbstractQueryContext 25 Mar 2002
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database;
26
27 import java.util.HashMap JavaDoc;
28
29 /**
30  * An abstract implementation of QueryContext
31  *
32  * @author Tobias Downer
33  */

34
35 public abstract class AbstractQueryContext implements QueryContext {
36
37   /**
38    * Any marked tables that are made during the evaluation of a query plan.
39    * (String) -> (Table)
40    */

41   private HashMap JavaDoc marked_tables;
42
43
44   /**
45    * Marks a table in a query plan.
46    */

47   public void addMarkedTable(String JavaDoc mark_name, Table table) {
48     if (marked_tables == null) {
49       marked_tables = new HashMap JavaDoc();
50     }
51     marked_tables.put(mark_name, table);
52   }
53
54   /**
55    * Returns a table that was marked in a query plan or null if no mark was
56    * found.
57    */

58   public Table getMarkedTable(String JavaDoc mark_name) {
59     if (marked_tables == null) {
60       return null;
61     }
62     return (Table) marked_tables.get(mark_name);
63   }
64
65   /**
66    * Put a Table into the cache.
67    */

68   public void putCachedNode(long id, Table table) {
69     if (marked_tables == null) {
70       marked_tables = new HashMap JavaDoc();
71     }
72     marked_tables.put(new Long JavaDoc(id), table);
73   }
74
75   /**
76    * Returns a cached table or null if it isn't cached.
77    */

78   public Table getCachedNode(long id) {
79     if (marked_tables == null) {
80       return null;
81     }
82     return (Table) marked_tables.get(new Long JavaDoc(id));
83   }
84
85   /**
86    * Clears the cache of any cached tables.
87    */

88   public void clearCache() {
89     if (marked_tables != null) {
90       marked_tables.clear();
91     }
92   }
93
94 }
95
Popular Tags