加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090226230433/http://developer.android.com:80/reference/java/text/StringCharacterIterator.html
public final class

StringCharacterIterator

extends Object
implements CharacterIterator
java.lang.Object
   ↳ java.text.StringCharacterIterator

Class Overview

StringCharacterIterator is an implementation of CharacterIterator for Strings.

Summary

[Expand]
Inherited Constants
From interface java.text.CharacterIterator
Public Constructors
StringCharacterIterator(String value)
Constructs a new StringCharacterIterator on the specified String.
StringCharacterIterator(String value, int location)
Constructs a new StringCharacterIterator on the specified String with the current index set to the specified value.
StringCharacterIterator(String value, int start, int end, int location)
Constructs a new StringCharacterIterator on the specified String with the begin, end and current index set to the specified values.
Public Methods
Object clone()
Returns a new StringCharacterIterator with the same source String, begin, end, and current index as this StringCharacterIterator.
char current()
Returns the character at the current index in the source String.
boolean equals(Object object)
Compares the specified object to this StringCharacterIterator and answer if they are equal.
char first()
Sets the current position to the begin index and returns the character at the begin index.
int getBeginIndex()
Returns the begin index in the source String.
int getEndIndex()
Returns the end index in the source String.
int getIndex()
Returns the current index in the source String.
int hashCode()
Returns an integer hash code for the receiver.
char last()
Sets the current position to the end index - 1 and returns the character at the current position.
char next()
Increments the current index and returns the character at the new index.
char previous()
Decrements the current index and returns the character at the new index.
char setIndex(int location)
Sets the current index in the source String.
void setText(String value)
Sets the source String to iterate.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.text.CharacterIterator

Public Constructors

public StringCharacterIterator (String value)

Constructs a new StringCharacterIterator on the specified String. The begin and current indexes are set to the beginning of the String, the end index is set to the length of the String.

Parameters
value the new source String to iterate

public StringCharacterIterator (String value, int location)

Constructs a new StringCharacterIterator on the specified String with the current index set to the specified value. The begin index is set to the beginning of the String, the end index is set to the length of the String.

Parameters
value the new source String to iterate
location the current index
Throws
IllegalArgumentException when the current index is less than zero or greater than the length of the String

public StringCharacterIterator (String value, int start, int end, int location)

Constructs a new StringCharacterIterator on the specified String with the begin, end and current index set to the specified values.

Parameters
value the new source String to iterate
start the index of the first character to iterate
end the index one past the last character to iterate
location the current index
Throws
IllegalArgumentException when the begin index is less than zero, the end index is greater than the String length, the begin index is greater than the end index, the current index is less than the begin index or greater than the end index

Public Methods

public Object clone ()

Returns a new StringCharacterIterator with the same source String, begin, end, and current index as this StringCharacterIterator.

Returns
  • a shallow copy of this StringCharacterIterator
See Also

public char current ()

Returns the character at the current index in the source String.

Returns
  • the current character, or DONE if the current index is past the end

public boolean equals (Object object)

Compares the specified object to this StringCharacterIterator and answer if they are equal. The object must be a StringCharacterIterator iterating over the same sequence of characters with the same index.

Parameters
object the object to compare with this object
Returns
  • true if the specified object is equal to this StringCharacterIterator, false otherwise
See Also

public char first ()

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

Returns
  • the character at the begin index

public int getBeginIndex ()

Returns the begin index in the source String.

Returns
  • the index of the first character to iterate

public int getEndIndex ()

Returns the end index in the source String.

Returns
  • the index one past the last character to iterate

public int getIndex ()

Returns the current index in the source String.

Returns
  • the current index

public int hashCode ()

Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Returns
  • the receiver's hash
See Also

public char last ()

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

Returns
  • the character before the end index

public char next ()

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

Returns
  • the character at the next index, or DONE if the next index is past the end

public char previous ()

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

Returns
  • the character at the previous index, or DONE if the previous index is past the beginning

public char setIndex (int location)

Sets the current index in the source String.

Parameters
location The index the CharacterIterator is set to.
Returns
  • the character at the new index, or DONE if the index is past the end
Throws
IllegalArgumentException when the new index is less than the begin index or greater than the end index

public void setText (String value)

Sets the source String to iterate. The begin and end positions are set to the start and end of this String.

Parameters
value the new source String