Build 1.0_r1(from source)

java.text
Class StringCharacterIterator

java.lang.Object
  extended by java.text.StringCharacterIterator
All Implemented Interfaces:
Cloneable, CharacterIterator

public final class StringCharacterIterator
extends Object
implements CharacterIterator

StringCharacterIterator is an implementation of CharacterIterator for Strings.


Field Summary
(package private)  int end
           
(package private)  int offset
           
(package private)  int start
           
(package private)  String string
           
 
Fields inherited from interface java.text.CharacterIterator
DONE
 
Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

string

String string

start

int start

end

int end

offset

int offset
Constructor Detail

StringCharacterIterator

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

StringCharacterIterator

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

StringCharacterIterator

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
Method Detail

clone

public Object clone()
Returns a new StringCharacterIterator with the same source String, begin, end, and current index as this StringCharacterIterator.

Specified by:
clone in interface CharacterIterator
Overrides:
clone in class Object
Returns:
a shallow copy of this StringCharacterIterator
See Also:
Cloneable

current

public char current()
Returns the character at the current index in the source String.

Specified by:
current in interface CharacterIterator
Returns:
the current character, or DONE if the current index is past the end

equals

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.

Overrides:
equals in class Object
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this StringCharacterIterator, false otherwise
See Also:
hashCode()

first

public char first()
Sets the current position to the begin index and returns the character at the begin index.

Specified by:
first in interface CharacterIterator
Returns:
the character at the begin index

getBeginIndex

public int getBeginIndex()
Returns the begin index in the source String.

Specified by:
getBeginIndex in interface CharacterIterator
Returns:
the index of the first character to iterate

getEndIndex

public int getEndIndex()
Returns the end index in the source String.

Specified by:
getEndIndex in interface CharacterIterator
Returns:
the index one past the last character to iterate

getIndex

public int getIndex()
Returns the current index in the source String.

Specified by:
getIndex in interface CharacterIterator
Returns:
the current index

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

last

public char last()
Sets the current position to the end index - 1 and returns the character at the current position.

Specified by:
last in interface CharacterIterator
Returns:
the character before the end index

next

public char next()
Increments the current index and returns the character at the new index.

Specified by:
next in interface CharacterIterator
Returns:
the character at the next index, or DONE if the next index is past the end

previous

public char previous()
Decrements the current index and returns the character at the new index.

Specified by:
previous in interface CharacterIterator
Returns:
the character at the previous index, or DONE if the previous index is past the beginning

setIndex

public char setIndex(int location)
Sets the current index in the source String.

Specified by:
setIndex in interface CharacterIterator
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

setText

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

Build 1.0_r1(from source)

Please submit a feedback, bug or feature