KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > genclass > map > TreeMapImpl


1 /**
2  * Copyright (C) 2001-2004 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package org.objectweb.speedo.genclass.map;
19
20 import org.objectweb.speedo.genclass.api.SpeedoGenClassProxy;
21 import org.objectweb.speedo.mim.api.SpeedoAccessor;
22
23 import java.util.TreeMap JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.Set JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.Comparator JavaDoc;
28 import java.util.SortedMap JavaDoc;
29
30 /**
31  *
32  * @author S.Chassande-Barrioz
33  */

34 public abstract class TreeMapImpl extends TreeMap JavaDoc
35         implements SpeedoGenClassProxy {
36
37     public TreeMapImpl() {
38         super();
39         accessor = (MapAccessor) createAccessor();
40     }
41
42     public String JavaDoc toString() {
43         return "";
44     }
45
46     MapAccessor accessor;
47
48     public SpeedoAccessor getReferenceAccessor() {
49         return accessor;
50     }
51     public void setReferenceAccessor(SpeedoAccessor refAcc) {
52         accessor = (MapAccessor) refAcc;
53     }
54
55     public Object JavaDoc createGenClass() {
56         return new TreeMap JavaDoc();
57     }
58
59     public SpeedoAccessor createAccessor() {
60         return new MapAccessor(this);
61     }
62
63     // IMPLEMENTS THE HashSet CLASS //
64
//------------------------------//
65

66     public int size() {
67         if (!jdoIsActive()) {
68             return accessor.size();
69         } else {
70             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
71             return ma.size();
72         }
73     }
74
75     public boolean isEmpty() {
76         if (!jdoIsActive()) {
77             return accessor.isEmpty();
78         } else {
79             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
80             return ma.isEmpty();
81         }
82     }
83
84     public boolean containsValue(Object JavaDoc o) {
85         if (!jdoIsActive()) {
86             return accessor.containsValue(o);
87         } else {
88             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
89             return ma.containsValue(o);
90         }
91     }
92
93     public synchronized boolean containsKey(Object JavaDoc o) {
94         if (!jdoIsActive()) {
95             return accessor.containsKey(o);
96         } else {
97             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
98             return ma.containsKey(o);
99         }
100     }
101
102     public synchronized Object JavaDoc get(Object JavaDoc o) {
103         if (!jdoIsActive()) {
104             return accessor.get(o);
105         } else {
106             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
107             return ma.get(o);
108         }
109     }
110
111     public synchronized Object JavaDoc put(Object JavaDoc o, Object JavaDoc o1) {
112         if (!jdoIsActive()) {
113             return accessor.put(o, o1);
114         } else {
115             MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null);
116             return ma.put(o, o1);
117         }
118     }
119
120     public synchronized Object JavaDoc remove(Object JavaDoc o) {
121         if (!jdoIsActive()) {
122             return accessor.remove(o);
123         } else {
124             MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null);
125             return ma.remove(o);
126         }
127     }
128
129     public synchronized void putAll(Map JavaDoc map) {
130         if (!jdoIsActive()) {
131             accessor.putAll(map);
132         } else {
133             MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null);
134             ma.putAll(map);
135         }
136     }
137
138     public synchronized void clear() {
139         if (!jdoIsActive()) {
140             accessor.clear();
141         } else {
142             MapAccessor ma = (MapAccessor) getSpeedoHome().writeIntention(this, null);
143             ma.clear();
144         }
145     }
146
147     public Set JavaDoc keySet() {
148         if (!jdoIsActive()) {
149             return accessor.keySet();
150         } else {
151             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
152             return ma.keySet();
153         }
154     }
155
156     public Set JavaDoc entrySet() {
157         if (!jdoIsActive()) {
158             return accessor.entrySet();
159         } else {
160             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
161             return ma.entrySet();
162         }
163     }
164
165     public Collection JavaDoc values() {
166         if (!jdoIsActive()) {
167             return accessor.values();
168         } else {
169             MapAccessor ma = (MapAccessor) getSpeedoHome().readIntention(this, null);
170             return ma.values();
171         }
172     }
173
174     public Comparator JavaDoc comparator() {
175         throw new UnsupportedOperationException JavaDoc();
176     }
177
178     public Object JavaDoc firstKey() {
179         throw new UnsupportedOperationException JavaDoc();
180     }
181
182     public Object JavaDoc lastKey() {
183         throw new UnsupportedOperationException JavaDoc();
184     }
185
186     public Object JavaDoc clone() {
187         throw new UnsupportedOperationException JavaDoc();
188     }
189
190     public SortedMap JavaDoc subMap(Object JavaDoc fromKey, Object JavaDoc toKey) {
191         throw new UnsupportedOperationException JavaDoc();
192     }
193
194     public SortedMap JavaDoc headMap(Object JavaDoc toKey) {
195         throw new UnsupportedOperationException JavaDoc();
196     }
197
198     public SortedMap JavaDoc tailMap(Object JavaDoc fromKey) {
199         throw new UnsupportedOperationException JavaDoc();
200     }
201
202 }
203
Popular Tags