1 20 21 22 package fr.dyade.aaa.agent; 23 24 import java.io.*; 25 import java.util.*; 26 27 28 35 public class RoleMultiple implements Serializable { 36 37 38 39 private String name; 40 private Vector list = null; 41 42 public RoleMultiple() {} 43 44 48 public RoleMultiple(String name) { 49 this.name = name; 50 } 51 52 55 public void addListener(AgentId target) { 56 if (list == null) 57 list = new Vector(); 58 list.addElement(target); 59 } 60 61 64 public void removeListener(AgentId target) { 65 if (list == null) 66 return; 67 for (int i = list.size(); i-- > 0;) { 68 AgentId id = (AgentId) list.elementAt(i); 69 if (target.equals(id)) { 70 list.removeElement(id); 71 break; 72 } 73 } 74 } 75 76 82 public Enumeration getListeners() { 83 if (list == null) 84 return null; 85 return list.elements(); 86 } 87 88 91 public String getName() { 92 return name; 93 } 94 95 99 public void setName(String name) { 100 this.name = name; 101 } 102 103 110 public boolean contains(AgentId id) { 111 if (list == null) 112 return false; 113 return list.contains(id); 114 } 115 116 119 public String toString() { 120 StringBuffer output = new StringBuffer (); 121 output.append("("); 122 output.append(super.toString()); 123 output.append(",name=" + name); 124 output.append(",list="); 125 if (list == null) { 126 output.append("null"); 127 } else { 128 output.append("("); 129 output.append(list.size()); 130 for (int i = 0; i < list.size(); i ++) { 131 output.append(","); 132 output.append((AgentId) list.elementAt(i)); 133 } 134 output.append(")"); 135 } 136 output.append(")"); 137 return output.toString(); 138 } 139 } 140 | Popular Tags |