- java.lang.Object
- 
- java.text.StringCharacterIterator
 
- 
- All Implemented Interfaces:
- Cloneable,- CharacterIterator
 
 public final class StringCharacterIterator extends Object implements CharacterIterator StringCharacterIteratorimplements theCharacterIteratorprotocol for aString. TheStringCharacterIteratorclass iterates over the entireString.- Since:
- 1.1
- See Also:
- CharacterIterator
 
- 
- 
Field Summary- 
Fields declared in interface java.text.CharacterIteratorDONE
 
- 
 - 
Constructor SummaryConstructors Constructor Description StringCharacterIterator(String text)Constructs an iterator with an initial index of 0.StringCharacterIterator(String text, int pos)Constructs an iterator with the specified initial index.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.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Creates a copy of this iterator.charcurrent()Implements CharacterIterator.current() for String.booleanequals(Object obj)Compares the equality of two StringCharacterIterator objects.charfirst()Implements CharacterIterator.first() for String.intgetBeginIndex()Implements CharacterIterator.getBeginIndex() for String.intgetEndIndex()Implements CharacterIterator.getEndIndex() for String.intgetIndex()Implements CharacterIterator.getIndex() for String.inthashCode()Computes a hashcode for this iterator.charlast()Implements CharacterIterator.last() for String.charnext()Implements CharacterIterator.next() for String.charprevious()Implements CharacterIterator.previous() for String.charsetIndex(int p)Implements CharacterIterator.setIndex() for String.voidsetText(String text)Reset this iterator to point to a new string.
 
- 
- 
- 
Constructor Detail- 
StringCharacterIteratorpublic StringCharacterIterator(String text) Constructs an iterator with an initial index of 0.- Parameters:
- text- the- Stringto be iterated over
 
 - 
StringCharacterIteratorpublic StringCharacterIterator(String text, int pos) Constructs an iterator with the specified initial index.- Parameters:
- text- The String to be iterated over
- pos- Initial iterator position
 
 - 
StringCharacterIteratorpublic 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.- Parameters:
- 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
 
 
- 
 - 
Method Detail- 
setTextpublic 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.- Parameters:
- text- The String to be iterated over
- Since:
- 1.2
 
 - 
firstpublic char first() Implements CharacterIterator.first() for String.- Specified by:
- firstin interface- CharacterIterator
- Returns:
- the first character in the text, or DONE if the text is empty
- See Also:
- CharacterIterator.first()
 
 - 
lastpublic char last() Implements CharacterIterator.last() for String.- Specified by:
- lastin interface- CharacterIterator
- Returns:
- the last character in the text, or DONE if the text is empty
- See Also:
- CharacterIterator.last()
 
 - 
setIndexpublic char setIndex(int p) Implements CharacterIterator.setIndex() for String.- Specified by:
- setIndexin interface- CharacterIterator
- Parameters:
- p- the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied.
- Returns:
- the character at the specified position or DONE if the specified position is equal to getEndIndex()
- See Also:
- CharacterIterator.setIndex(int)
 
 - 
currentpublic char current() Implements CharacterIterator.current() for String.- Specified by:
- currentin interface- CharacterIterator
- Returns:
- the character at the current position or DONE if the current position is off the end of the text.
- See Also:
- CharacterIterator.current()
 
 - 
nextpublic char next() Implements CharacterIterator.next() for String.- Specified by:
- nextin interface- CharacterIterator
- Returns:
- the character at the new position or DONE if the new position is off the end of the text range.
- See Also:
- CharacterIterator.next()
 
 - 
previouspublic char previous() Implements CharacterIterator.previous() for String.- Specified by:
- previousin interface- CharacterIterator
- Returns:
- the character at the new position or DONE if the current position is equal to getBeginIndex().
- See Also:
- CharacterIterator.previous()
 
 - 
getBeginIndexpublic int getBeginIndex() Implements CharacterIterator.getBeginIndex() for String.- Specified by:
- getBeginIndexin interface- CharacterIterator
- Returns:
- the index at which the text begins.
- See Also:
- CharacterIterator.getBeginIndex()
 
 - 
getEndIndexpublic int getEndIndex() Implements CharacterIterator.getEndIndex() for String.- Specified by:
- getEndIndexin interface- CharacterIterator
- Returns:
- the index after the last character in the text
- See Also:
- CharacterIterator.getEndIndex()
 
 - 
getIndexpublic int getIndex() Implements CharacterIterator.getIndex() for String.- Specified by:
- getIndexin interface- CharacterIterator
- Returns:
- the current index.
- See Also:
- CharacterIterator.getIndex()
 
 - 
equalspublic boolean equals(Object obj) Compares the equality of two StringCharacterIterator objects.- Overrides:
- equalsin class- Object
- Parameters:
- obj- the StringCharacterIterator object to be compared with.
- Returns:
- true if the given obj is the same as this StringCharacterIterator object; false otherwise.
- See Also:
- Object.hashCode(),- HashMap
 
 - 
hashCodepublic int hashCode() Computes a hashcode for this iterator.- Overrides:
- hashCodein class- Object
- Returns:
- A hash code
- See Also:
- Object.equals(java.lang.Object),- System.identityHashCode(java.lang.Object)
 
 
- 
 
-