Skip to content

Most visited

Recently visited

navigation
Added in API level 1

CharacterIterator

public interface CharacterIterator
implements Cloneable

java.text.CharacterIterator
Known Indirect Subclasses


An interface for the bidirectional iteration over a group of characters. The iteration starts at the begin index in the group of characters and continues to one index before the end index.

Summary

Constants

char DONE

A constant which indicates that there is no character at the current index.

Public methods

abstract Object clone()

Returns a new CharacterIterator with the same properties.

abstract char current()

Returns the character at the current index.

abstract char first()

Sets the current position to the begin index and returns the character at the new position.

abstract int getBeginIndex()

Returns the begin index.

abstract int getEndIndex()

Returns the end index.

abstract int getIndex()

Returns the current index.

abstract char last()

Sets the current position to the end index - 1 and returns the character at the new position.

abstract char next()

Increments the current index and returns the character at the new index.

abstract char previous()

Decrements the current index and returns the character at the new index.

abstract char setIndex(int location)

Sets the current index to a new position and returns the character at the new index.

Constants

DONE

Added in API level 1
char DONE

A constant which indicates that there is no character at the current index.

Constant Value: 65535 (0x0000ffff)

Public methods

clone

Added in API level 1
Object clone ()

Returns a new CharacterIterator with the same properties.

Returns
Object a shallow copy of this character iterator.

See also:

current

Added in API level 1
char current ()

Returns the character at the current index.

Returns
char the current character, or DONE if the current index is past the beginning or end of the sequence.

first

Added in API level 1
char first ()

Sets the current position to the begin index and returns the character at the new position.

Returns
char the character at the begin index.

getBeginIndex

Added in API level 1
int getBeginIndex ()

Returns the begin index.

Returns
int the index of the first character of the iteration.

getEndIndex

Added in API level 1
int getEndIndex ()

Returns the end index.

Returns
int the index one past the last character of the iteration.

getIndex

Added in API level 1
int getIndex ()

Returns the current index.

Returns
int the current index.

last

Added in API level 1
char last ()

Sets the current position to the end index - 1 and returns the character at the new position.

Returns
char the character before the end index.

next

Added in API level 1
char next ()

Increments the current index and returns the character at the new index.

Returns
char the character at the next index, or DONE if the next index would be past the end.

previous

Added in API level 1
char previous ()

Decrements the current index and returns the character at the new index.

Returns
char the character at the previous index, or DONE if the previous index would be past the beginning.

setIndex

Added in API level 1
char setIndex (int location)

Sets the current index to a new position and returns the character at the new index.

Parameters
location int: the new index that this character iterator is set to.
Returns
char the character at the new index, or DONE if the index is past the end.
Throws
IllegalArgumentException if location is less than the begin index or greater than the end index.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.