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