Package org.eclipse.sisu.space
Class Tokens.TokenIterator
java.lang.Object
org.eclipse.sisu.space.Tokens.TokenIterator
- Enclosing class:
Tokens
Iterator
that lazily splits a string into tokens.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final char
private final String
private int
private final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
hasNext()
next()
private int
nextSeparator
(int from) Finds the position of the next separator that follows the current token.private int
nextToken
(int from) Finds the start of the next token, i.e.void
remove()
private int
trimBack
(int from) Backtracks to find the non-whitespace end of the current token.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
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() -
next
-
remove
public void remove() -
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.
-