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.foundation;
22:
23: /**
24: * @exclude
25: */
26: public class KeySpecHashtable4 {
27:
28: private SynchronizedHashtable4 _delegate;
29:
30: private KeySpecHashtable4(SynchronizedHashtable4 delegate_) {
31: _delegate = delegate_;
32: }
33:
34: public KeySpecHashtable4(int size) {
35: this (new SynchronizedHashtable4(size));
36: }
37:
38: public void put(KeySpec spec, byte value) {
39: _delegate.put(spec, new Byte(value));
40: }
41:
42: public void put(KeySpec spec, boolean value) {
43: _delegate.put(spec, new Boolean(value));
44: }
45:
46: public void put(KeySpec spec, int value) {
47: _delegate.put(spec, new Integer(value));
48: }
49:
50: public void put(KeySpec spec, Object value) {
51: _delegate.put(spec, value);
52: }
53:
54: public byte getAsByte(KeySpec spec) {
55: return ((Byte) get(spec)).byteValue();
56: }
57:
58: public boolean getAsBoolean(KeySpec spec) {
59: return ((Boolean) get(spec)).booleanValue();
60: }
61:
62: public int getAsInt(KeySpec spec) {
63: return ((Integer) get(spec)).intValue();
64: }
65:
66: public TernaryBool getAsTernaryBool(KeySpec spec) {
67: return (TernaryBool) get(spec);
68: }
69:
70: public String getAsString(KeySpec spec) {
71: return (String) get(spec);
72: }
73:
74: public synchronized Object get(KeySpec spec) {
75: Object value = _delegate.get(spec);
76: if (value == null) {
77: value = spec.defaultValue();
78: if (value != null) {
79: _delegate.put(spec, value);
80: }
81: }
82: return value;
83: }
84:
85: public Object deepClone(Object obj) {
86: return new KeySpecHashtable4((SynchronizedHashtable4) _delegate
87: .deepClone(obj));
88: }
89: }
|