1. /*
  2. * @(#)AccessibleHyperlink.java 1.9 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.accessibility;
  11. import java.lang.*;
  12. import java.util.*;
  13. import java.awt.*;
  14. import javax.swing.text.*;
  15. /**
  16. * Encapsulation of a link, or set of links (e.g. client side imagemap)
  17. * in a Hypertext document
  18. *
  19. * @see Accessible
  20. * @see Accessible#getAccessibleContext
  21. * @see AccessibleContext
  22. * @see AccessibleText
  23. * @see AccessibleContext#getAccessibleText
  24. *
  25. * @version 1.9, 02/02/00
  26. * @author Peter Korn
  27. */
  28. public abstract class AccessibleHyperlink implements AccessibleAction {
  29. /**
  30. * Since the document a link is associated with may have
  31. * changed, this method returns whether or not this Link is still valid
  32. * (with respect to the document it references).
  33. *
  34. * @return a flag indicating whether this link is still valid with
  35. * respect to the AccessibleHypertext it belongs to
  36. */
  37. public abstract boolean isValid();
  38. /**
  39. * Returns the number of accessible actions available in this Link
  40. * If there are more than one, the first one is NOT considered the
  41. * "default" action of this LINK object (e.g. in an HTML imagemap).
  42. * In general, links will have only one AccessibleAction in them.
  43. *
  44. * @return the zero-based number of Actions in this object
  45. */
  46. public abstract int getAccessibleActionCount();
  47. /**
  48. * Performs the specified Action on the object
  49. *
  50. * @param i zero-based index of actions
  51. * @return true if the action was performed; otherwise false.
  52. * @see #getAccessibleActionCount
  53. */
  54. public abstract boolean doAccessibleAction(int i);
  55. /**
  56. * Returns a String description of this particular
  57. * link action. This should be a text string
  58. * associated with anchoring text, this should be the
  59. * anchor text. E.g. from HTML:
  60. * <a HREF="http://www.sun.com/access">Accessibility</a>
  61. * this method would return "Accessibility".
  62. *
  63. * Similarly, from this HTML:
  64. * <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a>
  65. * this method would return "top hat"
  66. *
  67. * @param i zero-based index of the actions
  68. * @return a String description of the action
  69. * @see #getAccessibleActionCount
  70. */
  71. public abstract String getAccessibleActionDescription(int i);
  72. /**
  73. * Returns an object that represents the link action,
  74. * as appropriate for that link. E.g. from HTML:
  75. * <a HREF="http://www.sun.com/access">Accessibility</a>
  76. * this method would return a
  77. * java.net.URL("http://www.sun.com/access.html");
  78. *
  79. * @param i zero-based index of the actions
  80. * @return an Object representing the hypertext link itself
  81. * @see #getAccessibleActionCount
  82. */
  83. public abstract Object getAccessibleActionObject(int i);
  84. /**
  85. * Returns an object that represents the link anchor,
  86. * as appropriate for that link. E.g. from HTML:
  87. * <a href="http://www.sun.com/access">Accessibility</a>
  88. * this method would return a String containing the text:
  89. * "Accessibility".
  90. *
  91. * Similarly, from this HTML:
  92. * <a HREF="#top"><img src="top-hat.gif" alt="top hat"></a>
  93. * this might return the object ImageIcon("top-hat.gif", "top hat");
  94. *
  95. * @param i zero-based index of the actions
  96. * @return an Object representing the hypertext anchor
  97. * @see #getAccessibleActionCount
  98. */
  99. public abstract Object getAccessibleActionAnchor(int i);
  100. /**
  101. * Gets the index with the hypertext document at which this
  102. * link begins
  103. *
  104. * @return index of start of link
  105. */
  106. public abstract int getStartIndex();
  107. /**
  108. * Gets the index with the hypertext document at which this
  109. * link ends
  110. *
  111. * @return index of end of link
  112. */
  113. public abstract int getEndIndex();
  114. }