1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.pluto.portalImpl.om.common.impl;
21
22 import java.io.*;
23 import java.util.*;
24
25 public class UnmodifiableSet implements Set, Serializable {
26
27
28 private static final long serialVersionUID = 1820017752578914078L;
29
30 protected Set c;
31
32 public UnmodifiableSet(Set c)
33 {
34 if (c == null) {
35 throw new NullPointerException();
36 }
37 this.c = c;
38 }
39
40 public int size()
41 {
42 return c.size();
43 }
44
45 public boolean isEmpty()
46 {
47 return c.isEmpty();
48 }
49
50 public boolean contains(Object o)
51 {
52 return c.contains(o);
53 }
54
55 public Object[] toArray()
56 {
57 return c.toArray();
58 }
59
60 public Object[] toArray(Object[] a)
61 {
62 return c.toArray(a);
63 }
64
65 public String toString()
66 {
67 return c.toString();
68 }
69
70 public Iterator iterator()
71 {
72 return new Iterator()
73 {
74 Iterator i = c.iterator();
75
76 public boolean hasNext()
77 {
78 return i.hasNext();
79 }
80
81 public Object next()
82 {
83 return i.next();
84 }
85
86 public void remove()
87 {
88 throw new UnsupportedOperationException();
89 }
90 };
91 }
92
93 public boolean add(Object o)
94 {
95 throw new UnsupportedOperationException();
96 }
97
98 public boolean remove(Object o)
99 {
100 throw new UnsupportedOperationException();
101 }
102
103 public boolean containsAll(Collection coll)
104 {
105 return c.containsAll(coll);
106 }
107
108 public boolean addAll(Collection coll)
109 {
110 throw new UnsupportedOperationException();
111 }
112
113 public boolean removeAll(Collection coll)
114 {
115 throw new UnsupportedOperationException();
116 }
117
118 public boolean retainAll(Collection coll)
119 {
120 throw new UnsupportedOperationException();
121 }
122
123 public void clear()
124 {
125 throw new UnsupportedOperationException();
126 }
127
128 public boolean equals(Object o)
129 {
130 return c.equals(o);
131 }
132
133 public int hashCode()
134 {
135 return c.hashCode();
136 }
137
138
139
140 /***
141 * This method is only used by the ControllerFactoryImpl
142 * to unwrap the unmodifiable Set and allow to
143 * modify the set via controllers
144 *
145 * @return the modifiable set
146 */
147 public Set getModifiableSet()
148 {
149 return c;
150 }
151 }