com.mobicage.rogerthat.form.LocationWidgetResult.java Source code

Java tutorial

Introduction

Here is the source code for com.mobicage.rogerthat.form.LocationWidgetResult.java

Source

/*
 * COPYRIGHT (C) 2011 MOBICAGE NV
 * ALL RIGHTS RESERVED.
 *
 * ALTHOUGH YOU MAY BE ABLE TO READ THE CONTENT OF THIS FILE, THIS FILE
 * CONTAINS CONFIDENTIAL INFORMATION OF MOBICAGE NV. YOU ARE NOT ALLOWED
 * TO MODIFY, REPRODUCE, DISCLOSE, PUBLISH OR DISTRIBUTE ITS CONTENT,
 * EMBED IT IN OTHER SOFTWARE, OR CREATE DERIVATIVE WORKS, UNLESS PRIOR
 * WRITTEN PERMISSION IS OBTAINED FROM MOBICAGE NV.
 *
 * THE COPYRIGHT NOTICE ABOVE DOES NOT EVIDENCE ANY ACTUAL OR INTENDED
 * PUBLICATION OF SUCH SOURCE CODE.
 *
 * @@license_version:1.4@@
 */
package com.mobicage.rogerthat.form;

import org.json.simple.JSONObject;

public class LocationWidgetResult extends WidgetResult {

    public final static String TYPE = "location_result";

    public double horizontalAccuracy;
    public double verticalAccuracy;
    public double latitude;
    public double longitude;
    public double altitude;
    public long timestamp;

    @SuppressWarnings("unchecked")
    @Override
    public JSONObject toJSONObject() {
        JSONObject obj = new JSONObject();
        obj.put("horizontal_accuracy", this.horizontalAccuracy);
        obj.put("vertical_accuracy", this.verticalAccuracy);
        obj.put("latitude", this.latitude);
        obj.put("longitude", this.longitude);
        obj.put("altitude", this.altitude);
        obj.put("timestamp", this.timestamp);
        return obj;
    }

    @Override
    public void fromJSONObject(JSONObject source) {
        this.horizontalAccuracy = toDouble(source.get("horizontal_accuracy"));
        this.verticalAccuracy = toDouble(source.get("vertical_accuracy"));
        this.latitude = toDouble(source.get("latitude"));
        this.longitude = toDouble(source.get("longitude"));
        this.altitude = toDouble(source.get("altitude"));
        this.timestamp = (Long) source.get("timestamp");
    }

    @Override
    public String getWidgetResultType() {
        return LocationWidgetResult.TYPE;
    }

}