KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > util > UnmodifiableVector


1 package org.jgroups.util;
2
3 import java.util.*;
4
5 /**
6  * Vector which cannot be modified
7  * @author Bela Ban
8  * @version $Id: UnmodifiableVector.java,v 1.3 2006/12/09 22:59:34 belaban Exp $
9  */

10 public class UnmodifiableVector extends Vector {
11     Vector v;
12
13     public UnmodifiableVector(Vector v) {
14         this.v=v;
15     }
16
17     public synchronized void copyInto(Object JavaDoc[] anArray) {
18         v.copyInto(anArray);
19     }
20
21     public synchronized void trimToSize() {
22         throw new UnsupportedOperationException JavaDoc();
23     }
24
25     public synchronized void ensureCapacity(int minCapacity) {
26         throw new UnsupportedOperationException JavaDoc();
27     }
28
29     public synchronized void setSize(int newSize) {
30         throw new UnsupportedOperationException JavaDoc();
31     }
32
33     public synchronized int capacity() {
34         return v.capacity();
35     }
36
37     public synchronized int size() {
38         return v.size();
39     }
40
41     public synchronized boolean isEmpty() {
42         return v.isEmpty();
43     }
44
45     public Enumeration elements() {
46         return v.elements();
47     }
48
49     public boolean contains(Object JavaDoc elem) {
50         return v.contains(elem);
51     }
52
53     public int indexOf(Object JavaDoc elem) {
54         return v.indexOf(elem);
55     }
56
57     public synchronized int indexOf(Object JavaDoc elem, int index) {
58         return v.indexOf(elem, index);
59     }
60
61     public synchronized int lastIndexOf(Object JavaDoc elem) {
62         return v.lastIndexOf(elem);
63     }
64
65     public synchronized int lastIndexOf(Object JavaDoc elem, int index) {
66         return v.lastIndexOf(elem, index);
67     }
68
69     public synchronized Object JavaDoc elementAt(int index) {
70         return v.elementAt(index);
71     }
72
73     public synchronized Object JavaDoc firstElement() {
74         return v.firstElement();
75     }
76
77     public synchronized Object JavaDoc lastElement() {
78         return v.lastElement();
79     }
80
81     public synchronized void setElementAt(Object JavaDoc obj, int index) {
82         v.setElementAt(obj, index);
83     }
84
85     public synchronized void removeElementAt(int index) {
86         throw new UnsupportedOperationException JavaDoc();
87     }
88
89     public synchronized void insertElementAt(Object JavaDoc obj, int index) {
90         throw new UnsupportedOperationException JavaDoc();
91     }
92
93     public synchronized void addElement(Object JavaDoc obj) {
94         throw new UnsupportedOperationException JavaDoc();
95     }
96
97     public synchronized boolean removeElement(Object JavaDoc obj) {
98         throw new UnsupportedOperationException JavaDoc();
99     }
100
101     public synchronized void removeAllElements() {
102         throw new UnsupportedOperationException JavaDoc();
103     }
104
105     public synchronized Object JavaDoc clone() {
106         return v.clone();
107     }
108
109     public synchronized Object JavaDoc[] toArray() {
110         return v.toArray();
111     }
112
113     public synchronized Object JavaDoc[] toArray(Object JavaDoc[] a) {
114         return v.toArray(a);
115     }
116
117     public synchronized Object JavaDoc get(int index) {
118         return v.get(index);
119     }
120
121     public synchronized Object JavaDoc set(int index, Object JavaDoc element) {
122         throw new UnsupportedOperationException JavaDoc();
123     }
124
125     public synchronized boolean add(Object JavaDoc o) {
126         throw new UnsupportedOperationException JavaDoc();
127     }
128
129     public boolean remove(Object JavaDoc o) {
130         throw new UnsupportedOperationException JavaDoc();
131     }
132
133     public void add(int index, Object JavaDoc element) {
134         throw new UnsupportedOperationException JavaDoc();
135     }
136
137     public synchronized Object JavaDoc remove(int index) {
138         throw new UnsupportedOperationException JavaDoc();
139     }
140
141     public void clear() {
142         throw new UnsupportedOperationException JavaDoc();
143     }
144
145     public synchronized boolean containsAll(Collection c) {
146         return v.containsAll(c);
147     }
148
149     public synchronized boolean addAll(Collection c) {
150         throw new UnsupportedOperationException JavaDoc();
151     }
152
153     public synchronized boolean removeAll(Collection c) {
154         throw new UnsupportedOperationException JavaDoc();
155     }
156
157     public synchronized boolean retainAll(Collection c) {
158         throw new UnsupportedOperationException JavaDoc();
159     }
160
161     public synchronized boolean addAll(int index, Collection c) {
162         throw new UnsupportedOperationException JavaDoc();
163     }
164
165     public synchronized boolean equals(Object JavaDoc o) {
166         return v.equals(o);
167     }
168
169     public synchronized int hashCode() {
170         return v.hashCode();
171     }
172
173     public synchronized String JavaDoc toString() {
174         return v.toString();
175     }
176
177     public synchronized java.util.List JavaDoc subList(int fromIndex, int toIndex) {
178         return v.subList(fromIndex, toIndex);
179     }
180
181     public ListIterator listIterator() {
182         return new ListIterator() {
183             ListIterator i = v.listIterator();
184
185             public boolean hasNext() {return i.hasNext();}
186             public Object JavaDoc next() {return i.next();}
187
188             public boolean hasPrevious() {
189                 return i.hasPrevious();
190             }
191
192             public Object JavaDoc previous() {
193                 return i.previous();
194             }
195
196             public int nextIndex() {
197                 return i.nextIndex();
198             }
199
200             public int previousIndex() {
201                 return i.previousIndex();
202             }
203
204             public void remove() {
205                 throw new UnsupportedOperationException JavaDoc();
206             }
207
208             public void set(Object JavaDoc o) {
209                 throw new UnsupportedOperationException JavaDoc();
210             }
211
212             public void add(Object JavaDoc o) {
213                 throw new UnsupportedOperationException JavaDoc();
214             }
215         };
216     }
217
218     public ListIterator listIterator(final int index) {
219         return new ListIterator() {
220             ListIterator i = v.listIterator(index);
221
222             public boolean hasNext() {return i.hasNext();}
223             public Object JavaDoc next() {return i.next();}
224
225             public boolean hasPrevious() {
226                 return i.hasPrevious();
227             }
228
229             public Object JavaDoc previous() {
230                 return i.previous();
231             }
232
233             public int nextIndex() {
234                 return i.nextIndex();
235             }
236
237             public int previousIndex() {
238                 return i.previousIndex();
239             }
240
241             public void remove() {
242                 throw new UnsupportedOperationException JavaDoc();
243             }
244
245             public void set(Object JavaDoc o) {
246                 throw new UnsupportedOperationException JavaDoc();
247             }
248
249             public void add(Object JavaDoc o) {
250                 throw new UnsupportedOperationException JavaDoc();
251             }
252         };
253     }
254
255
256     public Iterator iterator() {
257         return new Iterator() {
258             Iterator i = v.iterator();
259
260             public boolean hasNext() {return i.hasNext();}
261             public Object JavaDoc next() {return i.next();}
262             public void remove() {
263                 throw new UnsupportedOperationException JavaDoc();
264             }
265         };
266     }
267 }
268
Popular Tags