1 /*
2 * Copyright 1998-2000 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package javax.accessibility;
27
28
29 import java.util;
30 import java.awt;
31 import javax.swing.text;
32
33
34 /**
35 * Encapsulation of a link, or set of links (e.g. client side imagemap)
36 * in a Hypertext document
37 *
38 * @see Accessible
39 * @see Accessible#getAccessibleContext
40 * @see AccessibleContext
41 * @see AccessibleText
42 * @see AccessibleContext#getAccessibleText
43 *
44 * @author Peter Korn
45 */
46 public abstract class AccessibleHyperlink implements AccessibleAction {
47
48 /**
49 * Since the document a link is associated with may have
50 * changed, this method returns whether or not this Link is still valid
51 * (with respect to the document it references).
52 *
53 * @return a flag indicating whether this link is still valid with
54 * respect to the AccessibleHypertext it belongs to
55 */
56 public abstract boolean isValid();
57
58 /**
59 * Returns the number of accessible actions available in this Link
60 * If there are more than one, the first one is NOT considered the
61 * "default" action of this LINK object (e.g. in an HTML imagemap).
62 * In general, links will have only one AccessibleAction in them.
63 *
64 * @return the zero-based number of Actions in this object
65 */
66 public abstract int getAccessibleActionCount();
67
68 /**
69 * Performs the specified Action on the object
70 *
71 * @param i zero-based index of actions
72 * @return true if the action was performed; otherwise false.
73 * @see #getAccessibleActionCount
74 */
75 public abstract boolean doAccessibleAction(int i);
76
77 /**
78 * Returns a String description of this particular
79 * link action. This should be a text string
80 * associated with anchoring text, this should be the
81 * anchor text. E.g. from HTML:
82 * <a HREF="http://www.sun.com/access">Accessibility</a>
83 * this method would return "Accessibility".
84 *
85 * Similarly, from this HTML:
86 * <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a>
87 * this method would return "top hat"
88 *
89 * @param i zero-based index of the actions
90 * @return a String description of the action
91 * @see #getAccessibleActionCount
92 */
93 public abstract String getAccessibleActionDescription(int i);
94
95 /**
96 * Returns an object that represents the link action,
97 * as appropriate for that link. E.g. from HTML:
98 * <a HREF="http://www.sun.com/access">Accessibility</a>
99 * this method would return a
100 * java.net.URL("http://www.sun.com/access.html");
101 *
102 * @param i zero-based index of the actions
103 * @return an Object representing the hypertext link itself
104 * @see #getAccessibleActionCount
105 */
106 public abstract Object getAccessibleActionObject(int i);
107
108 /**
109 * Returns an object that represents the link anchor,
110 * as appropriate for that link. E.g. from HTML:
111 * <a href="http://www.sun.com/access">Accessibility</a>
112 * this method would return a String containing the text:
113 * "Accessibility".
114 *
115 * Similarly, from this HTML:
116 * <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a>
117 * this might return the object ImageIcon("top-hat.gif", "top hat");
118 *
119 * @param i zero-based index of the actions
120 * @return an Object representing the hypertext anchor
121 * @see #getAccessibleActionCount
122 */
123 public abstract Object getAccessibleActionAnchor(int i);
124
125 /**
126 * Gets the index with the hypertext document at which this
127 * link begins
128 *
129 * @return index of start of link
130 */
131 public abstract int getStartIndex();
132
133 /**
134 * Gets the index with the hypertext document at which this
135 * link ends
136 *
137 * @return index of end of link
138 */
139 public abstract int getEndIndex();
140 }