00001 package ca.mcgill.sable.util;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 public class Collections
00090 {
00091 static class UnmodIterator implements Iterator
00092 {
00093 Iterator it;
00094 public UnmodIterator(Iterator it) { this.it = it; }
00095
00096 public boolean hasNext() { return it.hasNext(); }
00097 public Object next() { return it.next(); }
00098 public void remove()
00099 throws UnsupportedOperationException, NoSuchElementException
00100 { throw new UnsupportedOperationException(); }
00101 }
00102
00103 static class UnmodListIterator implements ListIterator
00104 {
00105 ListIterator li;
00106
00107 public UnmodListIterator(ListIterator li) { this.li = li; }
00108
00109 public boolean hasNext() { return li.hasNext(); }
00110 public Object next() throws NoSuchElementException
00111 { return li.next(); }
00112 public boolean hasPrevious() { return li.hasPrevious(); }
00113 public Object previous() throws NoSuchElementException
00114 { return li.previous(); }
00115 public int nextIndex() { return li.nextIndex(); }
00116 public int previousIndex() { return li.previousIndex(); }
00117 public void remove()
00118 throws UnsupportedOperationException, NoSuchElementException
00119 { throw new UnsupportedOperationException(); }
00120 public void set(Object o)
00121 throws UnsupportedOperationException, NoSuchElementException
00122 { throw new UnsupportedOperationException(); }
00123 public void add(Object o)
00124 throws UnsupportedOperationException
00125 { throw new UnsupportedOperationException(); }
00126 }
00127
00128 static class UnmodList implements List
00129 {
00130 private List l;
00131
00132 public UnmodList(List l) { this.l = l; }
00133
00134 public int size() { return l.size(); }
00135 public boolean isEmpty() { return l.isEmpty(); }
00136 public boolean contains(Object o) { return l.contains(o); }
00137 public Object[] toArray() { return l.toArray(); }
00138
00139 public void toArray(Object[] a)
00140 {
00141 l.toArray(a);
00142 }
00143
00144 public boolean add(Object o)
00145 throws UnsupportedOperationException,
00146 ClassCastException, IllegalArgumentException
00147 { throw new UnsupportedOperationException(); }
00148 public boolean remove(Object o)
00149 throws UnsupportedOperationException
00150 { throw new UnsupportedOperationException(); }
00151 public boolean containsAll(Collection c) { return l.containsAll(c); }
00152 public boolean addAll(Collection c)
00153 throws UnsupportedOperationException,
00154 ClassCastException, IllegalArgumentException
00155 { throw new UnsupportedOperationException(); }
00156 public boolean removeAll(Collection c)
00157 throws UnsupportedOperationException
00158 { throw new UnsupportedOperationException(); }
00159 public boolean retainAll(Collection c)
00160 throws UnsupportedOperationException
00161 { throw new UnsupportedOperationException(); }
00162 public void clear()
00163 throws UnsupportedOperationException
00164 { throw new UnsupportedOperationException(); }
00165 public boolean equals(Object o) { return l.equals(o); }
00166 public int hashCode() { return l.hashCode(); }
00167 public Object get(int index)
00168 throws ArrayIndexOutOfBoundsException
00169 { return l.get(index); }
00170 public Object set(int index, Object element)
00171 throws UnsupportedOperationException, ClassCastException,
00172 IllegalArgumentException, ArrayIndexOutOfBoundsException
00173 { throw new UnsupportedOperationException(); }
00174 public void add(int index, Object element)
00175 throws UnsupportedOperationException, ClassCastException,
00176 IllegalArgumentException, ArrayIndexOutOfBoundsException
00177 { throw new UnsupportedOperationException(); }
00178 public Object remove(int index)
00179 throws UnsupportedOperationException, ArrayIndexOutOfBoundsException
00180 { throw new UnsupportedOperationException(); }
00181 public int indexOf(Object o) { return l.indexOf(o); }
00182 public int indexOf(Object o, int index)
00183 throws ArrayIndexOutOfBoundsException
00184 { return l.indexOf(o, index); }
00185 public int lastIndexOf(Object o) { return l.lastIndexOf(o); }
00186 public int lastIndexOf(Object o, int index)
00187 throws ArrayIndexOutOfBoundsException
00188 { return l.lastIndexOf(o, index); }
00189 public void removeRange(int fromIndex, int toIndex)
00190 throws UnsupportedOperationException, ArrayIndexOutOfBoundsException
00191 { throw new UnsupportedOperationException(); }
00192 public boolean addAll(int index, Collection c)
00193 throws UnsupportedOperationException, ClassCastException,
00194 IllegalArgumentException, ArrayIndexOutOfBoundsException
00195 { throw new UnsupportedOperationException(); }
00196 public String toString() { return l.toString(); }
00197
00198 public Iterator iterator() { return new UnmodIterator(l.iterator()); }
00199 public ListIterator listIterator()
00200 { return new UnmodListIterator(l.listIterator()); }
00201 public ListIterator listIterator(int index)
00202 throws ArrayIndexOutOfBoundsException
00203 { return new UnmodListIterator(l.listIterator(index)); }
00204 }
00205
00206 public static List unmodifiableList(List list)
00207 {
00208 return new UnmodList(list);
00209 }
00210 }