001 /*
002 * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.accessibility;
027
028 import java.util.*;
029 import java.awt.*;
030 import javax.swing.text.*;
031
032 /**
033 * Encapsulation of a link, or set of links (e.g. client side imagemap)
034 * in a Hypertext document
035 *
036 * @see Accessible
037 * @see Accessible#getAccessibleContext
038 * @see AccessibleContext
039 * @see AccessibleText
040 * @see AccessibleContext#getAccessibleText
041 *
042 * @version 1.20, 05/05/07
043 * @author Peter Korn
044 */
045 public abstract class AccessibleHyperlink implements AccessibleAction {
046
047 /**
048 * Since the document a link is associated with may have
049 * changed, this method returns whether or not this Link is still valid
050 * (with respect to the document it references).
051 *
052 * @return a flag indicating whether this link is still valid with
053 * respect to the AccessibleHypertext it belongs to
054 */
055 public abstract boolean isValid();
056
057 /**
058 * Returns the number of accessible actions available in this Link
059 * If there are more than one, the first one is NOT considered the
060 * "default" action of this LINK object (e.g. in an HTML imagemap).
061 * In general, links will have only one AccessibleAction in them.
062 *
063 * @return the zero-based number of Actions in this object
064 */
065 public abstract int getAccessibleActionCount();
066
067 /**
068 * Performs the specified Action on the object
069 *
070 * @param i zero-based index of actions
071 * @return true if the action was performed; otherwise false.
072 * @see #getAccessibleActionCount
073 */
074 public abstract boolean doAccessibleAction(int i);
075
076 /**
077 * Returns a String description of this particular
078 * link action. This should be a text string
079 * associated with anchoring text, this should be the
080 * anchor text. E.g. from HTML:
081 * <a HREF="http://www.sun.com/access">Accessibility</a>
082 * this method would return "Accessibility".
083 *
084 * Similarly, from this HTML:
085 * <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a>
086 * this method would return "top hat"
087 *
088 * @param i zero-based index of the actions
089 * @return a String description of the action
090 * @see #getAccessibleActionCount
091 */
092 public abstract String getAccessibleActionDescription(int i);
093
094 /**
095 * Returns an object that represents the link action,
096 * as appropriate for that link. E.g. from HTML:
097 * <a HREF="http://www.sun.com/access">Accessibility</a>
098 * this method would return a
099 * java.net.URL("http://www.sun.com/access.html");
100 *
101 * @param i zero-based index of the actions
102 * @return an Object representing the hypertext link itself
103 * @see #getAccessibleActionCount
104 */
105 public abstract Object getAccessibleActionObject(int i);
106
107 /**
108 * Returns an object that represents the link anchor,
109 * as appropriate for that link. E.g. from HTML:
110 * <a href="http://www.sun.com/access">Accessibility</a>
111 * this method would return a String containing the text:
112 * "Accessibility".
113 *
114 * Similarly, from this HTML:
115 * <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a>
116 * this might return the object ImageIcon("top-hat.gif", "top hat");
117 *
118 * @param i zero-based index of the actions
119 * @return an Object representing the hypertext anchor
120 * @see #getAccessibleActionCount
121 */
122 public abstract Object getAccessibleActionAnchor(int i);
123
124 /**
125 * Gets the index with the hypertext document at which this
126 * link begins
127 *
128 * @return index of start of link
129 */
130 public abstract int getStartIndex();
131
132 /**
133 * Gets the index with the hypertext document at which this
134 * link ends
135 *
136 * @return index of end of link
137 */
138 public abstract int getEndIndex();
139 }
|