public final class StringCharacterIterator extends Object implements CharacterIterator
StringCharacterIterator implements the CharacterIterator protocol for a String. The StringCharacterIterator class iterates over the entire String.
CharacterIteratorDONE public StringCharacterIterator(String text)
Constructs an iterator with an initial index of 0.
text - the String to be iterated overpublic StringCharacterIterator(String text,
int pos) Constructs an iterator with the specified initial index.
text - The String to be iterated overpos - Initial iterator positionpublic StringCharacterIterator(String text,
int begin,
int end,
int pos) Constructs an iterator over the given range of the given string, with the index set at the specified position.
text - The String to be iterated overbegin - Index of the first characterend - Index of the character following the last characterpos - Initial iterator positionpublic void setText(String text)
Reset this iterator to point to a new string. This package-visible method is used by other java.text classes that want to avoid allocating new StringCharacterIterator objects every time their setText method is called.
text - The String to be iterated overpublic char first()
Implements CharacterIterator.first() for String.
first in interface CharacterIterator
CharacterIterator.first()public char last()
Implements CharacterIterator.last() for String.
last in interface CharacterIterator
CharacterIterator.last()public char setIndex(int p)
Implements CharacterIterator.setIndex() for String.
setIndex in interface CharacterIterator
p - the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied.CharacterIterator.setIndex(int)public char current()
Implements CharacterIterator.current() for String.
current in interface CharacterIterator
CharacterIterator.current()public char next()
Implements CharacterIterator.next() for String.
next in interface CharacterIterator
CharacterIterator.next()public char previous()
Implements CharacterIterator.previous() for String.
previous in interface CharacterIterator
CharacterIterator.previous()public int getBeginIndex()
Implements CharacterIterator.getBeginIndex() for String.
getBeginIndex in interface CharacterIterator
CharacterIterator.getBeginIndex()public int getEndIndex()
Implements CharacterIterator.getEndIndex() for String.
getEndIndex in interface CharacterIterator
CharacterIterator.getEndIndex()public int getIndex()
Implements CharacterIterator.getIndex() for String.
getIndex in interface CharacterIterator
CharacterIterator.getIndex()public boolean equals(Object obj)
Compares the equality of two StringCharacterIterator objects.
equals in class Object
obj - the StringCharacterIterator object to be compared with.Object.hashCode(), HashMap
public int hashCode()
Computes a hashcode for this iterator.
hashCode in class Object
Object.equals(java.lang.Object), System.identityHashCode(java.lang.Object)
public Object clone()
Creates a copy of this iterator.
clone in interface CharacterIterator
clone in class Object
Cloneable
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.