/*
- * Svjatoslav Commons - shared library of common functionality.
- * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 3 of the GNU Lesser General Public License
- * or later as published by the Free Software Foundation.
+ * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
*/
-
package eu.svjatoslav.commons.string.tokenizer;
+import java.util.regex.Matcher;
+
public class TokenizerMatch {
public final String token;
- public final String reminder;
+
+ /**
+ * {@link Terminator} that matched current token
+ */
public final Terminator terminator;
- public TokenizerMatch(final String token, final String reminder, final Terminator terminator) {
+ public final Matcher matcher;
+
+
+ public TokenizerMatch(final String token, final Terminator terminator, Matcher matcher) {
this.token = token;
- this.reminder = reminder;
this.terminator = terminator;
+ this.matcher = matcher;
+ }
+
+ public boolean isGroup(String group){
+ if (terminator == null){
+ return group == null;
+ }
+
+ if (terminator.group == null){
+ return group == null;
+ }
+
+ return terminator.group.equals(group);
}
@Override
public String toString() {
return "TokenizerMatch{" +
"token='" + token + '\'' +
- ", reminder='" + reminder + '\'' +
", terminator=" + terminator +
'}';
}