public final class StringCharacterIterator extends Objectimplements CharacterIterator
StringCharacterIterator implements the
CharacterIterator protocol for a
String. The
StringCharacterIterator class iterates over the entire
String.
CharacterIterator
DONE| Constructor and Description |
|---|
StringCharacterIterator(String
Constructs an iterator with an initial index of 0.
|
StringCharacterIterator(String
Constructs an iterator with the specified initial index.
|
StringCharacterIterator(String
Constructs an iterator over the given range of the given string, with the index set at the specified position.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Creates a copy of this iterator.
|
char |
current()
Implements CharacterIterator.current() for String.
|
boolean |
equals(Object
Compares the equality of two StringCharacterIterator objects.
|
char |
first()
Implements CharacterIterator.first() for String.
|
int |
getBeginIndex()
Implements CharacterIterator.getBeginIndex() for String.
|
int |
getEndIndex()
Implements CharacterIterator.getEndIndex() for String.
|
int |
getIndex()
Implements CharacterIterator.getIndex() for String.
|
int |
hashCode()
Computes a hashcode for this iterator.
|
char |
last()
Implements CharacterIterator.last() for String.
|
char |
next()
Implements CharacterIterator.next() for String.
|
char |
previous()
Implements CharacterIterator.previous() for String.
|
char |
setIndex(int p)
Implements CharacterIterator.setIndex() for String.
|
void |
setText(String
Reset this iterator to point to a new string.
|
public StringCharacterIterator(Stringtext)
text - the
String to be iterated over
public StringCharacterIterator(Stringtext, int pos)
text - The String to be iterated over
pos - Initial iterator position
public StringCharacterIterator(Stringtext, int begin, int end, int pos)
text - The String to be iterated over
begin - Index of the first character
end - Index of the character following the last character
pos - Initial iterator position
public void setText(Stringtext)
text - The String to be iterated over
public char first()
first in interface
CharacterIterator
CharacterIterator.first()
public char last()
last in interface
CharacterIterator
CharacterIterator.last()
public char setIndex(int p)
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()
current in interface
CharacterIterator
CharacterIterator.current()
public char next()
next in interface
CharacterIterator
CharacterIterator.next()
public char previous()
previous in interface
CharacterIterator
CharacterIterator.previous()
public int getBeginIndex()
getBeginIndex in interface
CharacterIterator
CharacterIterator.getBeginIndex()
public int getEndIndex()
getEndIndex in interface
CharacterIterator
CharacterIterator.getEndIndex()
public int getIndex()
getIndex in interface
CharacterIterator
CharacterIterator.getIndex()
public boolean equals(Objectobj)
equals in class
Object
obj - the StringCharacterIterator object to be compared with.
Object.hashCode() ,
HashMap
public int hashCode()
hashCode in class
Object
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)