AccessibleHyperlink (Java SE 26 & JDK 26)
Description: declaration: module: java.desktop, package: javax.accessibility, class: AccessibleHyperlink
Keywords: javax.accessibility.AccessibleHyperlink class

# Class AccessibleHyperlink

java.lang.Object
javax.accessibility.AccessibleHyperlink

All Implemented Interfaces:
  `AccessibleAction`

Direct Known Subclasses:
  `JEditorPane.JEditorPaneAccessibleHypertextSupport.HTMLLink`

public abstract class AccessibleHyperlink extends Object implements AccessibleAction
Encapsulation of a link, or set of links (e.g. client side imagemap) in a Hypertext document

See Also:
  - `Accessible`
  - `Accessible.getAccessibleContext()`
  - `AccessibleContext`
  - `AccessibleText`
  - `AccessibleContext.getAccessibleText()`

- ## Field Summary

  ### Fields declared in interface AccessibleAction

  `CLICK, DECREMENT, INCREMENT, TOGGLE_EXPAND, TOGGLE_POPUP`
  Modifier and Type
  Field
  Description
  `static final String`
  `CLICK`
  An action which causes a component to execute its default action.
  `static final String`
  `DECREMENT`
  An action which decrements a value.
  `static final String`
  `INCREMENT`
  An action which increments a value.
  `static final String`
  `TOGGLE_EXPAND`
  An action which causes a tree node to collapse if expanded and expand if collapsed.
  `static final String`
  `TOGGLE_POPUP`
  An action which causes a popup to become visible if it is hidden and hidden if it is visible.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AccessibleHyperlink()`
  Constructor for subclasses to call.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract boolean`
  `doAccessibleAction(int i)`
  Performs the specified action on the object.
  `abstract Object`
  `getAccessibleActionAnchor(int i)`
  Returns an object that represents the link anchor, as appropriate for that link.
  `abstract int`
  `getAccessibleActionCount()`
  Returns the number of accessible actions available in this Link If there are more than one, the first one is NOT considered the "default" action of this LINK object (e.g. in an HTML imagemap).
  `abstract String`
  `getAccessibleActionDescription(int i)`
  Returns a string description of this particular link action.
  `abstract Object`
  `getAccessibleActionObject(int i)`
  Returns an object that represents the link action, as appropriate for that link.
  `abstract int`
  `getEndIndex()`
  Gets the index with the hypertext document at which this link ends.
  `abstract int`
  `getStartIndex()`
  Gets the index with the hypertext document at which this link begins.
  `abstract boolean`
  `isValid()`
  Since the document a link is associated with may have changed, this method returns whether or not this Link is still valid (with respect to the document it references).

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Constructor Details

  - ### AccessibleHyperlink

    protected AccessibleHyperlink()
    Constructor for subclasses to call.

- ## Method Details

  - ### isValid

    public abstract boolean isValid()
    Since the document a link is associated with may have changed, this method returns whether or not this Link is still valid (with respect to the document it references).
    Returns:
      a flag indicating whether this link is still valid with respect to the `AccessibleHypertext` it belongs to

  - ### getAccessibleActionCount

    public abstract int getAccessibleActionCount()
    Returns the number of accessible actions available in this Link If there are more than one, the first one is NOT considered the "default" action of this LINK object (e.g. in an HTML imagemap). In general, links will have only one `AccessibleAction` in them.
    Specified by:
      `getAccessibleActionCount` in interface `AccessibleAction`
    Returns:
      the zero-based number of actions in this object

  - ### doAccessibleAction

    public abstract boolean doAccessibleAction(int i)
    Performs the specified action on the object.
    Specified by:
      `doAccessibleAction` in interface `AccessibleAction`
    Parameters:
      `i` - zero-based index of actions
    Returns:
      `true` if the action was performed; otherwise `false`
    See Also:
      - `getAccessibleActionCount()`

  - ### getAccessibleActionDescription

    public abstract String getAccessibleActionDescription(int i)
    Returns a string description of this particular link action. This should be a text string associated with anchoring text, this should be the anchor text. E.g. from HTML: <a HREF="http://www.sun.com/access">Accessibility</a> this method would return "Accessibility".

    Similarly, from this HTML: <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a> this method would return "top hat"

    Specified by:
      `getAccessibleActionDescription` in interface `AccessibleAction`
    Parameters:
      `i` - zero-based index of the actions
    Returns:
      a string description of the action
    See Also:
      - `getAccessibleActionCount()`

  - ### getAccessibleActionObject

    public abstract Object getAccessibleActionObject(int i)
    Returns an object that represents the link action, as appropriate for that link. E.g. from HTML: <a HREF="http://www.sun.com/access">Accessibility</a> this method would return a java.net.URL("http://www.sun.com/access.html");
    Parameters:
      `i` - zero-based index of the actions
    Returns:
      an object representing the hypertext link itself
    See Also:
      - `getAccessibleActionCount()`

  - ### getAccessibleActionAnchor

    public abstract Object getAccessibleActionAnchor(int i)
    Returns an object that represents the link anchor, as appropriate for that link. E.g. from HTML: <a href="http://www.sun.com/access">Accessibility</a> this method would return a `String` containing the text: "Accessibility".

    Similarly, from this HTML: <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a> this might return the object ImageIcon("top-hat.gif", "top hat");

    Parameters:
      `i` - zero-based index of the actions
    Returns:
      an object representing the hypertext anchor
    See Also:
      - `getAccessibleActionCount()`

  - ### getStartIndex

    public abstract int getStartIndex()
    Gets the index with the hypertext document at which this link begins.
    Returns:
      index of start of link

  - ### getEndIndex

    public abstract int getEndIndex()
    Gets the index with the hypertext document at which this link ends.
    Returns:
      index of end of link