aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/model/ExtendedInfoFormatter.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/org/traccar/model/ExtendedInfoFormatter.java b/src/org/traccar/model/ExtendedInfoFormatter.java
index 31aac7672..e7e0dead0 100644
--- a/src/org/traccar/model/ExtendedInfoFormatter.java
+++ b/src/org/traccar/model/ExtendedInfoFormatter.java
@@ -15,6 +15,7 @@
*/
package org.traccar.model;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -42,9 +43,8 @@ public class ExtendedInfoFormatter {
data.put(key, value);
}
}
-
- @Override
- public String toString() {
+
+ private String toXmlString() {
StringBuilder result = new StringBuilder();
result.append("<").append(rootNode).append(">");
@@ -60,5 +60,34 @@ public class ExtendedInfoFormatter {
return result.toString();
}
+
+ private String toJsonString() {
+ StringBuilder result = new StringBuilder();
+
+ result.append("{");
+
+ Iterator<Map.Entry<String, Object> > i = data.entrySet().iterator();
+
+ while (i.hasNext()) {
+ Map.Entry<String, Object> entry = i.next();
+
+ result.append('"').append(entry.getKey()).append('"');
+ result.append(':');
+ result.append('"').append(entry.getValue()).append('"');
+
+ if (i.hasNext()) {
+ result.append(',');
+ }
+ }
+
+ result.append("}");
+
+ return result.toString();
+ }
+
+ @Override
+ public String toString() {
+ return toXmlString();
+ }
}