Class Tokens.TokenIterator

java.lang.Object
org.eclipse.sisu.space.Tokens.TokenIterator
All Implemented Interfaces:
Iterator<String>
Enclosing class:
Tokens

static final class Tokens.TokenIterator extends Object implements Iterator<String>
Iterator that lazily splits a string into tokens.
  • Field Details

    • text

      private final String text
    • separator

      private final char separator
    • trimming

      private final boolean trimming
    • tokenIndex

      private int tokenIndex
  • Constructor Details

    • TokenIterator

      TokenIterator(String text, char separator, boolean trimming)
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<String>
    • next

      public String next()
      Specified by:
      next in interface Iterator<String>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<String>
    • nextToken

      private int nextToken(int from)
      Finds the start of the next token, i.e. not the separator or whitespace when trimming.
    • nextSeparator

      private int nextSeparator(int from)
      Finds the position of the next separator that follows the current token.
    • trimBack

      private int trimBack(int from)
      Backtracks to find the non-whitespace end of the current token.