1 /* AccessibleRelation.java -- the relation between accessible objects
2 Copyright (C) 2002, 2005 Free Software Foundation
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax
.accessibility
;
40 import java
.util
.Locale
;
43 * The relation between one accessible object and one or more other objects.
44 * For example, a button may control an action. An AccessibleRelationSet
45 * summarizes all relations of the object. This strongly typed "enumeration"
46 * supports localized strings. If the constants of this class are not
47 * adequate, new ones may be added in a similar matter.
49 * @author Eric Blake (ebb9@email.byu.edu)
51 * @status updated to 1.4
53 public class AccessibleRelation
extends AccessibleBundle
56 * Indicates the object labels other objects.
59 * @see #CONTROLLER_FOR
64 public static final String LABEL_FOR
;
67 * Indicates the object is labeled by other objects.
70 * @see #CONTROLLER_FOR
75 public static final String LABELED_BY
;
78 * Indicates an object is a member of a group of target objects.
81 * @see #CONTROLLER_FOR
86 public static final String MEMBER_OF
;
89 * Indicates an object is a controller for other objects.
97 public static final String CONTROLLER_FOR
;
100 * Indicates an object is controlled by other objects.
103 * @see #CONTROLLER_FOR
108 public static final String CONTROLLED_BY
;
110 /** Indicates that the label target group has changed. */
111 public static final String LABEL_FOR_PROPERTY
= "labelForProperty";
113 /** Indicates that the labelling objects have changed. */
114 public static final String LABELED_BY_PROPERTY
= "labeledByProperty";
116 /** Indicates that group membership has changed. */
117 public static final String MEMBER_OF_PROPERTY
= "memberOfProperty";
119 /** Indicates that the controller target group has changed. */
120 public static final String CONTROLLER_FOR_PROPERTY
= "controllerForProperty";
122 /** Indicates that the controlling objects have changed. */
123 public static final String CONTROLLED_BY_PROPERTY
= "controlledByProperty";
126 * Indicates that an object is a child of another object.
129 public static final String CHILD_NODE_OF
= "childNodeOf";
132 * Indicates that the ancestry relationship has changed.
135 public static final String CHILD_NODE_OF_PROPERTY
= "childNodeOfProperty";
138 * Indicates that an object is embedded by another object.
141 public static final String EMBEDDED_BY
= "embeddedBy";
144 * Indicates that the {@link #EMBEDDED_BY} property changed.
147 public static final String EMBEDDED_BY_PROPERTY
= "embeddedByProperty";
150 * Indicates that an object embeds another object.
153 public static final String EMBEDS
= "embeds";
156 * Indicates that the {@link #EMBEDS} property changed.
159 public static final String EMBEDS_PROPERTY
= "embedsProperty";
162 * Indicates that one object directly follows another object,
163 * as in a paragraph flow.
166 public static final String FLOWS_FROM
= "flowsFrom";
169 * Indicates that the {@link #FLOWS_FROM} property changed.
172 public static final String FLOWS_FROM_PROPERTY
= "flowsFromProperty";
175 * Indicates that one object comes directly before another object,
176 * as in a paragraph flow.
179 public static final String FLOWS_TO
= "flowsTo";
182 * Indicates that the {@link #FLOWS_TO} property changed.
185 public static final String FLOWS_TO_PROPERTY
= "flowsToProperty";
188 * Indicates that one object is a parent window of another object.
191 public static final String PARENT_WINDOW_OF
= "parentWindowOf";
194 * Indicates that the {@link #PARENT_WINDOW_OF} property changed.
197 public static final String PARENT_WINDOW_OF_PROPERTY
= "parentWindowOfProperty";
200 * Indicates that one object is a subwindow of another object.
203 public static final String SUBWINDOW_OF
= "subwindowOf";
206 * Indicates that the {@link #SUBWINDOW_OF} property changed.
209 public static final String SUBWINDOW_OF_PROPERTY
= "subwindowOfProperty";
211 /** An empty set of targets. */
212 private static final Object
[] EMPTY_TARGETS
= { };
216 // not constants in JDK
217 LABEL_FOR
= "labelFor";
218 LABELED_BY
= "labeledBy";
219 MEMBER_OF
= "memberOf";
220 CONTROLLER_FOR
= "controllerFor";
221 CONTROLLED_BY
= "controlledBy";
225 * The related objects.
228 * @see #setTarget(Object)
229 * @see #setTarget(Object[])
234 * Create a new relation with a locale independent key, and no related
237 * @param key the name of the role
238 * @see #toDisplayString(String, Locale)
240 public AccessibleRelation(String key
)
243 targets
= EMPTY_TARGETS
;
247 * Create a new relation with a locale independent key, and a single related
250 * @param key the name of the role
251 * @param target the related object
252 * @see #toDisplayString(String, Locale)
254 public AccessibleRelation(String key
, Object target
)
257 targets
= new Object
[] { target
};
261 * Create a new relation with a locale independent key, and the given
264 * @param key the name of the role
265 * @param targets the related objects
266 * @see #toDisplayString(String, Locale)
268 public AccessibleRelation(String key
, Object
[] targets
)
271 this.targets
= targets
== null ? EMPTY_TARGETS
: targets
;
275 * Return the key for this relation.
278 * @see #CONTROLLER_FOR
279 * @see #CONTROLLED_BY
284 public String
getKey()
290 * Return the targets of this relation.
292 * @return the targets, may be empty, but never null
294 public Object
[] getTarget()
300 * Set the target to a single object.
302 * @param target the new target
304 public void setTarget(Object target
)
306 targets
= new Object
[] { target
};
310 * Set the target to an array of objects.
312 * @param targets the new targets
314 public void setTarget(Object
[] targets
)
316 this.targets
= targets
== null ? EMPTY_TARGETS
: targets
;
318 } // class AccessibleRelation