Added in API level 1

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

Constructs an iterator with an initial index of 0.

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

Creates a copy of this iterator.

Char

Implements CharacterIterator.

Boolean
equals(other: Any?)

Compares the equality of two StringCharacterIterator objects.

Char

Implements CharacterIterator.

Int

Implements CharacterIterator.

Int

Implements CharacterIterator.

Int

Implements CharacterIterator.

Int

Computes a hashcode for this iterator.

Char

Implements CharacterIterator.

Char

Implements CharacterIterator.

Char

Implements CharacterIterator.

Char

Implements CharacterIterator.

Unit
setText(text: String!)

Reset this iterator to point to a new string.

Public constructors

StringCharacterIterator

Added in API level 1
StringCharacterIterator(text: String!)

Constructs an iterator with an initial index of 0.

Parameters
text String!: the String to be iterated over

StringCharacterIterator

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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.

equals

Added in API level 1
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

Added in API level 1
fun first(): Char

Implements CharacterIterator.first() for String.

Return
Char the first character in the text, or DONE if the text is empty

getBeginIndex

Added in API level 1
fun getBeginIndex(): Int

Implements CharacterIterator.getBeginIndex() for String.

Return
Int the index at which the text begins.

getEndIndex

Added in API level 1
fun getEndIndex(): Int

Implements CharacterIterator.getEndIndex() for String.

Return
Int the index after the last character in the text

getIndex

Added in API level 1
fun getIndex(): Int

Implements CharacterIterator.getIndex() for String.

Return
Int the current index.

hashCode

Added in API level 1
fun hashCode(): Int

Computes a hashcode for this iterator.

Return
Int A hash code

last

Added in API level 1
fun last(): Char

Implements CharacterIterator.last() for String.

Return
Char the last character in the text, or DONE if the text is empty

next

Added in API level 1
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.

previous

Added in API level 1
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().

setIndex

Added in API level 1
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()

setText

Added in API level 1
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