001: ///////////////////////////////////////////////////////////////////////////////
002: //
003: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
004: //
005: // All Rights Reserved
006: //
007: // This program is free software; you can redistribute it and/or modify
008: // it under the terms of the GNU General Public License and GNU Library
009: // General Public License as published by the Free Software Foundation;
010: // either version 2, or (at your option) any later version.
011: //
012: // This program is distributed in the hope that it will be useful,
013: // but WITHOUT ANY WARRANTY; without even the implied warranty of
014: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: // GNU General Public License and GNU Library General Public License
016: // for more details.
017: //
018: // You should have received a copy of the GNU General Public License
019: // and GNU Library General Public License along with this program; if
020: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
021: // MA 02139, USA.
022: //
023: ///////////////////////////////////////////////////////////////////////////////
024: package org.myoodb.collectable;
025:
026: public class HashMapDbImpl extends CollectableDbImpl implements HashMap {
027: private java.util.HashMap m_hashMap;
028:
029: public HashMapDbImpl() {
030: m_hashMap = new java.util.HashMap();
031: }
032:
033: public HashMapDbImpl(int initialCapacity) {
034: m_hashMap = new java.util.HashMap(initialCapacity);
035: }
036:
037: public HashMapDbImpl(int initialCapacity, float loadFactor) {
038: m_hashMap = new java.util.HashMap(initialCapacity, loadFactor);
039: }
040:
041: public void fixUpReference(long fixUpTime) {
042: if (referenceHasBeenFixedUp(fixUpTime) == true) {
043: return;
044: }
045:
046: super .fixUpReference(fixUpTime);
047:
048: synchronized (m_hashMap) {
049: CollectableDbImpl.fixUpReference(m_hashMap, fixUpTime);
050: }
051: }
052:
053: public Object put(Object key, Object value) {
054: Object retval = null;
055:
056: synchronized (m_hashMap) {
057: retval = m_hashMap.put(key, value);
058: }
059:
060: return retval;
061: }
062:
063: public void putAll(java.util.Map map) {
064: synchronized (m_hashMap) {
065: m_hashMap.putAll(map);
066: }
067: }
068:
069: public Object get(Object key) {
070: Object retval = null;
071:
072: synchronized (m_hashMap) {
073: retval = m_hashMap.get(key);
074: }
075:
076: return retval;
077: }
078:
079: public Object remove(Object key) {
080: Object retval = null;
081:
082: synchronized (m_hashMap) {
083: retval = m_hashMap.remove(key);
084: }
085:
086: return retval;
087: }
088:
089: public void clear() {
090: synchronized (m_hashMap) {
091: m_hashMap.clear();
092: }
093: }
094:
095: public int size() {
096: int retval = -1;
097:
098: synchronized (m_hashMap) {
099: retval = m_hashMap.size();
100: }
101:
102: return retval;
103: }
104:
105: public String toString() {
106: String retval = null;
107:
108: synchronized (m_hashMap) {
109: retval = m_hashMap.toString();
110: }
111:
112: return retval;
113: }
114:
115: public boolean equals(Object obj) {
116: boolean retval = false;
117:
118: synchronized (m_hashMap) {
119: retval = m_hashMap.equals(obj);
120: }
121:
122: return retval;
123: }
124:
125: public java.util.HashSet keySet() {
126: java.util.HashSet retval = null;
127:
128: synchronized (m_hashMap) {
129: retval = new java.util.HashSet(m_hashMap.keySet());
130: }
131:
132: return retval;
133: }
134:
135: public java.util.HashSet entrySet() {
136: java.util.HashSet retval = null;
137:
138: synchronized (m_hashMap) {
139: retval = new java.util.HashSet(m_hashMap.entrySet());
140: }
141:
142: return retval;
143: }
144:
145: public java.util.Collection values() {
146: java.util.Collection retval = null;
147:
148: synchronized (m_hashMap) {
149: retval = m_hashMap.values();
150: }
151:
152: return retval;
153: }
154:
155: public java.util.HashMap collection() {
156: return m_hashMap;
157: }
158:
159: public java.util.ArrayList toArrayList() {
160: java.util.ArrayList retval = null;
161:
162: synchronized (m_hashMap) {
163: retval = new java.util.ArrayList(m_hashMap.values());
164: }
165:
166: return retval;
167: }
168:
169: public Iterator iterator() {
170: return (Iterator) getDatabase().createObject(
171: IteratorDbImpl.class.getName(), "java.util.Collection",
172: new Object[] { m_hashMap });
173: }
174: }
|