001: package org.jgroups.util;
002:
003: import java.util.*;
004:
005: /**
006: * Vector which cannot be modified
007: * @author Bela Ban
008: * @version $Id: UnmodifiableVector.java,v 1.1.2.2 2006/12/09 23:00:01 belaban Exp $
009: */
010: public class UnmodifiableVector extends Vector {
011: Vector v;
012:
013: public UnmodifiableVector(Vector v) {
014: this .v = v;
015: }
016:
017: public synchronized void copyInto(Object[] anArray) {
018: v.copyInto(anArray);
019: }
020:
021: public synchronized void trimToSize() {
022: throw new UnsupportedOperationException();
023: }
024:
025: public synchronized void ensureCapacity(int minCapacity) {
026: throw new UnsupportedOperationException();
027: }
028:
029: public synchronized void setSize(int newSize) {
030: throw new UnsupportedOperationException();
031: }
032:
033: public synchronized int capacity() {
034: return v.capacity();
035: }
036:
037: public synchronized int size() {
038: return v.size();
039: }
040:
041: public synchronized boolean isEmpty() {
042: return v.isEmpty();
043: }
044:
045: public Enumeration elements() {
046: return v.elements();
047: }
048:
049: public boolean contains(Object elem) {
050: return v.contains(elem);
051: }
052:
053: public int indexOf(Object elem) {
054: return v.indexOf(elem);
055: }
056:
057: public synchronized int indexOf(Object elem, int index) {
058: return v.indexOf(elem, index);
059: }
060:
061: public synchronized int lastIndexOf(Object elem) {
062: return v.lastIndexOf(elem);
063: }
064:
065: public synchronized int lastIndexOf(Object elem, int index) {
066: return v.lastIndexOf(elem, index);
067: }
068:
069: public synchronized Object elementAt(int index) {
070: return v.elementAt(index);
071: }
072:
073: public synchronized Object firstElement() {
074: return v.firstElement();
075: }
076:
077: public synchronized Object lastElement() {
078: return v.lastElement();
079: }
080:
081: public synchronized void setElementAt(Object obj, int index) {
082: v.setElementAt(obj, index);
083: }
084:
085: public synchronized void removeElementAt(int index) {
086: throw new UnsupportedOperationException();
087: }
088:
089: public synchronized void insertElementAt(Object obj, int index) {
090: throw new UnsupportedOperationException();
091: }
092:
093: public synchronized void addElement(Object obj) {
094: throw new UnsupportedOperationException();
095: }
096:
097: public synchronized boolean removeElement(Object obj) {
098: throw new UnsupportedOperationException();
099: }
100:
101: public synchronized void removeAllElements() {
102: throw new UnsupportedOperationException();
103: }
104:
105: public synchronized Object clone() {
106: return v.clone();
107: }
108:
109: public synchronized Object[] toArray() {
110: return v.toArray();
111: }
112:
113: public synchronized Object[] toArray(Object[] a) {
114: return v.toArray(a);
115: }
116:
117: public synchronized Object get(int index) {
118: return v.get(index);
119: }
120:
121: public synchronized Object set(int index, Object element) {
122: throw new UnsupportedOperationException();
123: }
124:
125: public synchronized boolean add(Object o) {
126: throw new UnsupportedOperationException();
127: }
128:
129: public boolean remove(Object o) {
130: throw new UnsupportedOperationException();
131: }
132:
133: public void add(int index, Object element) {
134: throw new UnsupportedOperationException();
135: }
136:
137: public synchronized Object remove(int index) {
138: throw new UnsupportedOperationException();
139: }
140:
141: public void clear() {
142: throw new UnsupportedOperationException();
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();
151: }
152:
153: public synchronized boolean removeAll(Collection c) {
154: throw new UnsupportedOperationException();
155: }
156:
157: public synchronized boolean retainAll(Collection c) {
158: throw new UnsupportedOperationException();
159: }
160:
161: public synchronized boolean addAll(int index, Collection c) {
162: throw new UnsupportedOperationException();
163: }
164:
165: public synchronized boolean equals(Object o) {
166: return v.equals(o);
167: }
168:
169: public synchronized int hashCode() {
170: return v.hashCode();
171: }
172:
173: public synchronized String toString() {
174: return v.toString();
175: }
176:
177: public synchronized java.util.List subList(int fromIndex,
178: int toIndex) {
179: return v.subList(fromIndex, toIndex);
180: }
181:
182: public ListIterator listIterator() {
183: return new ListIterator() {
184: ListIterator i = v.listIterator();
185:
186: public boolean hasNext() {
187: return i.hasNext();
188: }
189:
190: public Object next() {
191: return i.next();
192: }
193:
194: public boolean hasPrevious() {
195: return i.hasPrevious();
196: }
197:
198: public Object previous() {
199: return i.previous();
200: }
201:
202: public int nextIndex() {
203: return i.nextIndex();
204: }
205:
206: public int previousIndex() {
207: return i.previousIndex();
208: }
209:
210: public void remove() {
211: throw new UnsupportedOperationException();
212: }
213:
214: public void set(Object o) {
215: throw new UnsupportedOperationException();
216: }
217:
218: public void add(Object o) {
219: throw new UnsupportedOperationException();
220: }
221: };
222: }
223:
224: public ListIterator listIterator(final int index) {
225: return new ListIterator() {
226: ListIterator i = v.listIterator(index);
227:
228: public boolean hasNext() {
229: return i.hasNext();
230: }
231:
232: public Object next() {
233: return i.next();
234: }
235:
236: public boolean hasPrevious() {
237: return i.hasPrevious();
238: }
239:
240: public Object previous() {
241: return i.previous();
242: }
243:
244: public int nextIndex() {
245: return i.nextIndex();
246: }
247:
248: public int previousIndex() {
249: return i.previousIndex();
250: }
251:
252: public void remove() {
253: throw new UnsupportedOperationException();
254: }
255:
256: public void set(Object o) {
257: throw new UnsupportedOperationException();
258: }
259:
260: public void add(Object o) {
261: throw new UnsupportedOperationException();
262: }
263: };
264: }
265:
266: public Iterator iterator() {
267: return new Iterator() {
268: Iterator i = v.iterator();
269:
270: public boolean hasNext() {
271: return i.hasNext();
272: }
273:
274: public Object next() {
275: return i.next();
276: }
277:
278: public void remove() {
279: throw new UnsupportedOperationException();
280: }
281: };
282: }
283: }
|