1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.om.servlet.impl;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Iterator;
23
24 import org.apache.jetspeed.om.common.servlet.MutableSecurityRoleSet;
25 import org.apache.pluto.om.common.SecurityRole;
26 import org.apache.pluto.om.common.SecurityRoleSet;
27
28 /***
29 *
30 * SecurityRoleRefSetImpl
31 *
32 * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
33 * @version $Id: SecurityRoleSetImpl.java 517121 2007-03-12 07:45:49Z ate $
34 *
35 */
36 public class SecurityRoleSetImpl implements SecurityRoleSet, MutableSecurityRoleSet, Serializable {
37
38 protected Collection innerCollection;
39
40 public SecurityRoleSetImpl() {
41 innerCollection = new ArrayList();
42 }
43
44 public SecurityRoleSetImpl(Collection collection) {
45 innerCollection = collection;
46 }
47
48 /***
49 * @see org.apache.pluto.om.common.SecurityRoleSet#get(java.lang.String)
50 */
51 public SecurityRole get(String name) {
52 Iterator itr = innerCollection.iterator();
53 while (itr.hasNext()) {
54 SecurityRole role = (SecurityRole) itr.next();
55 if (role.getRoleName().equals(name)) { return role; }
56 }
57
58 return null;
59 }
60
61 /***
62 * @see org.apache.jetspeed.om.common.servlet.MutableSecurityRoleSet#add(org.apache.pluto.om.common.SecurityRole)
63 */
64 public SecurityRole add(SecurityRole securityRole) {
65 if ( innerCollection.contains(securityRole)) {
66 throw new IllegalArgumentException("SecurityRole "+securityRole.getRoleName()+" already defined.");
67 }
68 innerCollection.add(securityRole);
69 return securityRole;
70 }
71
72 /***
73 * @see java.util.Collection#add(java.lang.Object)
74 */
75 public boolean add(Object o) {
76 SecurityRole role = (SecurityRole) o;
77 add(role);
78 return true;
79 }
80
81 /***
82 * @see java.util.Collection#remove(java.lang.Object)
83 */
84 public boolean remove(Object o) {
85 return innerCollection.remove(o);
86 }
87
88 /***
89 * @see java.util.Collection#addAll(java.util.Collection)
90 */
91 public boolean addAll(Collection c) {
92
93 Iterator itr = c.iterator();
94 while ( itr.hasNext() ) {
95 add(itr.next());
96 }
97 return true;
98 }
99
100 /***
101 * @see java.util.Collection#clear()
102 */
103 public void clear() {
104 innerCollection.clear();
105
106 }
107
108 /***
109 * @see java.util.Collection#contains(java.lang.Object)
110 */
111 public boolean contains(Object o) {
112 return innerCollection.contains(o);
113 }
114
115 /***
116 * @see java.util.Collection#containsAll(java.util.Collection)
117 */
118 public boolean containsAll(Collection c) {
119 return innerCollection.containsAll(c);
120 }
121
122 /***
123 * @see java.util.Collection#isEmpty()
124 */
125 public boolean isEmpty() {
126 return innerCollection.isEmpty();
127 }
128
129 /***
130 * @see java.util.Collection#iterator()
131 */
132 public Iterator iterator() {
133 return innerCollection.iterator();
134 }
135
136 /***
137 * @see java.util.Collection#removeAll(java.util.Collection)
138 */
139 public boolean removeAll(Collection c) {
140 return innerCollection.removeAll(c);
141 }
142
143 /***
144 * @see java.util.Collection#retainAll(java.util.Collection)
145 */
146 public boolean retainAll(Collection c) {
147 return innerCollection.retainAll(c);
148 }
149
150 /***
151 * @see java.util.Collection#size()
152 */
153 public int size() {
154 return innerCollection.size();
155 }
156
157 /***
158 * @see java.util.Collection#toArray()
159 */
160 public Object[] toArray() {
161 return innerCollection.toArray();
162 }
163
164 /***
165 * @see java.util.Collection#toArray(java.lang.Object[])
166 */
167 public Object[] toArray(Object[] a) {
168 return innerCollection.toArray(a);
169 }
170
171 /***
172 * @return collection
173 */
174 public Collection getInnerCollection() {
175 return innerCollection;
176 }
177
178 /***
179 * @param collection
180 */
181 public void setInnerCollection(Collection collection) {
182 innerCollection = collection;
183 }
184
185 }