Package org.eclipse.sisu.space
Class Tokens.TokenIterator
- java.lang.Object
-
- org.eclipse.sisu.space.Tokens.TokenIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.String>
- Enclosing class:
- Tokens
static final class Tokens.TokenIterator extends java.lang.Object implements java.util.Iterator<java.lang.String>Iteratorthat lazily splits a string into tokens.
-
-
Field Summary
Fields Modifier and Type Field Description private charseparatorprivate java.lang.Stringtextprivate inttokenIndexprivate booleantrimming
-
Constructor Summary
Constructors Constructor Description TokenIterator(java.lang.String text, char separator, boolean trimming)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()java.lang.Stringnext()private intnextSeparator(int from)Finds the position of the next separator that follows the current token.private intnextToken(int from)Finds the start of the next token, i.e.voidremove()private inttrimBack(int from)Backtracks to find the non-whitespace end of the current token.
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<java.lang.String>
-
next
public java.lang.String next()
- Specified by:
nextin interfacejava.util.Iterator<java.lang.String>
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<java.lang.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.
-
-