1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
/* * @(#)AccessibleRelation.java 1.16 06/04/07 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.accessibility; import java.util.Vector; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * <P>Class AccessibleRelation describes a relation between the * object that implements the AccessibleRelation and one or more other * objects. The actual relations that an object has with other * objects are defined as an AccessibleRelationSet, which is a composed * set of AccessibleRelations. * <p>The toDisplayString method allows you to obtain the localized string * for a locale independent key from a predefined ResourceBundle for the * keys defined in this class. * <p>The constants in this class present a strongly typed enumeration * of common object roles. If the constants in this class are not sufficient * to describe the role of an object, a subclass should be generated * from this class and it should provide constants in a similar manner. * * @version 1.16 04/07/06 * @author Lynn Monsanto * @since 1.3 */ public class AccessibleRelation extends AccessibleBundle { /* * The group of objects that participate in the relation. * The relation may be one-to-one or one-to-many. For * example, in the case of a LABEL_FOR relation, the target * vector would contain a list of objects labeled by the object * that implements this AccessibleRelation. In the case of a * MEMBER_OF relation, the target vector would contain all * of the components that are members of the same group as the * object that implements this AccessibleRelation. */ private Object [] target = new Object[0]; /** * Indicates an object is a label for one or more target objects. * * @see #getTarget * @see #CONTROLLER_FOR * @see #CONTROLLED_BY * @see #LABELED_BY * @see #MEMBER_OF */ public static final String LABEL_FOR = new String("labelFor"); /** * Indicates an object is labeled by one or more target objects. * * @see #getTarget * @see #CONTROLLER_FOR * @see #CONTROLLED_BY * @see #LABEL_FOR * @see #MEMBER_OF */ public static final String LABELED_BY = new String("labeledBy"); /** * Indicates an object is a member of a group of one or more * target objects. * * @see #getTarget * @see #CONTROLLER_FOR * @see #CONTROLLED_BY * @see #LABEL_FOR * @see #LABELED_BY */ public static final String MEMBER_OF = new String("memberOf"); /** * Indicates an object is a controller for one or more target * objects. * * @see #getTarget * @see #CONTROLLED_BY * @see #LABEL_FOR * @see #LABELED_BY * @see #MEMBER_OF */ public static final String CONTROLLER_FOR = new String("controllerFor"); /** * Indicates an object is controlled by one or more target * objects. * * @see #getTarget * @see #CONTROLLER_FOR * @see #LABEL_FOR * @see #LABELED_BY * @see #MEMBER_OF */ public static final String CONTROLLED_BY = new String("controlledBy"); /** * Indicates an object is logically contiguous with a second * object where the second object occurs after the object. * An example is a paragraph of text that runs to the end of * a page and continues on the next page with an intervening * text footer and/or text header. The two parts of * the paragraph are separate text elements but are related * in that the second element is a continuation * of the first * element. In other words, the first element "flows to" * the second element. * * @since 1.5 */ public static final String FLOWS_TO = "flowsTo"; /** * Indicates an object is logically contiguous with a second * object where the second object occurs before the object. * An example is a paragraph of text that runs to the end of * a page and continues on the next page with an intervening * text footer and/or text header. The two parts of * the paragraph are separate text elements but are related * in that the second element is a continuation of the first * element. In other words, the second element "flows from" * the second element. * * @since 1.5 */ public static final String FLOWS_FROM = "flowsFrom"; /** * Indicates that an object is a subwindow of one or more * objects. * * @since 1.5 */ public static final String SUBWINDOW_OF = "subwindowOf"; /** * Indicates that an object is a parent window of one or more * objects. * * @since 1.5 */ public static final String PARENT_WINDOW_OF = "parentWindowOf"; /** * Indicates that an object has one or more objects * embedded in it. * * @since 1.5 */ public static final String EMBEDS = "embeds"; /** * Indicates that an object is embedded in one or more * objects. * * @since 1.5 */ public static final String EMBEDDED_BY = "embeddedBy"; /** * Indicates that an object is a child node of one * or more objects. * * @since 1.5 */ public static final String CHILD_NODE_OF = "childNodeOf"; /** * Identifies that the target group for a label has changed */ public static final String LABEL_FOR_PROPERTY = "labelForProperty"; /** * Identifies that the objects that are doing the labeling have changed */ public static final String LABELED_BY_PROPERTY = "labeledByProperty"; /** * Identifies that group membership has changed. */ public static final String MEMBER_OF_PROPERTY = "memberOfProperty"; /** * Identifies that the controller for the target object has changed */ public static final String CONTROLLER_FOR_PROPERTY = "controllerForProperty"; /** * Identifies that the target object that is doing the controlling has * changed */ public static final String CONTROLLED_BY_PROPERTY = "controlledByProperty"; /** * Indicates the FLOWS_TO relation between two objects * has changed. * * @since 1.5 */ public static final String FLOWS_TO_PROPERTY = "flowsToProperty"; /** * Indicates the FLOWS_FROM relation between two objects * has changed. * * @since 1.5 */ public static final String FLOWS_FROM_PROPERTY = "flowsFromProperty"; /** * Indicates the SUBWINDOW_OF relation between two or more objects * has changed. * * @since 1.5 */ public static final String SUBWINDOW_OF_PROPERTY = "subwindowOfProperty"; /** * Indicates the PARENT_WINDOW_OF relation between two or more objects * has changed. * * @since 1.5 */ public static final String PARENT_WINDOW_OF_PROPERTY = "parentWindowOfProperty"; /** * Indicates the EMBEDS relation between two or more objects * has changed. * * @since 1.5 */ public static final String EMBEDS_PROPERTY = "embedsProperty"; /** * Indicates the EMBEDDED_BY relation between two or more objects * has changed. * * @since 1.5 */ public static final String EMBEDDED_BY_PROPERTY = "embeddedByProperty"; /** * Indicates the CHILD_NODE_OF relation between two or more objects * has changed. * * @since 1.5 */ public static final String CHILD_NODE_OF_PROPERTY = "childNodeOfProperty"; /** * Create a new AccessibleRelation using the given locale independent key. * The key String should be a locale independent key for the relation. * It is not intended to be used as the actual String to display * to the user. To get the localized string, use toDisplayString. * * @param key the locale independent name of the relation. * @see AccessibleBundle#toDisplayString */ public AccessibleRelation(String key) { this.key = key; this.target = null; } /** * Creates a new AccessibleRelation using the given locale independent key. * The key String should be a locale independent key for the relation. * It is not intended to be used as the actual String to display * to the user. To get the localized string, use toDisplayString. * * @param key the locale independent name of the relation. * @param target the target object for this relation * @see AccessibleBundle#toDisplayString */ public AccessibleRelation(String key, Object target) { this.key = key; this.target = new Object[1]; this.target[0] = target; } /** * Creates a new AccessibleRelation using the given locale independent key. * The key String should be a locale independent key for the relation. * It is not intended to be used as the actual String to display * to the user. To get the localized string, use toDisplayString. * * @param key the locale independent name of the relation. * @param target the target object(s) for this relation * @see AccessibleBundle#toDisplayString */ public AccessibleRelation(String key, Object [] target) { this.key = key; this.target = target; } /** * Returns the key for this relation * * @return the key for this relation * * @see #CONTROLLER_FOR * @see #CONTROLLED_BY * @see #LABEL_FOR * @see #LABELED_BY * @see #MEMBER_OF */ public String getKey() { return this.key; } /** * Returns the target objects for this relation * * @return an array containing the target objects for this relation */ public Object [] getTarget() { if (target == null) { target = new Object[0]; } Object [] retval = new Object[target.length]; for (int i = 0; i < target.length; i++) { retval[i] = target[i]; } return retval; } /** * Sets the target object for this relation * * @param target the target object for this relation */ public void setTarget(Object target) { this.target = new Object[1]; this.target[0] = target; } /** * Sets the target objects for this relation * * @param target an array containing the target objects for this relation */ public void setTarget(Object [] target) { this.target = target; } }