1 16 package org.apache.cocoon.portal.pluto.om.common; 17 18 import java.io.Serializable ; 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 import java.util.Set ; 22 23 30 public class UnmodifiableSet implements Set , Serializable { 31 32 private static final long serialVersionUID = 1820017752578914078L; 34 35 protected Set c; 36 37 public UnmodifiableSet(Set c) { 38 if (c == null) { 39 throw new NullPointerException (); 40 } 41 this.c = c; 42 } 43 44 public int size() { 45 return c.size(); 46 } 47 48 public boolean isEmpty() { 49 return c.isEmpty(); 50 } 51 52 public boolean contains(Object o) { 53 return c.contains(o); 54 } 55 56 public Object [] toArray() { 57 return c.toArray(); 58 } 59 60 public Object [] toArray(Object [] a) { 61 return c.toArray(a); 62 } 63 64 public String toString() { 65 return c.toString(); 66 } 67 68 public Iterator iterator() { 69 return new Iterator () { 70 Iterator i = c.iterator(); 71 72 public boolean hasNext() { 73 return i.hasNext(); 74 } 75 76 public Object next() { 77 return i.next(); 78 } 79 80 public void remove() { 81 throw new UnsupportedOperationException (); 82 } 83 }; 84 } 85 86 public boolean add(Object o) { 87 throw new UnsupportedOperationException (); 88 } 89 90 public boolean remove(Object o) { 91 throw new UnsupportedOperationException (); 92 } 93 94 public boolean containsAll(Collection coll) { 95 return c.containsAll(coll); 96 } 97 98 public boolean addAll(Collection coll) { 99 throw new UnsupportedOperationException (); 100 } 101 102 public boolean removeAll(Collection coll) { 103 throw new UnsupportedOperationException (); 104 } 105 106 public boolean retainAll(Collection coll) { 107 throw new UnsupportedOperationException (); 108 } 109 110 public void clear() { 111 throw new UnsupportedOperationException (); 112 } 113 114 public boolean equals(Object o) { 115 return c.equals(o); 116 } 117 118 public int hashCode() { 119 return c.hashCode(); 120 } 121 122 124 131 public Set getModifiableSet() { 132 return c; 133 } 134 } 135 | Popular Tags |