1 16 package org.apache.commons.collections.buffer; 17 18 import java.io.IOException ; 19 import java.io.ObjectInputStream ; 20 import java.io.ObjectOutputStream ; 21 import java.io.Serializable ; 22 import java.util.Collection ; 23 import java.util.Iterator ; 24 25 import org.apache.commons.collections.Buffer; 26 import org.apache.commons.collections.Unmodifiable; 27 import org.apache.commons.collections.iterators.UnmodifiableIterator; 28 29 39 public final class UnmodifiableBuffer 40 extends AbstractBufferDecorator 41 implements Unmodifiable, Serializable { 42 43 44 private static final long serialVersionUID = 1832948656215393357L; 45 46 55 public static Buffer decorate(Buffer buffer) { 56 if (buffer instanceof Unmodifiable) { 57 return buffer; 58 } 59 return new UnmodifiableBuffer(buffer); 60 } 61 62 69 private UnmodifiableBuffer(Buffer buffer) { 70 super(buffer); 71 } 72 73 80 private void writeObject(ObjectOutputStream out) throws IOException { 81 out.defaultWriteObject(); 82 out.writeObject(collection); 83 } 84 85 92 private void readObject(ObjectInputStream in) throws IOException , ClassNotFoundException { 93 in.defaultReadObject(); 94 collection = (Collection ) in.readObject(); 95 } 96 97 public Iterator iterator() { 99 return UnmodifiableIterator.decorate(getCollection().iterator()); 100 } 101 102 public boolean add(Object object) { 103 throw new UnsupportedOperationException (); 104 } 105 106 public boolean addAll(Collection coll) { 107 throw new UnsupportedOperationException (); 108 } 109 110 public void clear() { 111 throw new UnsupportedOperationException (); 112 } 113 114 public boolean remove(Object object) { 115 throw new UnsupportedOperationException (); 116 } 117 118 public boolean removeAll(Collection coll) { 119 throw new UnsupportedOperationException (); 120 } 121 122 public boolean retainAll(Collection coll) { 123 throw new UnsupportedOperationException (); 124 } 125 126 public Object remove() { 128 throw new UnsupportedOperationException (); 129 } 130 131 } 132 | Popular Tags |