Class CharacterIterator
java.lang.Object
org.glassfish.jersey.uri.internal.CharacterIterator
Iterator which iterates through the input string and returns characters from that string.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new iterator initialized with the given input string. -
Method Summary
Modifier and TypeMethodDescriptionchar
current()
Returns character at the current position.getInput()
Returns the input String on which thisiterator
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.
-
Field Details
-
pos
private int pos -
s
-
-
Constructor Details
-
CharacterIterator
Creates a new iterator initialized with the given input string.- Parameters:
s
- String trough which the iterator iterates.
-
-
Method Details
-
hasNext
public boolean hasNext()Determines whether there is next character in the iteration chain.- Returns:
- True if there is a character which can be retrieved by
next()
, false otherwise.
-
next
public char next()Returns next character in the iteration chain and increase the current position.- Returns:
- Next character.
- Throws:
RuntimeException
- The method might throw exception when there is no more character to be retrieved.
-
peek
public char peek()Returns the next character without increasing the position. The method does the same asnext()
but the position is not changed by calling this method.- Returns:
- Next character.
-
pos
public int pos()Returns the current internal position of the iterator.- Returns:
- current position of the iterator
-
getInput
Returns the input String on which thisiterator
operates.- Returns:
- String which initialized this iterator.
-
setPosition
public void setPosition(int newPosition) Changes the current position to the position.- Parameters:
newPosition
- New position for the iterator.
-
current
public char current()Returns character at the current position.- Returns:
- Character from current position.
-