java.text
public
final
class
java.text.StringCharacterIterator
StringCharacterIterator is an implementation of CharacterIterator for
Strings.
Summary
|
|
|
Value |
|
char |
DONE |
A constant which indicates there is no character. |
65535 |
0x0000ffff |
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
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 |
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
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
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.
public
int
hashCode()
Returns an integer hash code for the receiver. Objects which are equal
answer the same value for this method.
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.
Returns
- the character at the new index, or DONE if the index is past the
end
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
|