aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-07 23:03:46 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-07 23:37:32 +1200
commit3b7148075815aa7f6cd650013949934a50a573f7 (patch)
tree0c5bfe25175f7d0d0c787a43ab9a802361588f3b /src/org/traccar
parent1a0ee4171d4f3dbddcbffc65f254fae2bd4632e0 (diff)
downloadtrackermap-server-3b7148075815aa7f6cd650013949934a50a573f7.tar.gz
trackermap-server-3b7148075815aa7f6cd650013949934a50a573f7.tar.bz2
trackermap-server-3b7148075815aa7f6cd650013949934a50a573f7.zip
Optimize minifinder decoder class
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index db01eaa9f..c7b0aecb2 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -142,18 +142,12 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
if (sentence.startsWith("!1,")) {
-
getDeviceSession(channel, remoteAddress, sentence.substring(3, sentence.length()));
-
return null;
}
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
- if (deviceSession == null) {
- return null;
- }
-
- if (!sentence.matches("![A-D],.*")) {
+ if (deviceSession == null || !sentence.matches("![A-D],.*")) {
return null;
}
@@ -161,10 +155,11 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- String recordType = sentence.substring(1, 2);
- position.set(Position.KEY_TYPE, recordType);
+ String type = sentence.substring(1, 2);
+ position.set(Position.KEY_TYPE, type);
+
+ if (type.equals("B") || type.equals("D")) {
- if (recordType.matches("[BD]")) {
Parser parser = new Parser(PATTERN_BD, sentence);
if (!parser.matches()) {
return null;
@@ -175,9 +170,9 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
decodeGPSPrecision(position, parser);
return position;
- }
- if (recordType.matches("C")) {
+ } else if (type.equals("C")) {
+
Parser parser = new Parser(PATTERN_C, sentence);
if (!parser.matches()) {
return null;
@@ -187,9 +182,9 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
decodeState(position, parser);
return position;
- }
- if (recordType.matches("A")) {
+ } else if (type.equals("A")) {
+
Parser parser = new Parser(PATTERN_A, sentence);
if (!parser.matches()) {
return null;
@@ -198,6 +193,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
decodeFix(position, parser);
return position;
+
}
return null;