01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.test.types;
22:
23: import java.util.*;
24:
25: import com.db4o.*;
26: import com.db4o.foundation.*;
27: import com.db4o.test.*;
28:
29: public class RHashtable implements RTestable {
30:
31: public Object newInstance() {
32: return new Hashtable();
33: }
34:
35: public Object set(Object obj, int ver) {
36: TEntry[] arr = new TEntry().test(ver);
37: Hashtable ht = (Hashtable) obj;
38: ht.clear();
39: for (int i = 0; i < arr.length; i++) {
40: ht.put(arr[i].key, arr[i].value);
41: }
42: return obj;
43: }
44:
45: public void compare(ObjectContainer con, Object obj, int ver) {
46: Hashtable ht = (Hashtable) obj;
47: TEntry[] entries = new TEntry[ht.size()];
48: Enumeration enu = ht.keys();
49: int i = 0;
50: while (enu.hasMoreElements()) {
51: entries[i] = new TEntry();
52: entries[i].key = enu.nextElement();
53: i++;
54: }
55: for (i = 0; i < entries.length; i++) {
56: entries[i].value = ht.get(entries[i].key);
57: }
58: new TEntry().compare(entries, ver, false);
59: }
60:
61: public void specific(ObjectContainer con, int step) {
62: TEntry entry = new TEntry().firstElement();
63: Hashtable ht = (Hashtable) newInstance();
64: if (step > 0) {
65: ht.put(entry.key, entry.value);
66: ObjectSet set = con.get(ht);
67: Collection4 col = new Collection4();
68: while (set.hasNext()) {
69: Object obj = set.next();
70: if (obj.getClass() == ht.getClass()) {
71: col.add(obj);
72: }
73: }
74: if (col.size() != step) {
75: Regression.addError("Hashtable member query not found");
76: }
77: }
78: entry = new TEntry().noElement();
79: ht.put(entry.key, entry.value);
80: if (con.get(ht).size() != 0) {
81: Regression
82: .addError("Hashtable member query found too many");
83: }
84: }
85:
86: public boolean jdk2() {
87: return false;
88: }
89:
90: public boolean ver3() {
91: return false;
92: }
93:
94: }
|