Class CharacterIterator

java.lang.Object
org.glassfish.jersey.uri.internal.CharacterIterator

final class CharacterIterator extends Object
Iterator which iterates through the input string and returns characters from that string.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new iterator initialized with the given input string.
  • Method Summary

    Modifier and Type
    Method
    Description
    char
    Returns character at the current position.
    Returns the input String on which this iterator operates.
    boolean
    Determines whether there is next character in the iteration chain.
    char
    Returns next character in the iteration chain and increase the current position.
    char
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pos

      private int pos
    • s

      private String s
  • Constructor Details

    • CharacterIterator

      public CharacterIterator(String s)
      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 as next() 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

      public String getInput()
      Returns the input String on which this iterator 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.