aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-23 17:34:25 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-23 17:34:25 +0500
commite89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db (patch)
tree51376f73260c9bbc89064ba2b5f2a428b6d46785 /src/org/traccar/model
parentdbbe99269140f057d3f72acca557730a6b10e902 (diff)
downloadtrackermap-server-e89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db.tar.gz
trackermap-server-e89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db.tar.bz2
trackermap-server-e89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db.zip
Implement attributes helpers
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/Extensible.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/Extensible.java
index efe60fb75..b8c83bb21 100644
--- a/src/org/traccar/model/Extensible.java
+++ b/src/org/traccar/model/Extensible.java
@@ -68,4 +68,44 @@ public class Extensible {
}
}
+ public String getString(String key) {
+ if (attributes.containsKey(key)) {
+ return (String) attributes.get(key);
+ } else {
+ return null;
+ }
+ }
+
+ public double getDouble(String key) {
+ if (attributes.containsKey(key)) {
+ return ((Number) attributes.get(key)).doubleValue();
+ } else {
+ return 0.0;
+ }
+ }
+
+ public boolean getBoolean(String key) {
+ if (attributes.containsKey(key)) {
+ return Boolean.parseBoolean(attributes.get(key).toString());
+ } else {
+ return false;
+ }
+ }
+
+ public int getInteger(String key) {
+ if (attributes.containsKey(key)) {
+ return ((Number) attributes.get(key)).intValue();
+ } else {
+ return 0;
+ }
+ }
+
+ public long getLong(String key) {
+ if (attributes.containsKey(key)) {
+ return ((Number) attributes.get(key)).longValue();
+ } else {
+ return 0;
+ }
+ }
+
}