Possibility to peek next value.
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Wed, 11 Oct 2017 14:36:05 +0000 (17:36 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Wed, 11 Oct 2017 14:36:05 +0000 (17:36 +0300)
src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java

index 899f8c4..ba1590d 100755 (executable)
@@ -104,6 +104,23 @@ public class Tokenizer {
         return false;
     }
 
+    public TokenizerMatch peekNextToken(){
+        TokenizerMatch result = getNextToken();
+        unreadToken();
+        return result;
+    }
+
+    public boolean peekIsOneOf(String [] ... possibilities){
+        TokenizerMatch nextToken = peekNextToken();
+
+        for (String[] possibility : possibilities)
+            if (possibility.equals(nextToken))
+                return true;
+
+        return false;
+    }
+
+
     public boolean sequenceMatches(final String sequence) {
         if ((currentIndex + sequence.length()) > source.length())
             return false;