1 16 package org.apache.cocoon.portal.pluto.om.common; 17 18 import java.util.HashSet ; 19 import java.util.Iterator ; 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 33 public class SecurityRoleRefSetImpl extends HashSet implements SecurityRoleRefSet, SecurityRoleRefSetCtrl, java.io.Serializable { 34 35 public SecurityRoleRefSetImpl() { 36 } 38 39 41 public SecurityRoleRef get(String roleName) { 42 Iterator 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 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 roleName) { 66 Iterator 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 83 public SecurityRoleRef add(String roleName, String 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 96 public static class Unmodifiable extends UnmodifiableSet 97 implements SecurityRoleRefSet { 98 99 public Unmodifiable(SecurityRoleRefSet c) { 100 super(c); 101 } 102 103 105 public SecurityRoleRef get(String roleName) { 106 return((SecurityRoleRefSet)c).get(roleName); 107 } 108 109 } 110 111 } 112 | Popular Tags |