1 16 19 20 package org.apache.pluto.portalImpl.om.common.impl; 21 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 25 import org.apache.pluto.om.common.DescriptionSet; 26 import org.apache.pluto.om.common.SecurityRoleRef; 27 import org.apache.pluto.om.common.SecurityRoleRefSet; 28 import org.apache.pluto.om.common.SecurityRoleRefSetCtrl; 29 import org.apache.pluto.util.StringUtils; 30 31 public class SecurityRoleRefSetImpl extends HashSet implements SecurityRoleRefSet, SecurityRoleRefSetCtrl, java.io.Serializable { 32 33 public SecurityRoleRefSetImpl() 34 { 35 } 36 37 39 public SecurityRoleRef get(String roleName) 40 { 41 Iterator iterator = this.iterator(); 42 while (iterator.hasNext()) { 43 SecurityRoleRef securityRoleRef = (SecurityRoleRef)iterator.next(); 44 if (securityRoleRef.getRoleName().equals(roleName)) { 45 return securityRoleRef; 46 } 47 } 48 return null; 49 } 50 51 53 public SecurityRoleRef add(SecurityRoleRef securityRoleRef) 54 { 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 { 67 Iterator iterator = this.iterator(); 68 while (iterator.hasNext()) { 69 SecurityRoleRef securityRoleRef = (SecurityRoleRef)iterator.next(); 70 if (securityRoleRef.getRoleName().equals(roleName)) { 71 super.remove(securityRoleRef); 72 return securityRoleRef; 73 } 74 } 75 return null; 76 } 77 78 public void remove(SecurityRoleRef securityRoleRef) 79 { 80 super.remove(securityRoleRef); 81 } 82 83 85 public SecurityRoleRef add(String roleName, String roleLink, DescriptionSet descriptions) 86 { 87 SecurityRoleRefImpl securityRoleRef = new SecurityRoleRefImpl(); 88 securityRoleRef.setRoleName(roleName); 89 securityRoleRef.setRoleLink(roleLink); 90 securityRoleRef.setDescriptionSet(descriptions); 91 92 super.add(securityRoleRef); 93 94 return securityRoleRef; 95 } 96 97 public String toString() 98 { 99 return toString(0); 100 } 101 102 public String toString(int indent) 103 { 104 StringBuffer buffer = new StringBuffer (50); 105 StringUtils.newLine(buffer,indent); 106 buffer.append(getClass().toString()); 107 buffer.append(": "); 108 Iterator iterator = this.iterator(); 109 while (iterator.hasNext()) { 110 buffer.append(((SecurityRoleRefImpl)iterator.next()).toString(indent+2)); 111 } 112 return buffer.toString(); 113 } 114 115 117 public static class Unmodifiable extends org.apache.pluto.portalImpl.om.common.impl.UnmodifiableSet 118 implements SecurityRoleRefSet { 119 120 public Unmodifiable(SecurityRoleRefSet c) 121 { 122 super(c); 123 } 124 125 127 public SecurityRoleRef get(String roleName) 128 { 129 return((SecurityRoleRefSet)c).get(roleName); 130 } 131 132 } 133 134 } 135 | Popular Tags |