CharacterIterator.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* CharacterIterator.java -- Iterate over a character range
  2. Copyright (C) 1998, 2001, 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 java.text;
  32. /**
  33. * This interface defines a mechanism for iterating over a range of
  34. * characters. For a given range of text, a beginning and ending index,
  35. * as well as a current index are defined. These values can be queried
  36. * by the methods in this interface. Additionally, various methods allow
  37. * the index to be set.
  38. *
  39. * @author Aaron M. Renn (arenn@urbanophile.com)
  40. */
  41. public interface CharacterIterator extends Cloneable
  42. {
  43. /**
  44. * This is a special constant value that is returned when the beginning or
  45. * end of the character range has been reached.
  46. */
  47. char DONE = '\uFFFF';
  48. /**
  49. * This method returns the character at the current index position
  50. *
  51. * @return The character at the current index position.
  52. */
  53. char current();
  54. /**
  55. * This method increments the current index and then returns the character
  56. * at the new index value. If the index is already at
  57. * <code>getEndIndex() - 1</code>, it will not be incremented.
  58. *
  59. * @return The character at the position of the incremented index value,
  60. * or {@link #DONE} if the index has reached getEndIndex() - 1
  61. */
  62. char next();
  63. /**
  64. * This method decrements the current index and then returns the character
  65. * at the new index value. If the index value is already at the beginning
  66. * index, it will not be decremented.
  67. *
  68. * @return The character at the position of the decremented index value,
  69. * or {@link #DONE} if index was already equal to the beginning index
  70. * value.
  71. */
  72. char previous();
  73. /**
  74. * This method sets the index value to the beginning of the range and returns
  75. * the character there.
  76. *
  77. * @return The character at the beginning of the range, or {@link #DONE} if
  78. * the range is empty.
  79. */
  80. char first();
  81. /**
  82. * This method sets the index value to <code>getEndIndex() - 1</code> and
  83. * returns the character there. If the range is empty, then the index value
  84. * will be set equal to the beginning index.
  85. *
  86. * @return The character at the end of the range, or {@link #DONE} if the
  87. * range is empty.
  88. */
  89. char last();
  90. /**
  91. * This method returns the current value of the index.
  92. *
  93. * @return The current index value
  94. */
  95. int getIndex();
  96. /**
  97. * This method sets the value of the index to the specified value, then
  98. * returns the character at that position.
  99. *
  100. * @param index The new index value.
  101. *
  102. * @return The character at the new index value or {@link #DONE} if the index
  103. * value is equal to {@link #getEndIndex()}.
  104. */
  105. char setIndex (int index) throws IllegalArgumentException;
  106. /**
  107. * This method returns the character position of the first character in the
  108. * range.
  109. *
  110. * @return The index of the first character in the range.
  111. */
  112. int getBeginIndex();
  113. /**
  114. * This method returns the character position of the end of the text range.
  115. * This will actually be the index of the first character following the
  116. * end of the range. In the event the text range is empty, this will be
  117. * equal to the first character in the range.
  118. *
  119. * @return The index of the end of the range.
  120. */
  121. int getEndIndex();
  122. /**
  123. * This method creates a copy of this <code>CharacterIterator</code>.
  124. *
  125. * @return A copy of this <code>CharacterIterator</code>.
  126. */
  127. Object clone();
  128. } // interface CharacterIterator