| 1 | /* CharacterIterator.java -- Iterate over a character range
|
|---|
| 2 | Copyright (C) 1998, 2001 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 6 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307 USA.
|
|---|
| 20 |
|
|---|
| 21 | Linking this library statically or dynamically with other modules is
|
|---|
| 22 | making a combined work based on this library. Thus, the terms and
|
|---|
| 23 | conditions of the GNU General Public License cover the whole
|
|---|
| 24 | combination.
|
|---|
| 25 |
|
|---|
| 26 | As a special exception, the copyright holders of this library give you
|
|---|
| 27 | permission to link this library with independent modules to produce an
|
|---|
| 28 | executable, regardless of the license terms of these independent
|
|---|
| 29 | modules, and to copy and distribute the resulting executable under
|
|---|
| 30 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 31 | independent module, the terms and conditions of the license of that
|
|---|
| 32 | module. An independent module is a module which is not derived from
|
|---|
| 33 | or based on this library. If you modify this library, you may extend
|
|---|
| 34 | this exception to your version of the library, but you are not
|
|---|
| 35 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 36 | exception statement from your version. */
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | package java.text;
|
|---|
| 40 |
|
|---|
| 41 | /**
|
|---|
| 42 | * This interface defines a mechanism for iterating over a range of
|
|---|
| 43 | * characters. For a given range of text, a beginning and ending index,
|
|---|
| 44 | * as well as a current index are defined. These values can be queried
|
|---|
| 45 | * by the methods in this interface. Additionally, various methods allow
|
|---|
| 46 | * the index to be set.
|
|---|
| 47 | *
|
|---|
| 48 | * @version 0.0
|
|---|
| 49 | *
|
|---|
| 50 | * @author Aaron M. Renn ([email protected])
|
|---|
| 51 | */
|
|---|
| 52 | public interface CharacterIterator extends Cloneable
|
|---|
| 53 | {
|
|---|
| 54 |
|
|---|
| 55 | /*************************************************************************/
|
|---|
| 56 |
|
|---|
| 57 | /*
|
|---|
| 58 | * Static Variables
|
|---|
| 59 | */
|
|---|
| 60 |
|
|---|
| 61 | /**
|
|---|
| 62 | * This is a special constant value that is returned when the beginning or
|
|---|
| 63 | * end of the character range has been reached.
|
|---|
| 64 | */
|
|---|
| 65 | public static final char DONE = '\uFFFF';
|
|---|
| 66 |
|
|---|
| 67 | /*************************************************************************/
|
|---|
| 68 |
|
|---|
| 69 | /*
|
|---|
| 70 | * Instance Methods
|
|---|
| 71 | */
|
|---|
| 72 |
|
|---|
| 73 | /**
|
|---|
| 74 | * This method returns the character at the current index position
|
|---|
| 75 | *
|
|---|
| 76 | * @return The character at the current index position.
|
|---|
| 77 | */
|
|---|
| 78 | public abstract char current ();
|
|---|
| 79 |
|
|---|
| 80 | /*************************************************************************/
|
|---|
| 81 |
|
|---|
| 82 | /**
|
|---|
| 83 | * This method increments the current index and then returns the character
|
|---|
| 84 | * at the new index value. If the index is already at <code>getEndIndex() - 1</code>,
|
|---|
| 85 | * it will not be incremented.
|
|---|
| 86 | *
|
|---|
| 87 | * @return The character at the position of the incremented index value, or <code>DONE</code> if the index has reached getEndIndex() - 1
|
|---|
| 88 | */
|
|---|
| 89 | public abstract char next ();
|
|---|
| 90 |
|
|---|
| 91 | /*************************************************************************/
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * This method decrements the current index and then returns the character
|
|---|
| 95 | * at the new index value. If the index value is already at the beginning
|
|---|
| 96 | * index, it will not be decremented.
|
|---|
| 97 | *
|
|---|
| 98 | * @return The character at the position of the decremented index value, or <code>DONE</code> if index was already equal to the beginning index value.
|
|---|
| 99 | */
|
|---|
| 100 | public abstract char previous ();
|
|---|
| 101 |
|
|---|
| 102 | /*************************************************************************/
|
|---|
| 103 |
|
|---|
| 104 | /**
|
|---|
| 105 | * This method sets the index value to the beginning of the range and returns
|
|---|
| 106 | * the character there.
|
|---|
| 107 | *
|
|---|
| 108 | * @return The character at the beginning of the range, or <code>DONE</code> if the range is empty.
|
|---|
| 109 | */
|
|---|
| 110 | public abstract char first ();
|
|---|
| 111 |
|
|---|
| 112 | /*************************************************************************/
|
|---|
| 113 |
|
|---|
| 114 | /**
|
|---|
| 115 | * This method sets the index value to <code>getEndIndex() - 1</code> and
|
|---|
| 116 | * returns the character there. If the range is empty, then the index value
|
|---|
| 117 | * will be set equal to the beginning index.
|
|---|
| 118 | *
|
|---|
| 119 | * @return The character at the end of the range, or <code>DONE</code> if the range is empty.
|
|---|
| 120 | */
|
|---|
| 121 | public abstract char last ();
|
|---|
| 122 |
|
|---|
| 123 | /*************************************************************************/
|
|---|
| 124 |
|
|---|
| 125 | /**
|
|---|
| 126 | * This method returns the current value of the index.
|
|---|
| 127 | *
|
|---|
| 128 | * @return The current index value
|
|---|
| 129 | */
|
|---|
| 130 | public abstract int getIndex ();
|
|---|
| 131 |
|
|---|
| 132 | /*************************************************************************/
|
|---|
| 133 |
|
|---|
| 134 | /**
|
|---|
| 135 | * This method sets the value of the index to the specified value, then
|
|---|
| 136 | * returns the character at that position.
|
|---|
| 137 | *
|
|---|
| 138 | * @param index The new index value.
|
|---|
| 139 | *
|
|---|
| 140 | * @return The character at the new index value or <code>DONE</code> if the index value is equal to <code>getEndIndex</code>.
|
|---|
| 141 | */
|
|---|
| 142 | public abstract char setIndex (int index) throws IllegalArgumentException;
|
|---|
| 143 |
|
|---|
| 144 | /*************************************************************************/
|
|---|
| 145 |
|
|---|
| 146 | /**
|
|---|
| 147 | * This method returns the character position of the first character in the
|
|---|
| 148 | * range.
|
|---|
| 149 | *
|
|---|
| 150 | * @return The index of the first character in the range.
|
|---|
| 151 | */
|
|---|
| 152 | public abstract int getBeginIndex ();
|
|---|
| 153 |
|
|---|
| 154 | /*************************************************************************/
|
|---|
| 155 |
|
|---|
| 156 | /**
|
|---|
| 157 | * This method returns the character position of the end of the text range.
|
|---|
| 158 | * This will actually be the index of the first character following the
|
|---|
| 159 | * end of the range. In the event the text range is empty, this will be
|
|---|
| 160 | * equal to the first character in the range.
|
|---|
| 161 | *
|
|---|
| 162 | * @return The index of the end of the range.
|
|---|
| 163 | */
|
|---|
| 164 | public abstract int getEndIndex ();
|
|---|
| 165 |
|
|---|
| 166 | /*************************************************************************/
|
|---|
| 167 |
|
|---|
| 168 | /**
|
|---|
| 169 | * This method creates a copy of this <code>CharacterIterator</code>.
|
|---|
| 170 | *
|
|---|
| 171 | * @return A copy of this <code>CharacterIterator</code>.
|
|---|
| 172 | */
|
|---|
| 173 | public abstract Object clone ();
|
|---|
| 174 | }
|
|---|