AccessibleHyperlink.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* AccessibleHyperlink.java -- aids in accessibly navigating hypertext
  2. Copyright (C) 2002, 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.accessibility;
  32. /**
  33. * This object encapsulates actions associated with navigating hypertext.
  34. *
  35. * @author Eric Blake (ebb9@email.byu.edu)
  36. * @see Accessible
  37. * @see AccessibleContext
  38. * @see AccessibleText
  39. * @see AccessibleContext#getAccessibleText()
  40. * @since 1.2
  41. * @status updated to 1.4
  42. */
  43. public abstract class AccessibleHyperlink implements AccessibleAction
  44. {
  45. /**
  46. * The default constructor.
  47. */
  48. public AccessibleHyperlink()
  49. {
  50. }
  51. /**
  52. * Returns whether the document the link references is still valid, as the
  53. * association may have changed with a text edit.
  54. *
  55. * @return true if the link is valid with respect to the AccessibleHypertext
  56. */
  57. public abstract boolean isValid();
  58. /**
  59. * Get the number possible actions for this object, starting from 0. In
  60. * general, a hypertext link has only one action, except for an image map,
  61. * so there isn't really a default action.
  62. *
  63. * @return the 0-based number of actions
  64. */
  65. public abstract int getAccessibleActionCount();
  66. /**
  67. * Perform the specified action. Does nothing if out of bounds.
  68. *
  69. * @param i the action to perform, 0-based
  70. * @return true if the action was performed
  71. * @see #getAccessibleActionCount()
  72. */
  73. public abstract boolean doAccessibleAction(int i);
  74. /**
  75. * Get the anchor text of the link, or null if the index is out of bounds.
  76. * For example, <a href="http://www.gnu.org/">GNU Home Page</a>
  77. * would return "GNU Home Page", while <a HREF="#top">
  78. * <img src="top-hat.png" alt="top hat"></a> would return
  79. * "top hat".
  80. *
  81. * @param i the link to retrieve, 0-based
  82. * @return the link anchor text
  83. * @see #getAccessibleActionCount()
  84. */
  85. public abstract String getAccessibleActionDescription(int i);
  86. /**
  87. * Get the link location, or null if the index is out of bounds. For
  88. * example, <a href="http://www.gnu.org/">GNU Home Page</a>
  89. * would return a java.net.URL("http://www.gnu.org/").
  90. *
  91. * @param i the link to retrieve, 0-based
  92. * @return the link location
  93. * @see #getAccessibleActionCount()
  94. */
  95. public abstract Object getAccessibleActionObject(int i);
  96. /**
  97. * Get the anchor appropriate for the link, or null if the index is out of
  98. * bounds. For example, <a href="http://www.gnu.org/">GNU Home Page
  99. * </a> would return "GNU Home Page", while <a HREF="#top">
  100. * <img src="top-hat.png" alt="top hat"></a> would return
  101. * an ImageIcon("top-hat.png", "top hat").
  102. *
  103. * @param i the link to retrieve, 0-based
  104. * @return the link anchor object
  105. * @see #getAccessibleActionCount()
  106. */
  107. public abstract Object getAccessibleActionAnchor(int i);
  108. /**
  109. * Gets the character index where this link starts in the parent hypertext
  110. * document.
  111. *
  112. * @return the starting index
  113. */
  114. public abstract int getStartIndex();
  115. /**
  116. * Gets the character index where this link ends in the parent hypertext
  117. * document.
  118. *
  119. * @return the ending index
  120. */
  121. public abstract int getEndIndex();
  122. } // class AccessibleAction