StringCharacterIterator (Java 2 Platform SE 5.0) (original) (raw)
java.text
Class StringCharacterIterator
java.lang.Object
java.text.StringCharacterIterator
All Implemented Interfaces:
public final class StringCharacterIterator
extends Object
implements CharacterIterator
StringCharacterIterator
implements theCharacterIterater
protocol for a String
. The StringCharacterIterator
class iterates over the entire String
.
See Also:
Field Summary |
---|
Fields inherited from interface java.text.CharacterIterator |
---|
DONE |
Constructor Summary |
---|
StringCharacterIterator(String text) Constructs an iterator with an initial index of 0. |
[StringCharacterIterator](../../java/text/StringCharacterIterator.html#StringCharacterIterator%28java.lang.String, int%29)(String text, int pos) Constructs an iterator with the specified initial index. |
[StringCharacterIterator](../../java/text/StringCharacterIterator.html#StringCharacterIterator%28java.lang.String, int, int, int%29)(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 Summary | |
---|---|
Object | clone() Creates a copy of this iterator. |
char | current() Implements CharacterIterator.current() for String. |
boolean | equals(Object obj) 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 text) Reset this iterator to point to a new string. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Constructor Detail |
---|
StringCharacterIterator
public StringCharacterIterator(String text)
Constructs an iterator with an initial index of 0.
StringCharacterIterator
public 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
StringCharacterIterator
public 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 |
---|
setText
public 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
first
public char first()
Implements CharacterIterator.first() for String.
Specified by:
[first](../../java/text/CharacterIterator.html#first%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the first character in the text, or DONE if the text is empty
See Also:
last
public char last()
Implements CharacterIterator.last() for String.
Specified by:
[last](../../java/text/CharacterIterator.html#last%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the last character in the text, or DONE if the text is empty
See Also:
setIndex
public char setIndex(int p)
Implements CharacterIterator.setIndex() for String.
Specified by:
[setIndex](../../java/text/CharacterIterator.html#setIndex%28int%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
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)
current
public char current()
Implements CharacterIterator.current() for String.
Specified by:
[current](../../java/text/CharacterIterator.html#current%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the character at the current position or DONE if the current position is off the end of the text.
See Also:
next
public char next()
Implements CharacterIterator.next() for String.
Specified by:
[next](../../java/text/CharacterIterator.html#next%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the character at the new position or DONE if the new position is off the end of the text range.
See Also:
previous
public char previous()
Implements CharacterIterator.previous() for String.
Specified by:
[previous](../../java/text/CharacterIterator.html#previous%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the character at the new position or DONE if the current position is equal to getBeginIndex().
See Also:
getBeginIndex
public int getBeginIndex()
Implements CharacterIterator.getBeginIndex() for String.
Specified by:
[getBeginIndex](../../java/text/CharacterIterator.html#getBeginIndex%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the index at which the text begins.
See Also:
CharacterIterator.getBeginIndex()
getEndIndex
public int getEndIndex()
Implements CharacterIterator.getEndIndex() for String.
Specified by:
[getEndIndex](../../java/text/CharacterIterator.html#getEndIndex%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the index after the last character in the text
See Also:
CharacterIterator.getEndIndex()
getIndex
public int getIndex()
Implements CharacterIterator.getIndex() for String.
Specified by:
[getIndex](../../java/text/CharacterIterator.html#getIndex%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Returns:
the current index.
See Also:
equals
public boolean equals(Object obj)
Compares the equality of two StringCharacterIterator objects.
Overrides:
[equals](../../java/lang/Object.html#equals%28java.lang.Object%29)
in class [Object](../../java/lang/Object.html "class in java.lang")
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:
hashCode
public int hashCode()
Computes a hashcode for this iterator.
Overrides:
[hashCode](../../java/lang/Object.html#hashCode%28%29)
in class [Object](../../java/lang/Object.html "class in java.lang")
Returns:
A hash code
See Also:
Object.equals(java.lang.Object), Hashtable
clone
public Object clone()
Creates a copy of this iterator.
Specified by:
[clone](../../java/text/CharacterIterator.html#clone%28%29)
in interface [CharacterIterator](../../java/text/CharacterIterator.html "interface in java.text")
Overrides:
[clone](../../java/lang/Object.html#clone%28%29)
in class [Object](../../java/lang/Object.html "class in java.lang")
Returns:
A copy of this
See Also:
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.