diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-06-20 22:06:51 +0400 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-06-20 22:06:51 +0400 |
commit | 23bf37045d96197ed43a02b48b9996103922593a (patch) | |
tree | de71e359adb9d4a521266237ba64cc33cef0e83c /src/org/traccar/protocol/Xexun2ProtocolDecoder.java | |
parent | 15d13a99d3215a3208b2c44a07a29a7af9c13de3 (diff) | |
download | trackermap-server-23bf37045d96197ed43a02b48b9996103922593a.tar.gz trackermap-server-23bf37045d96197ed43a02b48b9996103922593a.tar.bz2 trackermap-server-23bf37045d96197ed43a02b48b9996103922593a.zip |
Optimize strings
Diffstat (limited to 'src/org/traccar/protocol/Xexun2ProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/Xexun2ProtocolDecoder.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java index 2449a60a6..1ee2737d1 100644 --- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java @@ -82,15 +82,19 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder { // Create new position Position position = new Position(); - String extendedInfo = "<protocol>xexun2</protocol>"; + StringBuilder extendedInfo = new StringBuilder("<protocol>xexun2</protocol>"); Integer index = 1; // Serial - extendedInfo += "<serial>" + parser.group(index++) + "</serial>"; + extendedInfo.append("<serial>"); + extendedInfo.append(parser.group(index++)); + extendedInfo.append("</serial>"); // Number - extendedInfo += "<number>" + parser.group(index++) + "</number>"; + extendedInfo.append("<number>"); + extendedInfo.append(parser.group(index++)); + extendedInfo.append("</number>"); // Time Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -133,17 +137,23 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder { position.setTime(time.getTime()); // Signal - extendedInfo += "<signal>" + parser.group(index++) + "</signal>"; + extendedInfo.append("<signal>"); + extendedInfo.append(parser.group(index++)); + extendedInfo.append("</signal>"); // Alarm - extendedInfo += "<alarm>" + parser.group(index++) + "</alarm>"; + extendedInfo.append("<alarm>"); + extendedInfo.append(parser.group(index++)); + extendedInfo.append("</alarm>"); // Get device by IMEI String imei = parser.group(index++); position.setDeviceId(getDataManager().getDeviceByImei(imei).getId()); // Satellites - extendedInfo += "<satellites>" + parser.group(index++).replaceFirst ("^0*(?![\\.$])", "") + "</satellites>"; + extendedInfo.append("<satellites>"); + extendedInfo.append(parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); + extendedInfo.append("</satellites>"); // Altitude position.setAltitude(Double.valueOf(parser.group(index++))); @@ -152,7 +162,7 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder { position.setPower(Double.valueOf(parser.group(index++))); // Extended info - position.setExtendedInfo(extendedInfo); + position.setExtendedInfo(extendedInfo.toString()); return position; } |