001: /**
002: * Copyright (C) 2001-2004 France Telecom R&D
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package org.objectweb.speedo.genclass.map;
018:
019: import org.objectweb.speedo.genclass.api.SpeedoGenClassPO;
020: import org.objectweb.speedo.mim.api.StateItf;
021:
022: import java.util.Map;
023: import java.util.Enumeration;
024: import java.util.Collections;
025: import java.util.Set;
026: import java.util.Collection;
027: import java.util.Hashtable;
028:
029: /**
030: *
031: * @author S.Chassande-Barrioz
032: */
033: public abstract class HashtableImpl extends Hashtable implements
034: SpeedoGenClassPO {
035:
036: public HashtableImpl() {
037: super ();
038: accessor = (MapAccessor) speedoCreateState();
039: }
040:
041: public synchronized String toString() {
042: return "";
043: }
044:
045: MapAccessor accessor;
046:
047: public StateItf speedoGetReferenceState() {
048: return accessor;
049: }
050:
051: public void speedoSetReferenceState(StateItf refAcc) {
052: accessor = (MapAccessor) refAcc;
053: }
054:
055: public Object createGenClass() {
056: return new Hashtable();
057: }
058:
059: public StateItf speedoCreateState() {
060: return new MapAccessor(this );
061: }
062:
063: // IMPLEMENTS THE HashSet CLASS //
064: //------------------------------//
065:
066: public int size() {
067: if (!speedoIsActive()) {
068: return accessor.size();
069: } else {
070: MapAccessor ma = (MapAccessor) speedoGetHome()
071: .readIntention(this , null);
072: return ma.size();
073: }
074: }
075:
076: public boolean isEmpty() {
077: if (!speedoIsActive()) {
078: return accessor.isEmpty();
079: } else {
080: MapAccessor ma = (MapAccessor) speedoGetHome()
081: .readIntention(this , null);
082: return ma.isEmpty();
083: }
084: }
085:
086: public synchronized Enumeration keys() {
087: return Collections.enumeration(entrySet());
088: }
089:
090: public synchronized Enumeration elements() {
091: return Collections.enumeration(values());
092: }
093:
094: public synchronized boolean contains(Object o) {
095: return containsKey(o);
096: }
097:
098: public boolean containsValue(Object o) {
099: if (!speedoIsActive()) {
100: return accessor.containsValue(o);
101: } else {
102: MapAccessor ma = (MapAccessor) speedoGetHome()
103: .readIntention(this , null);
104: return ma.containsValue(o);
105: }
106: }
107:
108: public synchronized boolean containsKey(Object o) {
109: if (!speedoIsActive()) {
110: return accessor.containsKey(o);
111: } else {
112: MapAccessor ma = (MapAccessor) speedoGetHome()
113: .readIntention(this , null);
114: return ma.containsKey(o);
115: }
116: }
117:
118: public synchronized Object get(Object o) {
119: if (!speedoIsActive()) {
120: return accessor.get(o);
121: } else {
122: MapAccessor ma = (MapAccessor) speedoGetHome()
123: .readIntention(this , null);
124: return ma.get(o);
125: }
126: }
127:
128: protected void rehash() {
129: }
130:
131: public synchronized Object put(Object o, Object o1) {
132: if (!speedoIsActive()) {
133: return accessor.put(o, o1);
134: } else {
135: MapAccessor ma = (MapAccessor) speedoGetHome()
136: .writeIntention(this , null);
137: return ma.put(o, o1);
138: }
139: }
140:
141: public synchronized Object remove(Object o) {
142: if (!speedoIsActive()) {
143: return accessor.remove(o);
144: } else {
145: MapAccessor ma = (MapAccessor) speedoGetHome()
146: .writeIntention(this , null);
147: return ma.remove(o);
148: }
149: }
150:
151: public synchronized void putAll(Map map) {
152: if (!speedoIsActive()) {
153: accessor.putAll(map);
154: } else {
155: MapAccessor ma = (MapAccessor) speedoGetHome()
156: .writeIntention(this , null);
157: ma.putAll(map);
158: }
159: }
160:
161: public synchronized void clear() {
162: if (!speedoIsActive()) {
163: accessor.clear();
164: } else {
165: MapAccessor ma = (MapAccessor) speedoGetHome()
166: .writeIntention(this , null);
167: ma.clear();
168: }
169: }
170:
171: public Set keySet() {
172: if (!speedoIsActive()) {
173: return accessor.keySet();
174: } else {
175: MapAccessor ma = (MapAccessor) speedoGetHome()
176: .readIntention(this , null);
177: return ma.keySet();
178: }
179: }
180:
181: public Set entrySet() {
182: if (!speedoIsActive()) {
183: return accessor.entrySet();
184: } else {
185: MapAccessor ma = (MapAccessor) speedoGetHome()
186: .readIntention(this , null);
187: return ma.entrySet();
188: }
189: }
190:
191: public Collection values() {
192: if (!speedoIsActive()) {
193: return accessor.values();
194: } else {
195: MapAccessor ma = (MapAccessor) speedoGetHome()
196: .readIntention(this, null);
197: return ma.values();
198: }
199: }
200: }
|