diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-13 23:11:23 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-13 23:11:23 +1300 |
commit | 398b705820109c1103d915a2fec81fcf70b032cf (patch) | |
tree | 659a0483eda19f9c91855197b70fd2a0bfb82a60 /src/org/traccar/helper/PatternBuilder.java | |
parent | 2da5669f8bd3f734fa37626c892aebdff7268613 (diff) | |
download | trackermap-server-398b705820109c1103d915a2fec81fcf70b032cf.tar.gz trackermap-server-398b705820109c1103d915a2fec81fcf70b032cf.tar.bz2 trackermap-server-398b705820109c1103d915a2fec81fcf70b032cf.zip |
Fix some check style issues
Diffstat (limited to 'src/org/traccar/helper/PatternBuilder.java')
-rw-r--r-- | src/org/traccar/helper/PatternBuilder.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/org/traccar/helper/PatternBuilder.java b/src/org/traccar/helper/PatternBuilder.java index 0105bf7a6..fbef144e6 100644 --- a/src/org/traccar/helper/PatternBuilder.java +++ b/src/org/traccar/helper/PatternBuilder.java @@ -25,20 +25,24 @@ public class PatternBuilder { void build(PatternBuilder builder); } + // eXPRession public PatternBuilder xpr(String s) { pattern.append(s); return this; } + // OPtional eXpression public PatternBuilder opx(String s) { return xpr("(?:").xpr(s).xpr(")?"); } + // TeXT public PatternBuilder txt(String s) { pattern.append(s.replaceAll("([\\\\\\.\\[\\{\\(\\*\\+\\?\\^\\$\\|])", "\\\\$1")); return this; } + // NUMber public PatternBuilder num(String s) { s = s.replace("dddd", "d{4}").replace("ddd", "d{3}").replace("dd", "d{2}"); s = s.replace("xxxx", "x{4}").replace("xxx", "x{3}").replace("xx", "x{2}"); @@ -47,6 +51,7 @@ public class PatternBuilder { return this; } + // OPtional Number public PatternBuilder opn(String s) { return xpr("(?:").num(s).xpr(")?"); } @@ -60,6 +65,7 @@ public class PatternBuilder { return xpr("[^").txt(s).xpr("]*"); } + // NeXT public PatternBuilder nxt(String s) { return not(s).txt(s); } @@ -69,7 +75,11 @@ public class PatternBuilder { } public PatternBuilder groupEnd(boolean optional) { - return xpr(optional ? ")?" : ")"); + if (optional) { + return xpr(")?"); + } else { + return xpr(")"); + } } public Pattern compile() { |