From 2a14da72f46fb4984713ececc63b2a73954a5782 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 14 Sep 2016 16:31:54 +0500 Subject: - Make Attributes always last column - Format Map as simple string instead of json --- src/org/traccar/web/CsvBuilder.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/web/CsvBuilder.java b/src/org/traccar/web/CsvBuilder.java index 73d5fac1d..cd0f36fc4 100644 --- a/src/org/traccar/web/CsvBuilder.java +++ b/src/org/traccar/web/CsvBuilder.java @@ -37,6 +37,12 @@ public class CsvBuilder { SortedSet methods = new TreeSet(new Comparator() { @Override public int compare(Method m1, Method m2) { + if (m1.getName().equals("getAttributes") & !m1.getName().equals(m2.getName())) { + return 1; + } + if (m2.getName().equals("getAttributes") & !m1.getName().equals(m2.getName())) { + return -1; + } return m1.getName().compareTo(m2.getName()); } }); @@ -73,7 +79,10 @@ public class CsvBuilder { } else if (method.getReturnType().equals(Map.class)) { Map value = (Map) method.invoke(object); if (value != null) { - builder.append(MiscFormatter.toJson(value).toString()); + String map = MiscFormatter.toJson(value).toString(); + map = map.replaceAll("[\\{|\\}|\"]", ""); + map = map.replaceAll(",", " "); + builder.append(map); addSeparator(); } } -- cgit v1.2.3 From 6a2a9637c95b1da12cc82743044c944ff2ab7f81 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 14 Sep 2016 16:44:57 +0500 Subject: Simplify regex --- src/org/traccar/web/CsvBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/traccar/web/CsvBuilder.java b/src/org/traccar/web/CsvBuilder.java index cd0f36fc4..a25b839a9 100644 --- a/src/org/traccar/web/CsvBuilder.java +++ b/src/org/traccar/web/CsvBuilder.java @@ -80,7 +80,7 @@ public class CsvBuilder { Map value = (Map) method.invoke(object); if (value != null) { String map = MiscFormatter.toJson(value).toString(); - map = map.replaceAll("[\\{|\\}|\"]", ""); + map = map.replaceAll("[\\{\\}\"]", ""); map = map.replaceAll(",", " "); builder.append(map); addSeparator(); -- cgit v1.2.3