KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > om > common > SecurityRoleRefSetImpl


1 /*
2  * Copyright 2004,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.pluto.om.common;
17
18 import java.util.HashSet JavaDoc;
19 import java.util.Iterator JavaDoc;
20
21 import org.apache.pluto.om.common.DescriptionSet;
22 import org.apache.pluto.om.common.SecurityRoleRef;
23 import org.apache.pluto.om.common.SecurityRoleRefSet;
24 import org.apache.pluto.om.common.SecurityRoleRefSetCtrl;
25
26 /**
27  *
28  *
29  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
30  *
31  * @version CVS $Id: SecurityRoleRefSetImpl.java 123407 2004-12-27 13:51:59Z cziegeler $
32  */

33 public class SecurityRoleRefSetImpl extends HashSet JavaDoc implements SecurityRoleRefSet, SecurityRoleRefSetCtrl, java.io.Serializable JavaDoc {
34
35     public SecurityRoleRefSetImpl() {
36         // nothing to do
37
}
38
39     // SecurityRoleRefSet implementation.
40

41     public SecurityRoleRef get(String JavaDoc roleName) {
42         Iterator JavaDoc iterator = this.iterator();
43         while (iterator.hasNext()) {
44             SecurityRoleRef securityRoleRef = (SecurityRoleRef)iterator.next();
45             if (securityRoleRef.getRoleName().equals(roleName)) {
46                 return securityRoleRef;
47             }
48         }
49         return null;
50     }
51
52     // SecurityRoleRefSetCtrl implementation.
53

54     public SecurityRoleRef add(SecurityRoleRef securityRoleRef) {
55         SecurityRoleRefImpl newSecurityRoleRef = new SecurityRoleRefImpl();
56         newSecurityRoleRef.setRoleName(securityRoleRef.getRoleName());
57         newSecurityRoleRef.setRoleLink(securityRoleRef.getRoleLink());
58         newSecurityRoleRef.setDescriptionSet(((SecurityRoleRefImpl)securityRoleRef).getDescriptionSet());
59
60         super.add(newSecurityRoleRef);
61
62         return newSecurityRoleRef;
63     }
64
65     public SecurityRoleRef remove(String JavaDoc roleName) {
66         Iterator JavaDoc iterator = this.iterator();
67         while (iterator.hasNext()) {
68             SecurityRoleRef securityRoleRef = (SecurityRoleRef)iterator.next();
69             if (securityRoleRef.getRoleName().equals(roleName)) {
70                 super.remove(securityRoleRef);
71                 return securityRoleRef;
72             }
73         }
74         return null;
75     }
76
77     public void remove(SecurityRoleRef securityRoleRef) {
78         super.remove(securityRoleRef);
79     }
80
81     // additional methods.
82

83     public SecurityRoleRef add(String JavaDoc roleName, String JavaDoc roleLink, DescriptionSet descriptions) {
84         SecurityRoleRefImpl securityRoleRef = new SecurityRoleRefImpl();
85         securityRoleRef.setRoleName(roleName);
86         securityRoleRef.setRoleLink(roleLink);
87         securityRoleRef.setDescriptionSet(descriptions);
88
89         super.add(securityRoleRef);
90
91         return securityRoleRef;
92     }
93
94     // unmodifiable part
95

96     public static class Unmodifiable extends UnmodifiableSet
97             implements SecurityRoleRefSet {
98
99         public Unmodifiable(SecurityRoleRefSet c) {
100             super(c);
101         }
102
103         // additional methods.
104

105         public SecurityRoleRef get(String JavaDoc roleName) {
106             return((SecurityRoleRefSet)c).get(roleName);
107         }
108
109     }
110
111 }
112
Popular Tags