Path: blob/master/src/java.desktop/share/classes/javax/accessibility/AccessibleHyperlink.java
41153 views
/*1* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.accessibility;2627/**28* Encapsulation of a link, or set of links (e.g. client side imagemap) in a29* Hypertext document30*31* @author Peter Korn32* @see Accessible33* @see Accessible#getAccessibleContext34* @see AccessibleContext35* @see AccessibleText36* @see AccessibleContext#getAccessibleText37*/38public abstract class AccessibleHyperlink implements AccessibleAction {3940/**41* Constructor for subclasses to call.42*/43protected AccessibleHyperlink() {}4445/**46* Since the document a link is associated with may have changed, this47* method returns whether or not this Link is still valid (with respect to48* the document it references).49*50* @return a flag indicating whether this link is still valid with respect51* to the {@code AccessibleHypertext} it belongs to52*/53public abstract boolean isValid();5455/**56* Returns the number of accessible actions available in this Link If there57* are more than one, the first one is NOT considered the "default" action58* of this LINK object (e.g. in an HTML imagemap). In general, links will59* have only one {@code AccessibleAction} in them.60*61* @return the zero-based number of actions in this object62*/63public abstract int getAccessibleActionCount();6465/**66* Performs the specified action on the object.67*68* @param i zero-based index of actions69* @return {@code true} if the action was performed; otherwise {@code false}70* @see #getAccessibleActionCount71*/72public abstract boolean doAccessibleAction(int i);7374/**75* Returns a string description of this particular link action. This should76* be a text string associated with anchoring text, this should be the77* anchor text. E.g. from HTML: <a78* HREF="http://www.sun.com/access">Accessibility</a> this method79* would return "Accessibility".80* <p>81* Similarly, from this HTML: <a HREF="#top"><img src="top-hat.gif"82* alt="top hat"></a> this method would return "top hat"83*84* @param i zero-based index of the actions85* @return a string description of the action86* @see #getAccessibleActionCount87*/88public abstract String getAccessibleActionDescription(int i);8990/**91* Returns an object that represents the link action, as appropriate for92* that link. E.g. from HTML: <a93* HREF="http://www.sun.com/access">Accessibility</a> this method94* would return a java.net.URL("http://www.sun.com/access.html");95*96* @param i zero-based index of the actions97* @return an object representing the hypertext link itself98* @see #getAccessibleActionCount99*/100public abstract Object getAccessibleActionObject(int i);101102/**103* Returns an object that represents the link anchor, as appropriate for104* that link. E.g. from HTML: <a105* href="http://www.sun.com/access">Accessibility</a> this method106* would return a {@code String} containing the text: "Accessibility".107* <p>108* Similarly, from this HTML: <a HREF="#top"><img src="top-hat.gif"109* alt="top hat"></a> this might return the object110* ImageIcon("top-hat.gif", "top hat");111*112* @param i zero-based index of the actions113* @return an object representing the hypertext anchor114* @see #getAccessibleActionCount115*/116public abstract Object getAccessibleActionAnchor(int i);117118/**119* Gets the index with the hypertext document at which this link begins.120*121* @return index of start of link122*/123public abstract int getStartIndex();124125/**126* Gets the index with the hypertext document at which this link ends.127*128* @return index of end of link129*/130public abstract int getEndIndex();131}132133134