1 7 8 package javax.accessibility; 9 10 import java.util.Vector ; 11 import java.util.Locale ; 12 import java.util.MissingResourceException ; 13 import java.util.ResourceBundle ; 14 15 26 public class AccessibleStateSet { 27 28 37 protected Vector <AccessibleState > states = null; 38 39 42 public AccessibleStateSet() { 43 states = null; 44 } 45 46 52 public AccessibleStateSet(AccessibleState [] states) { 53 if (states.length != 0) { 54 this.states = new Vector (states.length); 55 for (int i = 0; i < states.length; i++) { 56 if (!this.states.contains(states[i])) { 57 this.states.addElement(states[i]); 58 } 59 } 60 } 61 } 62 63 73 public boolean add(AccessibleState state) { 74 if (states == null) { 78 states = new Vector (); 79 } 80 81 if (!states.contains(state)) { 82 states.addElement(state); 83 return true; 84 } else { 85 return false; 86 } 87 } 88 89 94 public void addAll(AccessibleState [] states) { 95 if (states.length != 0) { 96 if (this.states == null) { 97 this.states = new Vector (states.length); 98 } 99 for (int i = 0; i < states.length; i++) { 100 if (!this.states.contains(states[i])) { 101 this.states.addElement(states[i]); 102 } 103 } 104 } 105 } 106 107 117 public boolean remove(AccessibleState state) { 118 if (states == null) { 119 return false; 120 } else { 121 return states.removeElement(state); 122 } 123 } 124 125 128 public void clear() { 129 if (states != null) { 130 states.removeAllElements(); 131 } 132 } 133 134 139 public boolean contains(AccessibleState state) { 140 if (states == null) { 141 return false; 142 } else { 143 return states.contains(state); 144 } 145 } 146 147 151 public AccessibleState [] toArray() { 152 if (states == null) { 153 return new AccessibleState [0]; 154 } else { 155 AccessibleState [] stateArray = new AccessibleState [states.size()]; 156 for (int i = 0; i < stateArray.length; i++) { 157 stateArray[i] = (AccessibleState ) states.elementAt(i); 158 } 159 return stateArray; 160 } 161 } 162 163 170 public String toString() { 171 String ret = null; 172 if ((states != null) && (states.size() > 0)) { 173 ret = ((AccessibleState ) (states.elementAt(0))).toDisplayString(); 174 for (int i = 1; i < states.size(); i++) { 175 ret = ret + "," 176 + ((AccessibleState ) (states.elementAt(i))). 177 toDisplayString(); 178 } 179 } 180 return ret; 181 } 182 } 183 | Popular Tags |