1 7 8 package javax.management.relation; 9 10 import java.util.ArrayList ; 11 import java.util.List ; 12 import java.util.Iterator ; 13 import java.util.Collection ; 15 23 public class RoleList extends ArrayList { 24 25 26 private static final long serialVersionUID = 5568344346499649313L; 27 28 32 35 public RoleList() { 36 super(); 37 return; 38 } 39 40 46 public RoleList(int theInitialCapacity) { 47 super(theInitialCapacity); 48 return; 49 } 50 51 65 public RoleList(List theList) 66 throws IllegalArgumentException { 67 68 if (theList == null) { 69 String excMsg = "Invalid parameter"; 70 throw new IllegalArgumentException (excMsg); 71 } 72 73 int i = 0; 74 for (Iterator eltIter = theList.iterator(); 75 eltIter.hasNext();) { 76 Object currElt = eltIter.next(); 77 if (!(currElt instanceof Role )) { 78 StringBuffer excMsgStrB = new StringBuffer (); 79 String excMsg = "An element is not a Role at index "; 80 excMsgStrB.append(excMsg); 81 excMsgStrB.append(i); 82 throw new IllegalArgumentException (excMsgStrB.toString()); 83 } 84 i++; 85 super.add(currElt); 86 } 87 return; 88 } 89 90 94 101 public void add(Role theRole) 102 throws IllegalArgumentException { 103 104 if (theRole == null) { 105 String excMsg = "Invalid parameter"; 106 throw new IllegalArgumentException (excMsg); 107 } 108 super.add(theRole); 109 return; 110 } 111 112 125 public void add(int theIndex, 126 Role theRole) 127 throws IllegalArgumentException , 128 IndexOutOfBoundsException { 129 130 if (theRole == null) { 131 String excMsg = "Invalid parameter"; 132 throw new IllegalArgumentException (excMsg); 133 } 134 135 super.add(theIndex, theRole); 136 return; 137 } 138 139 151 public void set(int theIndex, 152 Role theRole) 153 throws IllegalArgumentException , 154 IndexOutOfBoundsException { 155 156 if (theRole == null) { 157 String excMsg = "Invalid parameter."; 159 throw new IllegalArgumentException (excMsg); 160 } 161 162 super.set(theIndex, theRole); 163 return; 164 } 165 166 180 public boolean addAll(RoleList theRoleList) 181 throws IndexOutOfBoundsException { 182 183 if (theRoleList == null) { 184 return true; 185 } 186 187 return (super.addAll(theRoleList)); 188 } 189 190 207 public boolean addAll(int theIndex, 208 RoleList theRoleList) 209 throws IllegalArgumentException , 210 IndexOutOfBoundsException { 211 212 if (theRoleList == null) { 213 String excMsg = "Invalid parameter."; 215 throw new IllegalArgumentException (excMsg); 216 } 217 218 return (super.addAll(theIndex, theRoleList)); 219 } 220 } 221 | Popular Tags |