aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/WondexProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-05-02 22:16:14 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-05-02 22:16:14 +1200
commit81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b (patch)
treece4d0b24f1c82381da30472844052f8cfdc1a164 /src/org/traccar/protocol/WondexProtocolDecoder.java
parentf367b71b9c081416f6d64f6efd9844cd05f047ea (diff)
downloadtrackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.gz
trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.tar.bz2
trackermap-server-81beb5afb946d8c9ccfa2bbdfcfe884771a5bd3b.zip
Fix extended info XML format
Diffstat (limited to 'src/org/traccar/protocol/WondexProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/WondexProtocolDecoder.java37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java
index ebae99bb4..65fb3526d 100644
--- a/src/org/traccar/protocol/WondexProtocolDecoder.java
+++ b/src/org/traccar/protocol/WondexProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
public class WondexProtocolDecoder extends BaseProtocolDecoder {
@@ -32,9 +33,6 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- /**
- * Regular expressions pattern
- */
static private Pattern pattern = Pattern.compile(
"[^\\d]*" + // Header
"(\\d+)," + // Device Identifier
@@ -66,7 +64,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- StringBuilder extendedInfo = new StringBuilder("<protocol>wondex</protocol>");
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("wondex");
int index = 1;
// Device identifier
@@ -99,40 +97,23 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
// Satellites
int satellites = Integer.valueOf(parser.group(index++));
position.setValid(satellites >= 3);
- extendedInfo.append("<satellites>").append(satellites).append("</satellites>");
+ extendedInfo.set("satellites", satellites);
// Event
- extendedInfo.append("<event>");
- extendedInfo.append(parser.group(index++));
- extendedInfo.append("</event>");
+ extendedInfo.set("event", parser.group(index++));
// Milage
- String milage = parser.group(index++);
- if (milage != null) {
- extendedInfo.append("<milage>").append(milage).append("</milage>");
- }
+ extendedInfo.set("milage", parser.group(index++));
// Input
- String input = parser.group(index++);
- if (input != null) {
- extendedInfo.append("<input>").append(input).append("</input>");
- }
+ extendedInfo.set("input", parser.group(index++));
// ADC
- String adc1 = parser.group(index++);
- if (adc1 != null) {
- extendedInfo.append("<adc1>").append(adc1).append("</adc1>");
- }
- String adc2 = parser.group(index++);
- if (adc2 != null) {
- extendedInfo.append("<adc2>").append(adc2).append("</adc2>");
- }
+ extendedInfo.set("adc1", parser.group(index++));
+ extendedInfo.set("adc2", parser.group(index++));
// Output
- String output = parser.group(index++);
- if (output != null) {
- extendedInfo.append("<output>").append(output).append("</output>");
- }
+ extendedInfo.set("output", parser.group(index++));
position.setExtendedInfo(extendedInfo.toString());
return position;