1 /***
2 Cache - Load data from source tables (or select statements) and puts them into
3 Hatshtable (cache).
4
5 Copyright (C) 2002-2003 Together
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 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 Cache.java
22 Date: 23.01.2003.
23 @version 1.0.0
24 @author: Milosevic Sinisa sinisa@prozone.co.yu
25 */
26
27 package org.webdocwf.util.loader;
28
29
30 import java.util.Hashtable;
31 import java.util.Vector;
32 import java.math.BigDecimal;
33
34 /***
35 Cache - Load data from source tables (or select statements) and puts them into
36 Hatshtable (cache).
37 */
38 public class Cache {
39
40 private Hashtable hCache=null;
41
42 /***
43 * Public constructor of cache class.
44 * Constructor create new hashtable
45 */
46 public Cache() {
47 this.hCache=new Hashtable();
48 }
49
50 /***
51 * Public constructor of cache class.
52 * Constructor set cache table.
53 * @param Hashtable cache table.
54 */
55 public Cache(Hashtable cache) {
56 this.hCache=cache;
57 }
58
59 /***
60 * Read current cache table
61 */
62 public Hashtable getCache() {
63 return this.hCache;
64 }
65
66 /***
67 * Set cache table.
68 * @param Hashtable cache table
69 */
70 public void setCache(Hashtable cache) {
71 this.hCache=cache;
72 }
73
74 /***
75 * Put row of source values into cache.
76 * @param BigDecimal SQL query row
77 * @param Vector source values
78 */
79 public void setCacheRow(BigDecimal row, Vector sourceValues) {
80 this.hCache.put(row,sourceValues);
81 }
82
83 /***
84 * Put row of source values into cache.
85 * @param Hashtable cache table
86 * @param BigDecimal SQL query row
87 * @param Vector source values
88 */
89 public void setCacheRow(Hashtable cache, BigDecimal row, Vector sourceValues) {
90 cache.put(row,sourceValues);
91 }
92
93 /***
94 * Read row of source values.
95 * @param BigDecimal SQL query row.
96 * @return Vector values of source columns.
97 */
98 public Vector getCacheRow(BigDecimal row) {
99 if(this.hCache.isEmpty())
100 return null;
101 else
102 return (Vector)this.hCache.get(row);
103 }
104
105 /***
106 * Read row of source values.
107 * @param BigDecimal SQL query row.
108 * @param Hashtable cache table
109 * @return Vector values of source columns.
110 */
111 public Vector getCacheRow(Hashtable cache, BigDecimal row) {
112 if(cache.isEmpty())
113 return null;
114 else
115 return (Vector)cache.get(row);
116 }
117
118 /***
119 * Reset cache.
120 */
121 public void resetCache() {
122 this.hCache.clear();
123 this.hCache=new Hashtable();
124 }
125
126 }
This page automatically generated by Maven