3
import java.io.Serializable;
5
public class Collections
7
public static List EMPTY_LIST = new ArrayList();
9
private Collections() {}
11
public static Collection unmodifiableCollection(Collection c)
13
return new UnmodifiableCollection(c);
16
static class UnmodifiableCollection implements Collection, Serializable
20
UnmodifiableCollection(Collection c)
25
public int size() {return c.size();}
26
public boolean isEmpty() {return c.isEmpty();}
27
public boolean contains(Object o) {return c.contains(o);}
28
public Object[] toArray() {return c.toArray();}
29
public Object[] toArray(Object[] a) {return c.toArray(a);}
31
public Iterator iterator()
35
Iterator i = c.iterator();
37
public boolean hasNext() {return i.hasNext();}
38
public Object next() {return i.next();}
41
throw new UnsupportedOperationException();
46
public boolean add(Object o)
48
throw new UnsupportedOperationException();
51
public boolean remove(Object o)
53
throw new UnsupportedOperationException();
56
public boolean containsAll(Collection coll)
58
return c.containsAll(coll);
61
public boolean addAll(Collection coll)
63
throw new UnsupportedOperationException();
66
public boolean removeAll(Collection coll)
68
throw new UnsupportedOperationException();
71
public boolean retainAll(Collection coll)
73
throw new UnsupportedOperationException();
78
throw new UnsupportedOperationException();
81
public String toString()
87
public static Set unmodifiableSet(Set s)
89
return new UnmodifiableSet(s);
92
static class UnmodifiableSet extends UnmodifiableCollection
93
implements Set, Serializable
95
UnmodifiableSet(Set s)
100
public boolean equals(Object o)
104
public int hashCode()
110
public static List unmodifiableList(List list)
112
return new UnmodifiableList(list);
115
static class UnmodifiableList extends UnmodifiableCollection
120
UnmodifiableList(List list)
126
public boolean equals(Object o)
128
return list.equals(o);
130
public int hashCode()
132
return list.hashCode();
135
public Object get(int index)
137
return list.get(index);
140
public Object set(int index, Object element)
142
throw new UnsupportedOperationException();
145
public void add(int index, Object element)
147
throw new UnsupportedOperationException();
150
public Object remove(int index)
152
throw new UnsupportedOperationException();
155
public int indexOf(Object o)
157
return list.indexOf(o);
160
public int lastIndexOf(Object o)
162
return list.lastIndexOf(o);
165
public boolean addAll(int index, Collection c)
167
throw new UnsupportedOperationException();
170
public ListIterator listIterator()
172
return listIterator(0);
175
public ListIterator listIterator(final int index)
177
return new ListIterator()
179
ListIterator i = list.listIterator(index);
181
public boolean hasNext()
191
public boolean hasPrevious()
193
return i.hasPrevious();
196
public Object previous()
201
public int nextIndex()
203
return i.nextIndex();
206
public int previousIndex()
208
return i.previousIndex();
213
throw new UnsupportedOperationException();
216
public void set(Object o)
218
throw new UnsupportedOperationException();
221
public void add(Object o)
223
throw new UnsupportedOperationException();
228
public List subList(int fromIndex, int toIndex) {
229
return new UnmodifiableList(list.subList(fromIndex, toIndex));
233
public static Enumeration enumeration(final Collection c) {
234
return new Enumeration() {
235
Iterator i = c.iterator();
237
public boolean hasMoreElements() {
241
public Object nextElement() {