final class CharacterIterator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
pos |
private java.lang.String |
s |
Constructor and Description |
---|
CharacterIterator(java.lang.String s)
Creates a new iterator initialized with the given input string.
|
Modifier and Type | Method and Description |
---|---|
char |
current()
Returns character at the current position.
|
java.lang.String |
getInput()
Returns the input String on which this
iterator operates. |
boolean |
hasNext()
Determines whether there is next character in the iteration chain.
|
char |
next()
Returns next character in the iteration chain and increase the current position.
|
char |
peek()
Returns the next character without increasing the position.
|
int |
pos()
Returns the current internal position of the iterator.
|
void |
setPosition(int newPosition)
Changes the current position to the position.
|
public CharacterIterator(java.lang.String s)
s
- String trough which the iterator iterates.public boolean hasNext()
next()
, false otherwise.public char next()
java.lang.RuntimeException
- The method might throw exception when there is no more character to be retrieved.public char peek()
next()
but
the position is not changed by calling this method.public int pos()
public java.lang.String getInput()
iterator
operates.public void setPosition(int newPosition)
newPosition
- New position for the iterator.public char current()