From: Svjatoslav Agejenko Date: Wed, 11 Oct 2017 14:36:05 +0000 (+0300) Subject: Possibility to peek next value. X-Git-Tag: svjatoslavcommons-1.8~56 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=fac4a7627b6496ff15c113adf6eaf2929520c043;p=svjatoslav_commons.git Possibility to peek next value. --- 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;