001package proxy;
002import java.util.Collection;
003import java.util.Iterator;
004import java.io.Serializable;
005
006@SuppressWarnings("serial")
007class UnmodifiableCollection<E> implements Collection<E>, Serializable {
008        Collection<E> c;
009
010        UnmodifiableCollection(Collection<E> c) {
011                if (c==null)
012                        throw new NullPointerException();
013                this.c = c;
014        }
015
016        public int      size()                       {return c.size();}
017        public boolean  isEmpty()                    {return c.isEmpty();}
018        public boolean  contains(Object o)           {return c.contains(o);}
019        public Object[] toArray()                    {return c.toArray();}
020        public <T> T[]  toArray(T[] a)               {return c.toArray(a);}
021        public String   toString()                   {return c.toString();}
022        public boolean  containsAll(Collection<?> d) {return c.containsAll(d);}
023
024        public Iterator<E> iterator() {
025                return new Iterator<E>() {
026                        Iterator<E> i = UnmodifiableCollection.this.c.iterator();
027
028                        public boolean hasNext() {return i.hasNext();}
029                        public E next()          {return i.next();}
030                        public void remove() {
031                                throw new UnsupportedOperationException();
032                        }
033                };
034        }
035
036        public boolean add(Object o){
037                throw new UnsupportedOperationException();
038        }
039        public boolean remove(Object o) {
040                throw new UnsupportedOperationException();
041        }
042        public boolean addAll(Collection<? extends E> c) {
043                throw new UnsupportedOperationException();
044        }
045        public boolean removeAll(Collection<?> c) {
046                throw new UnsupportedOperationException();
047        }
048        public boolean retainAll(Collection<?> c) {
049                throw new UnsupportedOperationException();
050        }
051        public void clear() {
052                throw new UnsupportedOperationException();
053        }
054}