001/* AccessibleHyperlink.java -- aids in accessibly navigating hypertext
002   Copyright (C) 2002, 2005  Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038
039package javax.accessibility;
040
041/**
042 * This object encapsulates actions associated with navigating hypertext.
043 *
044 * @author Eric Blake (ebb9@email.byu.edu)
045 * @see Accessible
046 * @see AccessibleContext
047 * @see AccessibleText
048 * @see AccessibleContext#getAccessibleText()
049 * @since 1.2
050 * @status updated to 1.4
051 */
052public abstract class AccessibleHyperlink implements AccessibleAction
053{
054  /**
055   * The default constructor.
056   */
057  public AccessibleHyperlink()
058  {
059  }
060
061  /**
062   * Returns whether the document the link references is still valid, as the
063   * association may have changed with a text edit.
064   *
065   * @return true if the link is valid with respect to the AccessibleHypertext
066   */
067  public abstract boolean isValid();
068
069  /**
070   * Get the number possible actions for this object, starting from 0. In
071   * general, a hypertext link has only one action, except for an image map,
072   * so there isn't really a default action.
073   *
074   * @return the 0-based number of actions
075   */
076  public abstract int getAccessibleActionCount();
077
078  /**
079   * Perform the specified action. Does nothing if out of bounds.
080   *
081   * @param i the action to perform, 0-based
082   * @return true if the action was performed
083   * @see #getAccessibleActionCount()
084   */
085  public abstract boolean doAccessibleAction(int i);
086
087  /**
088   * Get the anchor text of the link, or null if the index is out of bounds.
089   * For example, <a href="http://www.gnu.org/">GNU Home Page</a>
090   * would return "GNU Home Page", while <a HREF="#top">
091   * <img src="top-hat.png" alt="top hat"></a> would return
092   * "top hat".
093   *
094   * @param i the link to retrieve, 0-based
095   * @return the link anchor text
096   * @see #getAccessibleActionCount()
097   */
098  public abstract String getAccessibleActionDescription(int i);
099
100  /**
101   * Get the link location, or null if the index is out of bounds. For
102   * example, <a href="http://www.gnu.org/">GNU Home Page</a>
103   * would return a java.net.URL("http://www.gnu.org/").
104   *
105   * @param i the link to retrieve, 0-based
106   * @return the link location
107   * @see #getAccessibleActionCount()
108   */
109  public abstract Object getAccessibleActionObject(int i);
110
111  /**
112   * Get the anchor appropriate for the link, or null if the index is out of
113   * bounds. For example, <a href="http://www.gnu.org/">GNU Home Page
114   * </a> would return "GNU Home Page", while <a HREF="#top">
115   * <img src="top-hat.png" alt="top hat"></a> would return
116   * an ImageIcon("top-hat.png", "top hat").
117   *
118   * @param i the link to retrieve, 0-based
119   * @return the link anchor object
120   * @see #getAccessibleActionCount()
121   */
122  public abstract Object getAccessibleActionAnchor(int i);
123
124  /**
125   * Gets the character index where this link starts in the parent hypertext
126   * document.
127   *
128   * @return the starting index
129   */
130  public abstract int getStartIndex();
131
132  /**
133   * Gets the character index where this link ends in the parent hypertext
134   * document.
135   *
136   * @return the ending index
137   */
138  public abstract int getEndIndex();
139} // class AccessibleAction