%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.om.servlet.impl.SecurityRoleSetImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
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 | 0 | public SecurityRoleSetImpl() { |
41 | 0 | innerCollection = new ArrayList(); |
42 | 0 | } |
43 | ||
44 | 0 | public SecurityRoleSetImpl(Collection collection) { |
45 | 0 | innerCollection = collection; |
46 | 0 | } |
47 | ||
48 | /** |
|
49 | * @see org.apache.pluto.om.common.SecurityRoleSet#get(java.lang.String) |
|
50 | */ |
|
51 | public SecurityRole get(String name) { |
|
52 | 0 | Iterator itr = innerCollection.iterator(); |
53 | 0 | while (itr.hasNext()) { |
54 | 0 | SecurityRole role = (SecurityRole) itr.next(); |
55 | 0 | if (role.getRoleName().equals(name)) { return role; } |
56 | 0 | } |
57 | ||
58 | 0 | 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 | 0 | if ( innerCollection.contains(securityRole)) { |
66 | 0 | throw new IllegalArgumentException("SecurityRole "+securityRole.getRoleName()+" already defined."); |
67 | } |
|
68 | 0 | innerCollection.add(securityRole); |
69 | 0 | return securityRole; |
70 | } |
|
71 | ||
72 | /** |
|
73 | * @see java.util.Collection#add(java.lang.Object) |
|
74 | */ |
|
75 | public boolean add(Object o) { |
|
76 | 0 | SecurityRole role = (SecurityRole) o; |
77 | 0 | add(role); |
78 | 0 | return true; |
79 | } |
|
80 | ||
81 | /** |
|
82 | * @see java.util.Collection#remove(java.lang.Object) |
|
83 | */ |
|
84 | public boolean remove(Object o) { |
|
85 | 0 | return innerCollection.remove(o); |
86 | } |
|
87 | ||
88 | /** |
|
89 | * @see java.util.Collection#addAll(java.util.Collection) |
|
90 | */ |
|
91 | public boolean addAll(Collection c) { |
|
92 | // enforce unique role names in collection by adding them individually |
|
93 | 0 | Iterator itr = c.iterator(); |
94 | 0 | while ( itr.hasNext() ) { |
95 | 0 | add(itr.next()); |
96 | } |
|
97 | 0 | return true; |
98 | } |
|
99 | ||
100 | /** |
|
101 | * @see java.util.Collection#clear() |
|
102 | */ |
|
103 | public void clear() { |
|
104 | 0 | innerCollection.clear(); |
105 | ||
106 | 0 | } |
107 | ||
108 | /** |
|
109 | * @see java.util.Collection#contains(java.lang.Object) |
|
110 | */ |
|
111 | public boolean contains(Object o) { |
|
112 | 0 | return innerCollection.contains(o); |
113 | } |
|
114 | ||
115 | /** |
|
116 | * @see java.util.Collection#containsAll(java.util.Collection) |
|
117 | */ |
|
118 | public boolean containsAll(Collection c) { |
|
119 | 0 | return innerCollection.containsAll(c); |
120 | } |
|
121 | ||
122 | /** |
|
123 | * @see java.util.Collection#isEmpty() |
|
124 | */ |
|
125 | public boolean isEmpty() { |
|
126 | 0 | return innerCollection.isEmpty(); |
127 | } |
|
128 | ||
129 | /** |
|
130 | * @see java.util.Collection#iterator() |
|
131 | */ |
|
132 | public Iterator iterator() { |
|
133 | 0 | return innerCollection.iterator(); |
134 | } |
|
135 | ||
136 | /** |
|
137 | * @see java.util.Collection#removeAll(java.util.Collection) |
|
138 | */ |
|
139 | public boolean removeAll(Collection c) { |
|
140 | 0 | return innerCollection.removeAll(c); |
141 | } |
|
142 | ||
143 | /** |
|
144 | * @see java.util.Collection#retainAll(java.util.Collection) |
|
145 | */ |
|
146 | public boolean retainAll(Collection c) { |
|
147 | 0 | return innerCollection.retainAll(c); |
148 | } |
|
149 | ||
150 | /** |
|
151 | * @see java.util.Collection#size() |
|
152 | */ |
|
153 | public int size() { |
|
154 | 0 | return innerCollection.size(); |
155 | } |
|
156 | ||
157 | /** |
|
158 | * @see java.util.Collection#toArray() |
|
159 | */ |
|
160 | public Object[] toArray() { |
|
161 | 0 | return innerCollection.toArray(); |
162 | } |
|
163 | ||
164 | /** |
|
165 | * @see java.util.Collection#toArray(java.lang.Object[]) |
|
166 | */ |
|
167 | public Object[] toArray(Object[] a) { |
|
168 | 0 | return innerCollection.toArray(a); |
169 | } |
|
170 | ||
171 | /** |
|
172 | * @return collection |
|
173 | */ |
|
174 | public Collection getInnerCollection() { |
|
175 | 0 | return innerCollection; |
176 | } |
|
177 | ||
178 | /** |
|
179 | * @param collection |
|
180 | */ |
|
181 | public void setInnerCollection(Collection collection) { |
|
182 | 0 | innerCollection = collection; |
183 | 0 | } |
184 | ||
185 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |