aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/XexunProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-24 22:57:38 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-24 22:57:38 +1300
commit5538a83ac7eda6ad5775e582688dd0199e6c538c (patch)
tree7b261a5e9767fd807124c868d2c4a5d72315e7df /src/org/traccar/protocol/XexunProtocolDecoder.java
parentbe1baf2b062587099171b485ac1e3f591034816f (diff)
downloadtrackermap-server-5538a83ac7eda6ad5775e582688dd0199e6c538c.tar.gz
trackermap-server-5538a83ac7eda6ad5775e582688dd0199e6c538c.tar.bz2
trackermap-server-5538a83ac7eda6ad5775e582688dd0199e6c538c.zip
Refactor pattern builder class
Diffstat (limited to 'src/org/traccar/protocol/XexunProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index 5c719ece7..89ea954bc 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -36,35 +36,36 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern PATTERN_BASIC = new PatternBuilder()
- .xpr("G[PN]RMC,")
- .num("(dd)(dd)(dd).(d+),") // time
- .xpr("([AV]),") // validity
- .num("(d+)(dd.d+),([NS]),") // latitude
- .num("(d+)(dd.d+),([EW])?,") // longitude
- .num("(d+.?d*),") // speed
- .num("(d+.?d*)?,") // course
- .num("(dd)(dd)(dd),") // date
- .nxt("*")
- .num("xx,") // checksum
- .xpr("([FL]),") // signal
- .opx("([^,]*),") // alarm
+ .expression("G[PN]RMC,")
+ .number("(dd)(dd)(dd).(d+),") // time
+ .expression("([AV]),") // validity
+ .number("(d+)(dd.d+),([NS]),") // latitude
+ .number("(d+)(dd.d+),([EW])?,") // longitude
+ .number("(d+.?d*),") // speed
+ .number("(d+.?d*)?,") // course
+ .number("(dd)(dd)(dd),") // date
+ .expression("[^*]*").text("*")
+ .number("xx,") // checksum
+ .expression("([FL]),") // signal
+ .expression("([^,]*),").optional() // alarm
.any()
- .num("imei:(d+),") // imei
+ .number("imei:(d+),") // imei
.compile();
private static final Pattern PATTERN_FULL = new PatternBuilder()
.any()
- .num("(d+),") // serial
- .xpr("([^,]+)?,") // phone number
- .xpr(PATTERN_BASIC.pattern())
- .num("(d+),") // satellites
- .num("(-?d+.d+)?,") // altitude
- .num("[FL]:(d+.d+)V") // power
+ .number("(d+),") // serial
+ .expression("([^,]+)?,") // phone number
+ .expression(PATTERN_BASIC.pattern())
+ .number("(d+),") // satellites
+ .number("(-?d+.d+)?,") // altitude
+ .number("[FL]:(d+.d+)V") // power
.any()
.compile();
@Override
- protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
+ protected Object decode(
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
Pattern pattern = full ? PATTERN_FULL : PATTERN_BASIC;
Matcher parser = pattern.matcher((String) msg);