Top Description Fields Constructors Methods
org.glassfish.tyrus.core.uri.internal

pack-priv final Class CharacterIterator

extends Object
Class Inheritance
Imports
java.util.NoSuchElementException

Iterator which iterates through the input string and returns characters from that string.
Author
Miroslav Fuksa

Field Summary

Modifier and TypeField and Description
private int
private String
s

Constructor Summary

AccessConstructor and Description
public
CharacterIterator(final String
String trough which the iterator iterates.
s
)

Creates a new iterator initialized with the given input string.

Method Summary

Modifier and TypeMethod and Description
public char

Returns:

Character from current position.
current
()

Returns character at the current position.

public String

Returns:

String which initialized this iterator.
getInput
()

Returns the input String on which this iterator operates.

public boolean

Returns:

True if there is a character which can be retrieved by next(), false otherwise.
hasNext
()

Determines whether there is next character in the iteration chain.

public char

Returns:

Next character.
next
()

Returns next character in the iteration chain and increase the current position.

public char

Returns:

Next character.
peek
()

Returns the next character without increasing the position.

public int

Returns:

current position of the iterator
pos
()

Returns the current internal position of the iterator.

public void
setPosition(int
New position for the iterator.
newPosition
)

Changes the current position to the position.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

posback to summary
private int pos
sback to summary
private String s

Constructor Detail

CharacterIteratorback to summary
public CharacterIterator(final String s)

Creates a new iterator initialized with the given input string.

Parameters
s:String

String trough which the iterator iterates.

Method Detail

currentback to summary
public char current()

Returns character at the current position.

Returns:char

Character from current position.

getInputback to summary
public String getInput()

Returns the input String on which this iterator operates.

Returns:String

String which initialized this iterator.

hasNextback to summary
public boolean hasNext()

Determines whether there is next character in the iteration chain.

Returns:boolean

True if there is a character which can be retrieved by next(), false otherwise.

nextback to summary
public char next()

Returns next character in the iteration chain and increase the current position.

Returns:char

Next character.

Exceptions
RuntimeException:
The method might throw exception when there is no more character to be retrieved.
peekback to summary
public char peek()

Returns the next character without increasing the position. The method does the same as next() but the position is not changed by calling this method.

Returns:char

Next character.

posback to summary
public int pos()

Returns the current internal position of the iterator.

Returns:int

current position of the iterator

setPositionback to summary
public void setPosition(int newPosition)

Changes the current position to the position.

Parameters
newPosition:int

New position for the iterator.