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.SecurityRole; 26 import org.apache.pluto.om.common.SecurityRoleSet; 27 import org.apache.pluto.util.StringUtils; 28 29 public class SecurityRoleSetImpl extends HashSet implements SecurityRoleSet, java.io.Serializable { 30 31 32 34 public static class Unmodifiable 35 extends org.apache.pluto.portalImpl.om.common.impl.UnmodifiableSet 36 implements SecurityRoleSet 37 { 38 39 public Unmodifiable(SecurityRoleSet c) 40 { 41 super(c); 42 } 43 44 public SecurityRole get(String roleName) 45 { 46 return ((SecurityRoleSet)c).get(roleName); 47 } 48 49 } 50 51 public SecurityRoleSetImpl() 52 { 53 } 54 55 57 public SecurityRole get(String roleName) 58 { 59 Iterator iterator = this.iterator(); 60 while (iterator.hasNext()) { 61 SecurityRole securityRole = (SecurityRole)iterator.next(); 62 if (securityRole.getRoleName().equals(roleName)) { 63 return securityRole; 64 } 65 } 66 return null; 67 } 68 69 71 public SecurityRole add(SecurityRole securityRole) 72 { 73 SecurityRoleImpl newSecurityRole = new SecurityRoleImpl(); 74 newSecurityRole.setRoleName(securityRole.getRoleName()); 75 newSecurityRole.setDescription(securityRole.getDescription()); 76 77 super.add(newSecurityRole); 78 79 return newSecurityRole; 80 } 81 82 public SecurityRole add(String roleName, String description) 83 { 84 SecurityRoleImpl securityRole = new SecurityRoleImpl(); 85 securityRole.setRoleName(roleName); 86 securityRole.setDescription(description); 87 88 super.add(securityRole); 89 90 return securityRole; 91 } 92 93 public void remove(SecurityRole securityRole) 94 { 95 super.remove(securityRole); 96 } 97 98 public SecurityRole remove(String roleName) 99 { 100 Iterator iterator = this.iterator(); 101 while (iterator.hasNext()) 102 { 103 SecurityRole securityRole = (SecurityRole)iterator.next(); 104 if (securityRole.getRoleName().equals(roleName)) 105 { 106 super.remove(securityRole); 107 return securityRole; 108 } 109 } 110 return null; 111 } 112 113 public String toString() 114 { 115 return toString(0); 116 } 117 118 public String toString(int indent) 119 { 120 StringBuffer buffer = new StringBuffer (50); 121 StringUtils.newLine(buffer,indent); 122 buffer.append(getClass().toString()); 123 buffer.append(": "); 124 Iterator iterator = this.iterator(); 125 while (iterator.hasNext()) { 126 buffer.append(((SecurityRoleImpl)iterator.next()).toString(indent+2)); 127 } 128 return buffer.toString(); 129 } 130 131 } 132 | Popular Tags |