From fac4a7627b6496ff15c113adf6eaf2929520c043 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Wed, 11 Oct 2017 17:36:05 +0300 Subject: [PATCH] Possibility to peek next value. --- .../commons/string/tokenizer/Tokenizer.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java b/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java index 899f8c4..ba1590d 100755 --- a/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java +++ b/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java @@ -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; -- 2.20.1