1 /*
2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package javax.accessibility;
27 
28 import java.awt.IllegalComponentStateException;
29 import java.beans.BeanProperty;
30 import java.beans.JavaBean;
31 import java.beans.PropertyChangeEvent;
32 import java.beans.PropertyChangeListener;
33 import java.beans.PropertyChangeSupport;
34 import java.util.Locale;
35 
36 import sun.awt.AWTAccessor;
37 import sun.awt.AppContext;
38 
39 /**
40  * {@code AccessibleContext} represents the minimum information all accessible
41  * objects return. This information includes the accessible name, description,
42  * role, and state of the object, as well as information about its parent and
43  * children. {@code AccessibleContext} also contains methods for obtaining more
44  * specific accessibility information about a component. If the component
45  * supports them, these methods will return an object that implements one or
46  * more of the following interfaces:
47  * <ul>
48  *   <li>{@link AccessibleAction} - the object can perform one or more actions.
49  *   This interface provides the standard mechanism for an assistive technology
50  *   to determine what those actions are and tell the object to perform them.
51  *   Any object that can be manipulated should support this interface.
52  *   <li>{@link AccessibleComponent} - the object has a graphical
53  *   representation. This interface provides the standard mechanism for an
54  *   assistive technology to determine and set the graphical representation of
55  *   the object. Any object that is rendered on the screen should support this
56  *   interface.
57  *   <li>{@link AccessibleSelection} - the object allows its children to be
58  *   selected. This interface provides the standard mechanism for an assistive
59  *   technology to determine the currently selected children of the object as
60  *   well as modify its selection set. Any object that has children that can be
61  *   selected should support this interface.
62  *   <li>{@link AccessibleText} - the object presents editable textual
63  *   information on the display. This interface provides the standard mechanism
64  *   for an assistive technology to access that text via its content,
65  *   attributes, and spatial location. Any object that contains editable text
66  *   should support this interface.
67  *   <li>{@link AccessibleValue} - the object supports a numerical value. This
68  *   interface provides the standard mechanism for an assistive technology to
69  *   determine and set the current value of the object, as well as obtain its
70  *   minimum and maximum values. Any object that supports a numerical value
71  *   should support this interface.
72  * </ul>
73  *
74  * @author Peter Korn
75  * @author Hans Muller
76  * @author Willie Walker
77  * @author Lynn Monsanto
78  */
79 @JavaBean(description = "Minimal information that all accessible objects return")
80 public abstract class AccessibleContext {
81 
82     /**
83      * The {@code AppContext} that should be used to dispatch events for this
84      * {@code AccessibleContext}.
85      */
86     private volatile AppContext targetAppContext;
87 
88     static {
AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() { @Override public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) { accessibleContext.targetAppContext = appContext; } @Override public AppContext getAppContext(AccessibleContext accessibleContext) { return accessibleContext.targetAppContext; } @Override public Object getNativeAXResource(AccessibleContext accessibleContext) { return accessibleContext.nativeAXResource; } @Override public void setNativeAXResource(AccessibleContext accessibleContext, Object value) { accessibleContext.nativeAXResource = value; } })89         AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() {
90             @Override
91             public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) {
92                 accessibleContext.targetAppContext = appContext;
93             }
94 
95             @Override
96             public AppContext getAppContext(AccessibleContext accessibleContext) {
97                 return accessibleContext.targetAppContext;
98             }
99 
100             @Override
101             public Object getNativeAXResource(AccessibleContext accessibleContext) {
102                 return accessibleContext.nativeAXResource;
103             }
104 
105             @Override
106             public void setNativeAXResource(AccessibleContext accessibleContext, Object value) {
107                 accessibleContext.nativeAXResource = value;
108             }
109         });
110     }
111 
112     /**
113      * Constant used to determine when the {@link #accessibleName} property has
114      * changed. The old value in the {@code PropertyChangeEvent} will be the old
115      * {@code accessibleName} and the new value will be the new
116      * {@code accessibleName}.
117      *
118      * @see #getAccessibleName
119      * @see #addPropertyChangeListener
120      */
121     public static final String ACCESSIBLE_NAME_PROPERTY = "AccessibleName";
122 
123     /**
124      * Constant used to determine when the {@link #accessibleDescription}
125      * property has changed. The old value in the {@code PropertyChangeEvent}
126      * will be the old {@code accessibleDescription} and the new value will be
127      * the new {@code accessibleDescription}.
128      *
129      * @see #getAccessibleDescription
130      * @see #addPropertyChangeListener
131      */
132     public static final String ACCESSIBLE_DESCRIPTION_PROPERTY = "AccessibleDescription";
133 
134     /**
135      * Constant used to determine when the {@code accessibleStateSet} property
136      * has changed. The old value will be the old {@code AccessibleState} and
137      * the new value will be the new {@code AccessibleState} in the
138      * {@code accessibleStateSet}. For example, if a component that supports the
139      * vertical and horizontal states changes its orientation from vertical to
140      * horizontal, the old value will be {@code AccessibleState.VERTICAL} and
141      * the new value will be {@code AccessibleState.HORIZONTAL}. Please note
142      * that either value can also be {@code null}. For example, when a component
143      * changes from being enabled to disabled, the old value will be
144      * {@code AccessibleState.ENABLED} and the new value will be {@code null}.
145      *
146      * @see #getAccessibleStateSet
147      * @see AccessibleState
148      * @see AccessibleStateSet
149      * @see #addPropertyChangeListener
150      */
151     public static final String ACCESSIBLE_STATE_PROPERTY = "AccessibleState";
152 
153     /**
154      * Constant used to determine when the {@code accessibleValue} property has
155      * changed. The old value in the {@code PropertyChangeEvent} will be a
156      * {@code Number} representing the old value and the new value will be a
157      * {@code Number} representing the new value.
158      *
159      * @see #getAccessibleValue
160      * @see #addPropertyChangeListener
161      */
162     public static final String ACCESSIBLE_VALUE_PROPERTY = "AccessibleValue";
163 
164     /**
165      * Constant used to determine when the {@code accessibleSelection} has
166      * changed. The old and new values in the {@code PropertyChangeEvent} are
167      * currently reserved for future use.
168      *
169      * @see #getAccessibleSelection
170      * @see #addPropertyChangeListener
171      */
172     public static final String ACCESSIBLE_SELECTION_PROPERTY = "AccessibleSelection";
173 
174     /**
175      * Constant used to determine when the {@code accessibleText} caret has
176      * changed. The old value in the {@code PropertyChangeEvent} will be an
177      * integer representing the old caret position, and the new value will be an
178      * integer representing the new/current caret position.
179      *
180      * @see #addPropertyChangeListener
181      */
182     public static final String ACCESSIBLE_CARET_PROPERTY = "AccessibleCaret";
183 
184     /**
185      * Constant used to determine when the visual appearance of the object has
186      * changed. The old and new values in the {@code PropertyChangeEvent} are
187      * currently reserved for future use.
188      *
189      * @see #addPropertyChangeListener
190      */
191     public static final String ACCESSIBLE_VISIBLE_DATA_PROPERTY = "AccessibleVisibleData";
192 
193     /**
194      * Constant used to determine when {@code Accessible} children are
195      * added/removed from the object. If an {@code Accessible} child is being
196      * added, the old value will be {@code null} and the new value will be the
197      * {@code Accessible} child. If an {@code Accessible} child is being
198      * removed, the old value will be the {@code Accessible} child, and the new
199      * value will be {@code null}.
200      *
201      * @see #addPropertyChangeListener
202      */
203     public static final String ACCESSIBLE_CHILD_PROPERTY = "AccessibleChild";
204 
205     /**
206      * Constant used to determine when the active descendant of a component has
207      * changed. The active descendant is used for objects such as list, tree,
208      * and table, which may have transient children. When the active descendant
209      * has changed, the old value of the property change event will be the
210      * {@code Accessible} representing the previous active child, and the new
211      * value will be the {@code Accessible} representing the current active
212      * child.
213      *
214      * @see #addPropertyChangeListener
215      */
216     public static final String ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY = "AccessibleActiveDescendant";
217 
218     /**
219      * Constant used to indicate that the table caption has changed. The old
220      * value in the {@code PropertyChangeEvent} will be an {@code Accessible}
221      * representing the previous table caption and the new value will be an
222      * {@code Accessible} representing the new table caption.
223      *
224      * @see Accessible
225      * @see AccessibleTable
226      */
227     public static final String ACCESSIBLE_TABLE_CAPTION_CHANGED =
228         "accessibleTableCaptionChanged";
229 
230     /**
231      * Constant used to indicate that the table summary has changed. The old
232      * value in the {@code PropertyChangeEvent} will be an {@code Accessible}
233      * representing the previous table summary and the new value will be an
234      * {@code Accessible} representing the new table summary.
235      *
236      * @see Accessible
237      * @see AccessibleTable
238      */
239     public static final String ACCESSIBLE_TABLE_SUMMARY_CHANGED =
240         "accessibleTableSummaryChanged";
241 
242     /**
243      * Constant used to indicate that table data has changed. The old value in
244      * the {@code PropertyChangeEvent} will be {@code null} and the new value
245      * will be an {@code AccessibleTableModelChange} representing the table
246      * change.
247      *
248      * @see AccessibleTable
249      * @see AccessibleTableModelChange
250      */
251     public static final String ACCESSIBLE_TABLE_MODEL_CHANGED =
252         "accessibleTableModelChanged";
253 
254     /**
255      * Constant used to indicate that the row header has changed. The old value
256      * in the {@code PropertyChangeEvent} will be {@code null} and the new value
257      * will be an {@code AccessibleTableModelChange} representing the header
258      * change.
259      *
260      * @see AccessibleTable
261      * @see AccessibleTableModelChange
262      */
263     public static final String ACCESSIBLE_TABLE_ROW_HEADER_CHANGED =
264         "accessibleTableRowHeaderChanged";
265 
266     /**
267      * Constant used to indicate that the row description has changed. The old
268      * value in the {@code PropertyChangeEvent} will be {@code null} and the new
269      * value will be an {@code Integer} representing the row index.
270      *
271      * @see AccessibleTable
272      */
273     public static final String ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED =
274         "accessibleTableRowDescriptionChanged";
275 
276     /**
277      * Constant used to indicate that the column header has changed. The old
278      * value in the {@code PropertyChangeEvent} will be {@code null} and the new
279      * value will be an {@code AccessibleTableModelChange} representing the
280      * header change.
281      *
282      * @see AccessibleTable
283      * @see AccessibleTableModelChange
284      */
285     public static final String ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED =
286         "accessibleTableColumnHeaderChanged";
287 
288     /**
289      * Constant used to indicate that the column description has changed. The
290      * old value in the {@code PropertyChangeEvent} will be {@code null} and the
291      * new value will be an {@code Integer} representing the column index.
292      *
293      * @see AccessibleTable
294      */
295     public static final String ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED =
296         "accessibleTableColumnDescriptionChanged";
297 
298     /**
299      * Constant used to indicate that the supported set of actions has changed.
300      * The old value in the {@code PropertyChangeEvent} will be an
301      * {@code Integer} representing the old number of actions supported and the
302      * new value will be an {@code Integer} representing the new number of
303      * actions supported.
304      *
305      * @see AccessibleAction
306      */
307     public static final String ACCESSIBLE_ACTION_PROPERTY =
308         "accessibleActionProperty";
309 
310     /**
311      * Constant used to indicate that a hypertext element has received focus.
312      * The old value in the {@code PropertyChangeEvent} will be an
313      * {@code Integer} representing the start index in the document of the
314      * previous element that had focus and the new value will be an
315      * {@code Integer} representing the start index in the document of the
316      * current element that has focus. A value of -1 indicates that an element
317      * does not or did not have focus.
318      *
319      * @see AccessibleHyperlink
320      */
321     public static final String ACCESSIBLE_HYPERTEXT_OFFSET =
322         "AccessibleHypertextOffset";
323 
324     /**
325      * {@code PropertyChangeEvent} which indicates that text has changed.
326      * <br>
327      * For text insertion, the {@code oldValue} is {@code null} and the
328      * {@code newValue} is an {@code AccessibleTextSequence} specifying the text
329      * that was inserted.
330      * <br>
331      * For text deletion, the {@code oldValue} is an
332      * {@code AccessibleTextSequence} specifying the text that was deleted and
333      * the {@code newValue} is {@code null}.
334      * <br>
335      * For text replacement, the {@code oldValue} is an
336      * {@code AccessibleTextSequence} specifying the old text and the
337      * {@code newValue} is an {@code AccessibleTextSequence} specifying the new
338      * text.
339      *
340      * @see #getAccessibleText
341      * @see #addPropertyChangeListener
342      * @see AccessibleTextSequence
343      */
344     public static final String ACCESSIBLE_TEXT_PROPERTY
345         = "AccessibleText";
346 
347     /**
348      * {@code PropertyChangeEvent} which indicates that a significant change has
349      * occurred to the children of a component like a tree or text. This change
350      * notifies the event listener that it needs to reacquire the state of the
351      * subcomponents. The {@code oldValue} is {@code null} and the
352      * {@code newValue} is the component whose children have become invalid.
353      *
354      * @see #getAccessibleText
355      * @see #addPropertyChangeListener
356      * @see AccessibleTextSequence
357      * @since 1.5
358      */
359     public static final String ACCESSIBLE_INVALIDATE_CHILDREN =
360         "accessibleInvalidateChildren";
361 
362     /**
363      * {@code PropertyChangeEvent} which indicates that text attributes have
364      * changed.
365      * <br>
366      * For attribute insertion, the {@code oldValue} is {@code null} and the
367      * {@code newValue} is an {@code AccessibleAttributeSequence} specifying the
368      * attributes that were inserted.
369      * <br>
370      * For attribute deletion, the {@code oldValue} is an
371      * {@code AccessibleAttributeSequence} specifying the attributes that were
372      * deleted and the {@code newValue} is {@code null}.
373      * <br>
374      * For attribute replacement, the {@code oldValue} is an
375      * {@code AccessibleAttributeSequence} specifying the old attributes and the
376      * {@code newValue} is an {@code AccessibleAttributeSequence} specifying the
377      * new attributes.
378      *
379      * @see #getAccessibleText
380      * @see #addPropertyChangeListener
381      * @see AccessibleAttributeSequence
382      * @since 1.5
383      */
384     public static final String ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED =
385         "accessibleTextAttributesChanged";
386 
387     /**
388      * {@code PropertyChangeEvent} which indicates that a change has occurred in
389      * a component's bounds. The {@code oldValue} is the old component bounds
390      * and the {@code newValue} is the new component bounds.
391      *
392      * @see #addPropertyChangeListener
393      * @since 1.5
394      */
395     public static final String ACCESSIBLE_COMPONENT_BOUNDS_CHANGED =
396         "accessibleComponentBoundsChanged";
397 
398     /**
399      * The accessible parent of this object.
400      *
401      * @see #getAccessibleParent
402      * @see #setAccessibleParent
403      */
404     protected Accessible accessibleParent = null;
405 
406     /**
407      * A localized String containing the name of the object.
408      *
409      * @see #getAccessibleName
410      * @see #setAccessibleName
411      */
412     protected String accessibleName = null;
413 
414     /**
415      * A localized String containing the description of the object.
416      *
417      * @see #getAccessibleDescription
418      * @see #setAccessibleDescription
419      */
420     protected String accessibleDescription = null;
421 
422     /**
423      * Used to handle the listener list for property change events.
424      *
425      * @see #addPropertyChangeListener
426      * @see #removePropertyChangeListener
427      * @see #firePropertyChange
428      */
429     private PropertyChangeSupport accessibleChangeSupport = null;
430 
431     /**
432      * Used to represent the context's relation set.
433      *
434      * @see #getAccessibleRelationSet
435      */
436     private AccessibleRelationSet relationSet
437         = new AccessibleRelationSet();
438 
439     private Object nativeAXResource;
440 
441     /**
442      * Gets the {@code accessibleName} property of this object. The
443      * {@code accessibleName} property of an object is a localized
444      * {@code String} that designates the purpose of the object. For example,
445      * the {@code accessibleName} property of a label or button might be the
446      * text of the label or button itself. In the case of an object that doesn't
447      * display its name, the {@code accessibleName} should still be set. For
448      * example, in the case of a text field used to enter the name of a city,
449      * the {@code accessibleName} for the {@code en_US} locale could be 'city.'
450      *
451      * @return the localized name of the object; {@code null} if this object
452      *         does not have a name
453      * @see #setAccessibleName
454      */
getAccessibleName()455     public String getAccessibleName() {
456         return accessibleName;
457     }
458 
459     /**
460      * Sets the localized accessible name of this object. Changing the name will
461      * cause a {@code PropertyChangeEvent} to be fired for the
462      * {@code ACCESSIBLE_NAME_PROPERTY} property.
463      *
464      * @param  s the new localized name of the object
465      * @see #getAccessibleName
466      * @see #addPropertyChangeListener
467      */
468     @BeanProperty(preferred = true, description
469             = "Sets the accessible name for the component.")
setAccessibleName(String s)470     public void setAccessibleName(String s) {
471         String oldName = accessibleName;
472         accessibleName = s;
473         firePropertyChange(ACCESSIBLE_NAME_PROPERTY,oldName,accessibleName);
474     }
475 
476     /**
477      * Gets the {@code accessibleDescription} property of this object. The
478      * {@code accessibleDescription} property of this object is a short
479      * localized phrase describing the purpose of the object. For example, in
480      * the case of a 'Cancel' button, the {@code accessibleDescription} could be
481      * 'Ignore changes and close dialog box.'
482      *
483      * @return the localized description of the object; {@code null} if this
484      *         object does not have a description
485      * @see #setAccessibleDescription
486      */
getAccessibleDescription()487     public String getAccessibleDescription() {
488         return accessibleDescription;
489     }
490 
491     /**
492      * Sets the accessible description of this object. Changing the name will
493      * cause a {@code PropertyChangeEvent} to be fired for the
494      * {@code ACCESSIBLE_DESCRIPTION_PROPERTY} property.
495      *
496      * @param  s the new localized description of the object
497      * @see #setAccessibleName
498      * @see #addPropertyChangeListener
499      */
500     @BeanProperty(preferred = true, description
501             = "Sets the accessible description for the component.")
setAccessibleDescription(String s)502     public void setAccessibleDescription(String s) {
503         String oldDescription = accessibleDescription;
504         accessibleDescription = s;
505         firePropertyChange(ACCESSIBLE_DESCRIPTION_PROPERTY,
506                            oldDescription,accessibleDescription);
507     }
508 
509     /**
510      * Gets the role of this object. The role of the object is the generic
511      * purpose or use of the class of this object. For example, the role of a
512      * push button is {@code AccessibleRole.PUSH_BUTTON}. The roles in
513      * {@code AccessibleRole} are provided so component developers can pick from
514      * a set of predefined roles. This enables assistive technologies to provide
515      * a consistent interface to various tweaked subclasses of components (e.g.,
516      * use {@code AccessibleRole.PUSH_BUTTON} for all components that act like a
517      * push button) as well as distinguish between subclasses that behave
518      * differently (e.g., {@code AccessibleRole.CHECK_BOX} for check boxes and
519      * {@code AccessibleRole.RADIO_BUTTON} for radio buttons).
520      * <p>
521      * Note that the {@code AccessibleRole} class is also extensible, so custom
522      * component developers can define their own {@code AccessibleRole}'s if the
523      * set of predefined roles is inadequate.
524      *
525      * @return an instance of {@code AccessibleRole} describing the role of the
526      *         object
527      * @see AccessibleRole
528      */
getAccessibleRole()529     public abstract AccessibleRole getAccessibleRole();
530 
531     /**
532      * Gets the state set of this object. The {@code AccessibleStateSet} of an
533      * object is composed of a set of unique {@code AccessibleStates}. A change
534      * in the {@code AccessibleStateSet} of an object will cause a
535      * {@code PropertyChangeEvent} to be fired for the
536      * {@code ACCESSIBLE_STATE_PROPERTY} property.
537      *
538      * @return an instance of {@code AccessibleStateSet} containing the current
539      *         state set of the object
540      * @see AccessibleStateSet
541      * @see AccessibleState
542      * @see #addPropertyChangeListener
543      */
getAccessibleStateSet()544     public abstract AccessibleStateSet getAccessibleStateSet();
545 
546     /**
547      * Gets the {@code Accessible} parent of this object.
548      *
549      * @return the {@code Accessible} parent of this object; {@code null} if
550      *         this object does not have an {@code Accessible} parent
551      */
getAccessibleParent()552     public Accessible getAccessibleParent() {
553         return accessibleParent;
554     }
555 
556     /**
557      * Sets the {@code Accessible} parent of this object. This is meant to be
558      * used only in the situations where the actual component's parent should
559      * not be treated as the component's accessible parent and is a method that
560      * should only be called by the parent of the accessible child.
561      *
562      * @param  a - {@code Accessible} to be set as the parent
563      */
setAccessibleParent(Accessible a)564     public void setAccessibleParent(Accessible a) {
565         accessibleParent = a;
566     }
567 
568     /**
569      * Gets the 0-based index of this object in its accessible parent.
570      *
571      * @return the 0-based index of this object in its parent; -1 if this object
572      *         does not have an accessible parent.
573      * @see #getAccessibleParent
574      * @see #getAccessibleChildrenCount
575      * @see #getAccessibleChild
576      */
getAccessibleIndexInParent()577     public abstract int getAccessibleIndexInParent();
578 
579     /**
580      * Returns the number of accessible children of the object.
581      *
582      * @return the number of accessible children of the object.
583      */
getAccessibleChildrenCount()584     public abstract int getAccessibleChildrenCount();
585 
586     /**
587      * Returns the specified {@code Accessible} child of the object. The
588      * {@code Accessible} children of an {@code Accessible} object are
589      * zero-based, so the first child of an {@code Accessible} child is at index
590      * 0, the second child is at index 1, and so on.
591      *
592      * @param  i zero-based index of child
593      * @return the {@code Accessible} child of the object
594      * @see #getAccessibleChildrenCount
595      */
getAccessibleChild(int i)596     public abstract Accessible getAccessibleChild(int i);
597 
598     /**
599      * Gets the locale of the component. If the component does not have a
600      * locale, then the locale of its parent is returned.
601      *
602      * @return this component's locale. If this component does not have a
603      *         locale, the locale of its parent is returned.
604      * @throws IllegalComponentStateException If the component does not have its
605      *         own locale and has not yet been added to a containment hierarchy
606      *         such that the locale can be determined from the containing
607      *         parent
608      */
getLocale()609     public abstract Locale getLocale() throws IllegalComponentStateException;
610 
611     /**
612      * Adds a {@code PropertyChangeListener} to the listener list. The listener
613      * is registered for all {@code Accessible} properties and will be called
614      * when those properties change.
615      *
616      * @param  listener The PropertyChangeListener to be added
617      * @see #ACCESSIBLE_NAME_PROPERTY
618      * @see #ACCESSIBLE_DESCRIPTION_PROPERTY
619      * @see #ACCESSIBLE_STATE_PROPERTY
620      * @see #ACCESSIBLE_VALUE_PROPERTY
621      * @see #ACCESSIBLE_SELECTION_PROPERTY
622      * @see #ACCESSIBLE_TEXT_PROPERTY
623      * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
624      */
addPropertyChangeListener(PropertyChangeListener listener)625     public void addPropertyChangeListener(PropertyChangeListener listener) {
626         if (accessibleChangeSupport == null) {
627             accessibleChangeSupport = new PropertyChangeSupport(this);
628         }
629         accessibleChangeSupport.addPropertyChangeListener(listener);
630     }
631 
632     /**
633      * Removes a {@code PropertyChangeListener} from the listener list. This
634      * removes a {@code PropertyChangeListener} that was registered for all
635      * properties.
636      *
637      * @param  listener The PropertyChangeListener to be removed
638      */
removePropertyChangeListener(PropertyChangeListener listener)639     public void removePropertyChangeListener(PropertyChangeListener listener) {
640         if (accessibleChangeSupport != null) {
641             accessibleChangeSupport.removePropertyChangeListener(listener);
642         }
643     }
644 
645     /**
646      * Gets the {@code AccessibleAction} associated with this object that
647      * supports one or more actions.
648      *
649      * @return {@code AccessibleAction} if supported by object; else return
650      *         {@code null}
651      * @see AccessibleAction
652      */
getAccessibleAction()653     public AccessibleAction getAccessibleAction() {
654         return null;
655     }
656 
657     /**
658      * Gets the {@code AccessibleComponent} associated with this object that has
659      * a graphical representation.
660      *
661      * @return {@code AccessibleComponent} if supported by object; else return
662      *         {@code null}
663      * @see AccessibleComponent
664      */
getAccessibleComponent()665     public AccessibleComponent getAccessibleComponent() {
666         return null;
667     }
668 
669     /**
670      * Gets the {@code AccessibleSelection} associated with this object which
671      * allows its {@code Accessible} children to be selected.
672      *
673      * @return {@code AccessibleSelection} if supported by object; else return
674      *         {@code null}
675      * @see AccessibleSelection
676      */
getAccessibleSelection()677     public AccessibleSelection getAccessibleSelection() {
678         return null;
679     }
680 
681     /**
682      * Gets the {@code AccessibleText} associated with this object presenting
683      * text on the display.
684      *
685      * @return {@code AccessibleText} if supported by object; else return
686      *         {@code null}
687      * @see AccessibleText
688      */
getAccessibleText()689     public AccessibleText getAccessibleText() {
690         return null;
691     }
692 
693     /**
694      * Gets the {@code AccessibleEditableText} associated with this object
695      * presenting editable text on the display.
696      *
697      * @return {@code AccessibleEditableText} if supported by object; else
698      *         return {@code null}
699      * @see AccessibleEditableText
700      * @since 1.4
701      */
getAccessibleEditableText()702     public AccessibleEditableText getAccessibleEditableText() {
703         return null;
704     }
705 
706     /**
707      * Gets the {@code AccessibleValue} associated with this object that
708      * supports a {@code Numerical} value.
709      *
710      * @return {@code AccessibleValue} if supported by object; else return
711      *         {@code null}
712      * @see AccessibleValue
713      */
getAccessibleValue()714     public AccessibleValue getAccessibleValue() {
715         return null;
716     }
717 
718     /**
719      * Gets the {@code AccessibleIcons} associated with an object that has one
720      * or more associated icons.
721      *
722      * @return an array of {@code AccessibleIcon} if supported by object;
723      *         otherwise return {@code null}
724      * @see AccessibleIcon
725      * @since 1.3
726      */
getAccessibleIcon()727     public AccessibleIcon [] getAccessibleIcon() {
728         return null;
729     }
730 
731     /**
732      * Gets the {@code AccessibleRelationSet} associated with an object.
733      *
734      * @return an {@code AccessibleRelationSet} if supported by object;
735      *         otherwise return {@code null}
736      * @see AccessibleRelationSet
737      * @since 1.3
738      */
getAccessibleRelationSet()739     public AccessibleRelationSet getAccessibleRelationSet() {
740         return relationSet;
741     }
742 
743     /**
744      * Gets the {@code AccessibleTable} associated with an object.
745      *
746      * @return an {@code AccessibleTable} if supported by object; otherwise return
747      *         {@code null}
748      * @see AccessibleTable
749      * @since 1.3
750      */
getAccessibleTable()751     public AccessibleTable getAccessibleTable() {
752         return null;
753     }
754 
755     /**
756      * Support for reporting bound property changes. If {@code oldValue} and
757      * {@code newValue} are not equal and the {@code PropertyChangeEvent}
758      * listener list is not empty, then fire a {@code PropertyChange} event to
759      * each listener. In general, this is for use by the {@code Accessible}
760      * objects themselves and should not be called by an application program.
761      *
762      * @param  propertyName The programmatic name of the property that was
763      *         changed
764      * @param  oldValue The old value of the property
765      * @param  newValue The new value of the property
766      * @see PropertyChangeSupport
767      * @see #addPropertyChangeListener
768      * @see #removePropertyChangeListener
769      * @see #ACCESSIBLE_NAME_PROPERTY
770      * @see #ACCESSIBLE_DESCRIPTION_PROPERTY
771      * @see #ACCESSIBLE_STATE_PROPERTY
772      * @see #ACCESSIBLE_VALUE_PROPERTY
773      * @see #ACCESSIBLE_SELECTION_PROPERTY
774      * @see #ACCESSIBLE_TEXT_PROPERTY
775      * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
776      */
firePropertyChange(String propertyName, Object oldValue, Object newValue)777     public void firePropertyChange(String propertyName,
778                                    Object oldValue,
779                                    Object newValue) {
780         if (accessibleChangeSupport != null) {
781             if (newValue instanceof PropertyChangeEvent) {
782                 PropertyChangeEvent pce = (PropertyChangeEvent)newValue;
783                 accessibleChangeSupport.firePropertyChange(pce);
784             } else {
785                 accessibleChangeSupport.firePropertyChange(propertyName,
786                                                            oldValue,
787                                                            newValue);
788             }
789         }
790     }
791 }
792