KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > accessibility > AccessibleRelation


1 /*
2  * @(#)AccessibleRelation.java 1.14 04/04/15
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.accessibility;
9
10 import java.util.Vector JavaDoc;
11 import java.util.Locale JavaDoc;
12 import java.util.MissingResourceException JavaDoc;
13 import java.util.ResourceBundle JavaDoc;
14
15 /**
16  * <P>Class AccessibleRelation describes a relation between the
17  * object that implements the AccessibleRelation and one or more other
18  * objects. The actual relations that an object has with other
19  * objects are defined as an AccessibleRelationSet, which is a composed
20  * set of AccessibleRelations.
21  * <p>The toDisplayString method allows you to obtain the localized string
22  * for a locale independent key from a predefined ResourceBundle for the
23  * keys defined in this class.
24  * <p>The constants in this class present a strongly typed enumeration
25  * of common object roles. If the constants in this class are not sufficient
26  * to describe the role of an object, a subclass should be generated
27  * from this class and it should provide constants in a similar manner.
28  *
29  * @version 1.14 04/15/04
30  * @author Lynn Monsanto
31  */

32 public class AccessibleRelation extends AccessibleBundle JavaDoc {
33
34     /*
35      * The group of objects that participate in the relation.
36      * The relation may be one-to-one or one-to-many. For
37      * example, in the case of a LABEL_FOR relation, the target
38      * vector would contain a list of objects labeled by the object
39      * that implements this AccessibleRelation. In the case of a
40      * MEMBER_OF relation, the target vector would contain all
41      * of the components that are members of the same group as the
42      * object that implements this AccessibleRelation.
43      */

44     private Object JavaDoc [] target = new Object JavaDoc[0];
45
46     /**
47      * Indicates an object is a label for one or more target objects.
48      *
49      * @see #getTarget
50      * @see #CONTROLLER_FOR
51      * @see #CONTROLLED_BY
52      * @see #LABELED_BY
53      * @see #MEMBER_OF
54      */

55     public static final String JavaDoc LABEL_FOR = new String JavaDoc("labelFor");
56
57     /**
58      * Indicates an object is labeled by one or more target objects.
59      *
60      * @see #getTarget
61      * @see #CONTROLLER_FOR
62      * @see #CONTROLLED_BY
63      * @see #LABEL_FOR
64      * @see #MEMBER_OF
65      */

66     public static final String JavaDoc LABELED_BY = new String JavaDoc("labeledBy");
67
68     /**
69      * Indicates an object is a member of a group of one or more
70      * target objects.
71      *
72      * @see #getTarget
73      * @see #CONTROLLER_FOR
74      * @see #CONTROLLED_BY
75      * @see #LABEL_FOR
76      * @see #LABELED_BY
77      */

78     public static final String JavaDoc MEMBER_OF = new String JavaDoc("memberOf");
79
80     /**
81      * Indicates an object is a controller for one or more target
82      * objects.
83      *
84      * @see #getTarget
85      * @see #CONTROLLED_BY
86      * @see #LABEL_FOR
87      * @see #LABELED_BY
88      * @see #MEMBER_OF
89      */

90     public static final String JavaDoc CONTROLLER_FOR = new String JavaDoc("controllerFor");
91
92     /**
93      * Indicates an object is controlled by one or more target
94      * objects.
95      *
96      * @see #getTarget
97      * @see #CONTROLLER_FOR
98      * @see #LABEL_FOR
99      * @see #LABELED_BY
100      * @see #MEMBER_OF
101      */

102     public static final String JavaDoc CONTROLLED_BY = new String JavaDoc("controlledBy");
103
104     /**
105      * Indicates an object is logically contiguous with a second
106      * object where the second object occurs after the object.
107      * An example is a paragraph of text that runs to the end of
108      * a page and continues on the next page with an intervening
109      * text footer and/or text header. The two parts of
110      * the paragraph are separate text elements but are related
111      * in that the second element is a continuation
112      * of the first
113      * element. In other words, the first element "flows to"
114      * the second element.
115      *
116      * @since 1.5
117      */

118     public static final String JavaDoc FLOWS_TO = "flowsTo";
119  
120     /**
121      * Indicates an object is logically contiguous with a second
122      * object where the second object occurs before the object.
123      * An example is a paragraph of text that runs to the end of
124      * a page and continues on the next page with an intervening
125      * text footer and/or text header. The two parts of
126      * the paragraph are separate text elements but are related
127      * in that the second element is a continuation of the first
128      * element. In other words, the second element "flows from"
129      * the second element.
130      *
131      * @since 1.5
132      */

133     public static final String JavaDoc FLOWS_FROM = "flowsFrom";
134  
135     /**
136      * Indicates that an object is a subwindow of one or more
137      * objects.
138      *
139      * @since 1.5
140      */

141     public static final String JavaDoc SUBWINDOW_OF = "subwindowOf";
142  
143     /**
144      * Indicates that an object is a parent window of one or more
145      * objects.
146      *
147      * @since 1.5
148      */

149     public static final String JavaDoc PARENT_WINDOW_OF = "parentWindowOf";
150  
151     /**
152      * Indicates that an object has one or more objects
153      * embedded in it.
154      *
155      * @since 1.5
156      */

157     public static final String JavaDoc EMBEDS = "embeds";
158  
159     /**
160      * Indicates that an object is embedded in one or more
161      * objects.
162      *
163      * @since 1.5
164      */

165     public static final String JavaDoc EMBEDDED_BY = "embeddedBy";
166  
167     /**
168      * Indicates that an object is a child node of one
169      * or more objects.
170      *
171      * @since 1.5
172      */

173     public static final String JavaDoc CHILD_NODE_OF = "childNodeOf";
174
175     /**
176      * Identifies that the target group for a label has changed
177      */

178     public static final String JavaDoc LABEL_FOR_PROPERTY = "labelForProperty";
179
180     /**
181      * Identifies that the objects that are doing the labeling have changed
182      */

183     public static final String JavaDoc LABELED_BY_PROPERTY = "labeledByProperty";
184
185     /**
186      * Identifies that group membership has changed.
187      */

188     public static final String JavaDoc MEMBER_OF_PROPERTY = "memberOfProperty";
189
190     /**
191      * Identifies that the controller for the target object has changed
192      */

193     public static final String JavaDoc CONTROLLER_FOR_PROPERTY = "controllerForProperty";
194
195     /**
196      * Identifies that the target object that is doing the controlling has
197      * changed
198      */

199     public static final String JavaDoc CONTROLLED_BY_PROPERTY = "controlledByProperty";
200     
201     /**
202      * Indicates the FLOWS_TO relation between two objects
203      * has changed.
204      *
205      * @since 1.5
206      */

207     public static final String JavaDoc FLOWS_TO_PROPERTY = "flowsToProperty";
208
209     /**
210      * Indicates the FLOWS_FROM relation between two objects
211      * has changed.
212      *
213      * @since 1.5
214      */

215     public static final String JavaDoc FLOWS_FROM_PROPERTY = "flowsFromProperty";
216     
217     /**
218      * Indicates the SUBWINDOW_OF relation between two or more objects
219      * has changed.
220      *
221      * @since 1.5
222      */

223     public static final String JavaDoc SUBWINDOW_OF_PROPERTY = "subwindowOfProperty";
224     
225     /**
226      * Indicates the PARENT_WINDOW_OF relation between two or more objects
227      * has changed.
228      *
229      * @since 1.5
230      */

231     public static final String JavaDoc PARENT_WINDOW_OF_PROPERTY = "parentWindowOfProperty";
232     
233     /**
234      * Indicates the EMBEDS relation between two or more objects
235      * has changed.
236      *
237      * @since 1.5
238      */

239     public static final String JavaDoc EMBEDS_PROPERTY = "embedsProperty";
240     
241     /**
242      * Indicates the EMBEDDED_BY relation between two or more objects
243      * has changed.
244      *
245      * @since 1.5
246      */

247     public static final String JavaDoc EMBEDDED_BY_PROPERTY = "embeddedByProperty";
248     
249     /**
250      * Indicates the CHILD_NODE_OF relation between two or more objects
251      * has changed.
252      *
253      * @since 1.5
254      */

255     public static final String JavaDoc CHILD_NODE_OF_PROPERTY = "childNodeOfProperty";
256
257     /**
258      * Create a new AccessibleRelation using the given locale independent key.
259      * The key String should be a locale independent key for the relation.
260      * It is not intended to be used as the actual String to display
261      * to the user. To get the localized string, use toDisplayString.
262      *
263      * @param key the locale independent name of the relation.
264      * @see AccessibleBundle#toDisplayString
265      */

266     public AccessibleRelation(String JavaDoc key) {
267         this.key = key;
268     this.target = null;
269     }
270
271     /**
272      * Creates a new AccessibleRelation using the given locale independent key.
273      * The key String should be a locale independent key for the relation.
274      * It is not intended to be used as the actual String to display
275      * to the user. To get the localized string, use toDisplayString.
276      *
277      * @param key the locale independent name of the relation.
278      * @param target the target object for this relation
279      * @see AccessibleBundle#toDisplayString
280      */

281     public AccessibleRelation(String JavaDoc key, Object JavaDoc target) {
282         this.key = key;
283     this.target = new Object JavaDoc[1];
284     this.target[0] = target;
285     }
286
287     /**
288      * Creates a new AccessibleRelation using the given locale independent key.
289      * The key String should be a locale independent key for the relation.
290      * It is not intended to be used as the actual String to display
291      * to the user. To get the localized string, use toDisplayString.
292      *
293      * @param key the locale independent name of the relation.
294      * @param target the target object(s) for this relation
295      * @see AccessibleBundle#toDisplayString
296      */

297     public AccessibleRelation(String JavaDoc key, Object JavaDoc [] target) {
298         this.key = key;
299     this.target = target;
300     }
301
302     /**
303      * Returns the key for this relation
304      *
305      * @return the key for this relation
306      *
307      * @see #CONTROLLER_FOR
308      * @see #CONTROLLED_BY
309      * @see #LABEL_FOR
310      * @see #LABELED_BY
311      * @see #MEMBER_OF
312      */

313     public String JavaDoc getKey() {
314     return this.key;
315     }
316
317     /**
318      * Returns the target objects for this relation
319      *
320      * @return an array containing the target objects for this relation
321      */

322     public Object JavaDoc [] getTarget() {
323         if (target == null) {
324         target = new Object JavaDoc[0];
325     }
326     Object JavaDoc [] retval = new Object JavaDoc[target.length];
327     for (int i = 0; i < target.length; i++) {
328         retval[i] = target[i];
329     }
330     return retval;
331     }
332
333     /**
334      * Sets the target object for this relation
335      *
336      * @param target the target object for this relation
337      */

338     public void setTarget(Object JavaDoc target) {
339     this.target = new Object JavaDoc[1];
340     this.target[0] = target;
341     }
342
343     /**
344      * Sets the target objects for this relation
345      *
346      * @param target an array containing the target objects for this relation
347      */

348     public void setTarget(Object JavaDoc [] target) {
349     this.target = target;
350     }
351 }
352
Popular Tags