StringCharacterIterator
class StringCharacterIterator : CharacterIterator
| kotlin.Any | |
| ↳ | java.text.StringCharacterIterator |
StringCharacterIterator implements the CharacterIterator protocol for a String. The StringCharacterIterator class iterates over the entire String.
Summary
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
StringCharacterIterator(text: String!)Constructs an iterator with an initial index of 0. |
|
StringCharacterIterator(text: String!, pos: Int)Constructs an iterator with the specified initial index. |
|
StringCharacterIterator(text: String!, begin: Int, end: Int, pos: Int)Constructs an iterator over the given range of the given string, with the index set at the specified position. |
|
| Public methods | |
|---|---|
| Any |
clone()Creates a copy of this iterator. |
| Char |
current()Implements CharacterIterator. |
| Boolean |
Compares the equality of two StringCharacterIterator objects. |
| Char |
first()Implements CharacterIterator. |
| Int |
Implements CharacterIterator. |
| Int |
Implements CharacterIterator. |
| Int |
getIndex()Implements CharacterIterator. |
| Int |
hashCode()Computes a hashcode for this iterator. |
| Char |
last()Implements CharacterIterator. |
| Char |
next()Implements CharacterIterator. |
| Char |
previous()Implements CharacterIterator. |
| Char |
Implements CharacterIterator. |
| Unit |
Reset this iterator to point to a new string. |
Public constructors
StringCharacterIterator
StringCharacterIterator(text: String!)
Constructs an iterator with an initial index of 0.
| Parameters | |
|---|---|
text |
String!: the String to be iterated over |
StringCharacterIterator
StringCharacterIterator(
text: String!,
pos: Int)
Constructs an iterator with the specified initial index.
| Parameters | |
|---|---|
text |
String!: The String to be iterated over |
pos |
Int: Initial iterator position |
StringCharacterIterator
StringCharacterIterator(
text: String!,
begin: Int,
end: Int,
pos: Int)
Constructs an iterator over the given range of the given string, with the index set at the specified position.
| Parameters | |
|---|---|
text |
String!: The String to be iterated over |
begin |
Int: Index of the first character |
end |
Int: Index of the character following the last character |
pos |
Int: Initial iterator position |
Public methods
clone
fun clone(): Any
Creates a copy of this iterator.
| Return | |
|---|---|
Any |
A copy of this |
| Exceptions | |
|---|---|
java.lang.CloneNotSupportedException |
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned. |
current
fun current(): Char
Implements CharacterIterator.current() for String.
| Return | |
|---|---|
Char |
the character at the current position or DONE if the current position is off the end of the text. |
See Also
equals
fun equals(other: Any?): Boolean
Compares the equality of two StringCharacterIterator objects.
| Parameters | |
|---|---|
obj |
the StringCharacterIterator object to be compared with. |
| Return | |
|---|---|
Boolean |
true if the given obj is the same as this StringCharacterIterator object; false otherwise. |
first
fun first(): Char
Implements CharacterIterator.first() for String.
| Return | |
|---|---|
Char |
the first character in the text, or DONE if the text is empty |
See Also
getBeginIndex
fun getBeginIndex(): Int
Implements CharacterIterator.getBeginIndex() for String.
| Return | |
|---|---|
Int |
the index at which the text begins. |
getEndIndex
fun getEndIndex(): Int
Implements CharacterIterator.getEndIndex() for String.
| Return | |
|---|---|
Int |
the index after the last character in the text |
getIndex
fun getIndex(): Int
Implements CharacterIterator.getIndex() for String.
| Return | |
|---|---|
Int |
the current index. |
See Also
hashCode
fun hashCode(): Int
Computes a hashcode for this iterator.
| Return | |
|---|---|
Int |
A hash code |
last
fun last(): Char
Implements CharacterIterator.last() for String.
| Return | |
|---|---|
Char |
the last character in the text, or DONE if the text is empty |
See Also
next
fun next(): Char
Implements CharacterIterator.next() for String.
| Return | |
|---|---|
Char |
the character at the new position or DONE if the new position is off the end of the text range. |
See Also
previous
fun previous(): Char
Implements CharacterIterator.previous() for String.
| Return | |
|---|---|
Char |
the character at the new position or DONE if the current position is equal to getBeginIndex(). |
See Also
setIndex
fun setIndex(p: Int): Char
Implements CharacterIterator.setIndex() for String.
| Parameters | |
|---|---|
position |
the position within the text. Valid values range from getBeginIndex() to getEndIndex(). An IllegalArgumentException is thrown if an invalid value is supplied. |
| Return | |
|---|---|
Char |
the character at the specified position or DONE if the specified position is equal to getEndIndex() |
See Also
setText
fun setText(text: String!): Unit
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 |
String!: The String to be iterated over |