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