aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Avl08ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-06-20 22:06:51 +0400
committerAnton Tananaev <anton.tananaev@gmail.com>2012-06-20 22:06:51 +0400
commit23bf37045d96197ed43a02b48b9996103922593a (patch)
treede71e359adb9d4a521266237ba64cc33cef0e83c /src/org/traccar/protocol/Avl08ProtocolDecoder.java
parent15d13a99d3215a3208b2c44a07a29a7af9c13de3 (diff)
downloadtrackermap-server-23bf37045d96197ed43a02b48b9996103922593a.tar.gz
trackermap-server-23bf37045d96197ed43a02b48b9996103922593a.tar.bz2
trackermap-server-23bf37045d96197ed43a02b48b9996103922593a.zip
Optimize strings
Diffstat (limited to 'src/org/traccar/protocol/Avl08ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Avl08ProtocolDecoder.java56
1 files changed, 41 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/Avl08ProtocolDecoder.java
index 0ca976d26..2dc711cd7 100644
--- a/src/org/traccar/protocol/Avl08ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl08ProtocolDecoder.java
@@ -82,7 +82,7 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder {
// Create new position
Position position = new Position();
- String extendedInfo = "<protocol>avl08</protocol>";
+ StringBuilder extendedInfo = new StringBuilder("<protocol>avl08</protocol>");
Integer index = 1;
@@ -91,7 +91,9 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder {
position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
// Alarm type
- extendedInfo += "<alarm>" + parser.group(index++) + "</alarm>";
+ extendedInfo.append("<alarm>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</alarm>");
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
@@ -137,44 +139,68 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder {
position.setTime(time.getTime());
// Dilution of precision
- extendedInfo += "<pdop>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</pdop>";
- extendedInfo += "<hdop>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</hdop>";
- extendedInfo += "<vdop>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</vdop>";
+ extendedInfo.append("<pdop>");
+ extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", ""));
+ extendedInfo.append("</pdop>");
+ extendedInfo.append("<hdop>");
+ extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", ""));
+ extendedInfo.append("</hdop>");
+ extendedInfo.append("<vdop>");
+ extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", ""));
+ extendedInfo.append("</vdop>");
// Status
- extendedInfo += "<status>" + parser.group(index++) + "</status>";
+ extendedInfo.append("<status>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</status>");
// Real time clock
- extendedInfo += "<clock>" + parser.group(index++) + "</clock>";
+ extendedInfo.append("<clock>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</clock>");
// Voltage
String voltage = parser.group(index++);
position.setPower(Double.valueOf(voltage.substring(1, 4)) / 100);
- extendedInfo += "<voltage>" + voltage + "</voltage>";
+ extendedInfo.append("<voltage>");
+ extendedInfo.append(voltage);
+ extendedInfo.append("</voltage>");
// ADC
- extendedInfo += "<adc>" + parser.group(index++) + "</adc>";
+ extendedInfo.append("<adc>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</adc>");
// Cell
- extendedInfo += "<cell>" + parser.group(index++) + "</cell>";
+ extendedInfo.append("<cell>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</cell>");
// Temperature
- extendedInfo += "<temperature>" + parser.group(index++) + "</temperature>";
+ extendedInfo.append("<temperature>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</temperature>");
// Mileage
- extendedInfo += "<mileage>" + parser.group(index++) + "</mileage>";
+ extendedInfo.append("<mileage>");
+ extendedInfo.append(parser.group(index++));
+ extendedInfo.append("</mileage>");
// Serial
- extendedInfo += "<serial>" + parser.group(index++).replaceFirst ("^0*", "") + "</serial>";
+ extendedInfo.append("<serial>");
+ extendedInfo.append(parser.group(index++).replaceFirst ("^0*", ""));
+ extendedInfo.append("</serial>");
// RFID
String rfid = parser.group(index++);
if (rfid != null) {
- extendedInfo += "<rfid>" + rfid + "</rfid>";
+ extendedInfo.append("<rfid>");
+ extendedInfo.append(rfid);
+ extendedInfo.append("</rfid>");
}
// Extended info
- position.setExtendedInfo(extendedInfo);
+ position.setExtendedInfo(extendedInfo.toString());
return position;
}