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.TreeMap;
023: import java.util.Map;
024: import java.util.Set;
025: import java.util.Collection;
026: import java.util.Comparator;
027: import java.util.SortedMap;
028:
029: /**
030: *
031: * @author S.Chassande-Barrioz
032: */
033: public abstract class TreeMapImpl extends TreeMap implements
034: SpeedoGenClassPO {
035:
036: public TreeMapImpl() {
037: super ();
038: accessor = (MapAccessor) speedoCreateState();
039: }
040:
041: public 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 TreeMap();
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 boolean containsValue(Object o) {
087: if (!speedoIsActive()) {
088: return accessor.containsValue(o);
089: } else {
090: MapAccessor ma = (MapAccessor) speedoGetHome()
091: .readIntention(this , null);
092: return ma.containsValue(o);
093: }
094: }
095:
096: public synchronized boolean containsKey(Object o) {
097: if (!speedoIsActive()) {
098: return accessor.containsKey(o);
099: } else {
100: MapAccessor ma = (MapAccessor) speedoGetHome()
101: .readIntention(this , null);
102: return ma.containsKey(o);
103: }
104: }
105:
106: public synchronized Object get(Object o) {
107: if (!speedoIsActive()) {
108: return accessor.get(o);
109: } else {
110: MapAccessor ma = (MapAccessor) speedoGetHome()
111: .readIntention(this , null);
112: return ma.get(o);
113: }
114: }
115:
116: public synchronized Object put(Object o, Object o1) {
117: if (!speedoIsActive()) {
118: return accessor.put(o, o1);
119: } else {
120: MapAccessor ma = (MapAccessor) speedoGetHome()
121: .writeIntention(this , null);
122: return ma.put(o, o1);
123: }
124: }
125:
126: public synchronized Object remove(Object o) {
127: if (!speedoIsActive()) {
128: return accessor.remove(o);
129: } else {
130: MapAccessor ma = (MapAccessor) speedoGetHome()
131: .writeIntention(this , null);
132: return ma.remove(o);
133: }
134: }
135:
136: public synchronized void putAll(Map map) {
137: if (!speedoIsActive()) {
138: accessor.putAll(map);
139: } else {
140: MapAccessor ma = (MapAccessor) speedoGetHome()
141: .writeIntention(this , null);
142: ma.putAll(map);
143: }
144: }
145:
146: public synchronized void clear() {
147: if (!speedoIsActive()) {
148: accessor.clear();
149: } else {
150: MapAccessor ma = (MapAccessor) speedoGetHome()
151: .writeIntention(this , null);
152: ma.clear();
153: }
154: }
155:
156: public Set keySet() {
157: if (!speedoIsActive()) {
158: return accessor.keySet();
159: } else {
160: MapAccessor ma = (MapAccessor) speedoGetHome()
161: .readIntention(this , null);
162: return ma.keySet();
163: }
164: }
165:
166: public Set entrySet() {
167: if (!speedoIsActive()) {
168: return accessor.entrySet();
169: } else {
170: MapAccessor ma = (MapAccessor) speedoGetHome()
171: .readIntention(this , null);
172: return ma.entrySet();
173: }
174: }
175:
176: public Collection values() {
177: if (!speedoIsActive()) {
178: return accessor.values();
179: } else {
180: MapAccessor ma = (MapAccessor) speedoGetHome()
181: .readIntention(this , null);
182: return ma.values();
183: }
184: }
185:
186: public Comparator comparator() {
187: throw new UnsupportedOperationException();
188: }
189:
190: public Object firstKey() {
191: throw new UnsupportedOperationException();
192: }
193:
194: public Object lastKey() {
195: throw new UnsupportedOperationException();
196: }
197:
198: public Object clone() {
199: throw new UnsupportedOperationException();
200: }
201:
202: public SortedMap subMap(Object fromKey, Object toKey) {
203: throw new UnsupportedOperationException();
204: }
205:
206: public SortedMap headMap(Object toKey) {
207: throw new UnsupportedOperationException();
208: }
209:
210: public SortedMap tailMap(Object fromKey) {
211: throw new UnsupportedOperationException();
212: }
213:
214: }
|