From 5cf1061cfcc5baf214bce145961512fd4f672621 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 15 Sep 2015 11:51:45 +1200 Subject: Rename other field to attributes --- src/org/traccar/model/Command.java | 18 +++++++++--------- src/org/traccar/model/Event.java | 16 ++++++++-------- src/org/traccar/model/MiscFormatter.java | 26 +++++++++++++------------- 3 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/org/traccar/model') diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java index cfebaa38e..16772e0cb 100644 --- a/src/org/traccar/model/Command.java +++ b/src/org/traccar/model/Command.java @@ -18,15 +18,15 @@ public class Command implements Factory { public String getType() { return type; } public void setType(String type) { this.type = type; } - private Map other = new LinkedHashMap<>(); - public Map getOther() { return other; } - public void setOther(Map other) { this.other = other; } - - public void set(String key, boolean value) { other.put(key, value); } - public void set(String key, int value) { other.put(key, value); } - public void set(String key, long value) { other.put(key, value); } - public void set(String key, double value) { other.put(key, value); } - public void set(String key, String value) { if (value != null && !value.isEmpty()) other.put(key, value); } + private Map attributes = new LinkedHashMap<>(); + public Map getAttributes() { return attributes; } + public void setAttributes(Map attributes) { this.attributes = attributes; } + + public void set(String key, boolean value) { attributes.put(key, value); } + public void set(String key, int value) { attributes.put(key, value); } + public void set(String key, long value) { attributes.put(key, value); } + public void set(String key, double value) { attributes.put(key, value); } + public void set(String key, String value) { if (value != null && !value.isEmpty()) attributes.put(key, value); } public static final String TYPE_POSITION_SINGLE = "positionSingle"; public static final String TYPE_POSITION_PERIODIC = "positionPeriodic"; diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index 40ea38e26..5ad6c38fe 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -41,15 +41,15 @@ public abstract class Event { public Date getDeviceTime() { return deviceTime; } public void setDeviceTime(Date deviceTime) { this.deviceTime = deviceTime; } - private Map other = new LinkedHashMap<>(); - public Map getOther() { return other; } - public void setOther(Map other) { this.other = other; } + private Map attributes = new LinkedHashMap<>(); + public Map getAttributes() { return attributes; } + public void setAttributes(Map attributes) { this.attributes = attributes; } - public void set(String key, boolean value) { other.put(key, value); } - public void set(String key, int value) { other.put(key, value); } - public void set(String key, long value) { other.put(key, value); } - public void set(String key, double value) { other.put(key, value); } - public void set(String key, String value) { if (value != null && !value.isEmpty()) other.put(key, value); } + public void set(String key, boolean value) { attributes.put(key, value); } + public void set(String key, int value) { attributes.put(key, value); } + public void set(String key, long value) { attributes.put(key, value); } + public void set(String key, double value) { attributes.put(key, value); } + public void set(String key, String value) { if (value != null && !value.isEmpty()) attributes.put(key, value); } // Words separated by dashes (word-second-third) public static final String KEY_INDEX = "index"; diff --git a/src/org/traccar/model/MiscFormatter.java b/src/org/traccar/model/MiscFormatter.java index 7a1e69082..38aa853d4 100644 --- a/src/org/traccar/model/MiscFormatter.java +++ b/src/org/traccar/model/MiscFormatter.java @@ -44,12 +44,12 @@ public class MiscFormatter { } } - public static String toXmlString(Map other) { + public static String toXmlString(Map attributes) { StringBuilder result = new StringBuilder(); result.append("<").append(xmlRootNode).append(">"); - for (Map.Entry entry : other.entrySet()) { + for (Map.Entry entry : attributes.entrySet()) { result.append("<").append(entry.getKey()).append(">"); result.append(format(entry.getValue())); @@ -61,10 +61,10 @@ public class MiscFormatter { return result.toString(); } - public static JsonObject toJson(Map other) { + public static JsonObject toJson(Map attributes) { JsonObjectBuilder json = Json.createObjectBuilder(); - for (Map.Entry entry : other.entrySet()) { + for (Map.Entry entry : attributes.entrySet()) { if (entry.getValue() instanceof String) { json.add(entry.getKey(), (String) entry.getValue()); } else if (entry.getValue() instanceof Integer) { @@ -87,35 +87,35 @@ public class MiscFormatter { public static Map fromJson(JsonObject json) { - Map other = new LinkedHashMap<>(); + Map attributes = new LinkedHashMap<>(); for (Map.Entry entry : json.entrySet()) { switch (entry.getValue().getValueType()) { case STRING: - other.put(entry.getKey(), ((JsonString) entry.getValue()).getString()); + attributes.put(entry.getKey(), ((JsonString) entry.getValue()).getString()); break; case NUMBER: JsonNumber number = (JsonNumber) entry.getValue(); if (number.isIntegral()) { - other.put(entry.getKey(), number.longValue()); + attributes.put(entry.getKey(), number.longValue()); } else { - other.put(entry.getKey(), number.doubleValue()); + attributes.put(entry.getKey(), number.doubleValue()); } break; case TRUE: - other.put(entry.getKey(), true); + attributes.put(entry.getKey(), true); break; case FALSE: - other.put(entry.getKey(), false); + attributes.put(entry.getKey(), false); break; } } - return other; + return attributes; } - public static String toJsonString(Map other) { - return toJson(other).toString(); + public static String toJsonString(Map attributes) { + return toJson(attributes).toString(); } } -- cgit v1.2.3