diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-19 23:33:42 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-19 23:33:42 +1200 |
commit | fd2fd71a522585ade8653618d95eb0f846f4bfbb (patch) | |
tree | 72ac71451fec5ecea2315d2ae44105b40285a7ca | |
parent | 56a4fe28c4d72b8ec1f55fce4c8de18c1ef71f73 (diff) | |
download | traccar-server-fd2fd71a522585ade8653618d95eb0f846f4bfbb.tar.gz traccar-server-fd2fd71a522585ade8653618d95eb0f846f4bfbb.tar.bz2 traccar-server-fd2fd71a522585ade8653618d95eb0f846f4bfbb.zip |
Update regex pattern debugger
-rw-r--r-- | src/org/traccar/helper/PatternUtil.java | 26 | ||||
-rw-r--r-- | test/org/traccar/helper/PatternUtilTest.java | 2 |
2 files changed, 11 insertions, 17 deletions
diff --git a/src/org/traccar/helper/PatternUtil.java b/src/org/traccar/helper/PatternUtil.java index 88c3f053b..f665eb30d 100644 --- a/src/org/traccar/helper/PatternUtil.java +++ b/src/org/traccar/helper/PatternUtil.java @@ -25,20 +25,13 @@ public final class PatternUtil { } public static class MatchResult { - private String pattern; - private String matched; - private String remaining; + private String patternMatch; + private String patternTail; + private String stringMatch; + private String stringTail; - public String getPattern() { - return this.pattern; - } - - public String getMatched() { - return this.matched; - } - - public String getRemaining() { - return this.remaining; + public String getPatternMatch() { + return patternMatch; } } @@ -50,9 +43,10 @@ public final class PatternUtil { try { Matcher matcher = Pattern.compile("(" + pattern.substring(0, i) + ").*").matcher(input); if (matcher.matches()) { - result.pattern = pattern.substring(0, i); - result.matched = matcher.group(1); - result.remaining = input.substring(matcher.group(1).length()); + result.patternMatch = pattern.substring(0, i); + result.patternTail = pattern.substring(i); + result.stringMatch = matcher.group(1); + result.stringTail = input.substring(matcher.group(1).length()); } } catch (PatternSyntaxException error) { Log.warning(error); diff --git a/test/org/traccar/helper/PatternUtilTest.java b/test/org/traccar/helper/PatternUtilTest.java index bb1349363..b6b05e88c 100644 --- a/test/org/traccar/helper/PatternUtilTest.java +++ b/test/org/traccar/helper/PatternUtilTest.java @@ -9,7 +9,7 @@ public class PatternUtilTest { @Test public void testCheckPattern() { - assertEquals("ab", PatternUtil.checkPattern("abc", "abd").getPattern()); + assertEquals("ab", PatternUtil.checkPattern("abc", "abd").getPatternMatch()); } |