diff options
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r-- | src/org/traccar/model/Extensible.java | 40 |
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; + } + } + } |