Example usage for org.json JSONException printStackTrace

List of usage examples for org.json JSONException printStackTrace

Introduction

In this page you can find the example usage for org.json JSONException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:cn.code.notes.gtask.data.TaskList.java

public JSONObject getUpdateAction(int actionId) {
    JSONObject js = new JSONObject();

    try {//from   w  ww  .  j a va  2  s. c o m
        // action_type
        js.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE, GTaskStringUtils.GTASK_JSON_ACTION_TYPE_UPDATE);

        // action_id
        js.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, actionId);

        // id
        js.put(GTaskStringUtils.GTASK_JSON_ID, getGid());

        // entity_delta
        JSONObject entity = new JSONObject();
        entity.put(GTaskStringUtils.GTASK_JSON_NAME, getName());
        entity.put(GTaskStringUtils.GTASK_JSON_DELETED, getDeleted());
        js.put(GTaskStringUtils.GTASK_JSON_ENTITY_DELTA, entity);

    } catch (JSONException e) {
        Log.e(TAG, e.toString());
        e.printStackTrace();
        throw new ActionFailureException("fail to generate tasklist-update jsonobject");
    }

    return js;
}

From source file:cn.code.notes.gtask.data.TaskList.java

public void setContentByRemoteJSON(JSONObject js) {
    if (js != null) {
        try {/*www  . j ava2  s  .c  o m*/
            // id
            if (js.has(GTaskStringUtils.GTASK_JSON_ID)) {
                setGid(js.getString(GTaskStringUtils.GTASK_JSON_ID));
            }

            // last_modified
            if (js.has(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED)) {
                setLastModified(js.getLong(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED));
            }

            // name
            if (js.has(GTaskStringUtils.GTASK_JSON_NAME)) {
                setName(js.getString(GTaskStringUtils.GTASK_JSON_NAME));
            }

        } catch (JSONException e) {
            Log.e(TAG, e.toString());
            e.printStackTrace();
            throw new ActionFailureException("fail to get tasklist content from jsonobject");
        }
    }
}

From source file:cn.code.notes.gtask.data.TaskList.java

public void setContentByLocalJSON(JSONObject js) {
    if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
        Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
    }/*  w  w  w. jav  a2 s.  c om*/

    try {
        JSONObject folder = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);

        if (folder.getInt(NoteColumns.TYPE) == Notes.TYPE_FOLDER) {
            String name = folder.getString(NoteColumns.SNIPPET);
            setName(GTaskStringUtils.MIUI_FOLDER_PREFFIX + name);
        } else if (folder.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) {
            if (folder.getLong(NoteColumns.ID) == Notes.ID_ROOT_FOLDER)
                setName(GTaskStringUtils.MIUI_FOLDER_PREFFIX + GTaskStringUtils.FOLDER_DEFAULT);
            else if (folder.getLong(NoteColumns.ID) == Notes.ID_CALL_RECORD_FOLDER)
                setName(GTaskStringUtils.MIUI_FOLDER_PREFFIX + GTaskStringUtils.FOLDER_CALL_NOTE);
            else
                Log.e(TAG, "invalid system folder");
        } else {
            Log.e(TAG, "error type");
        }
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
        e.printStackTrace();
    }
}

From source file:cn.code.notes.gtask.data.TaskList.java

public JSONObject getLocalJSONFromContent() {
    try {/*from w ww.j  a v  a2  s .c  o m*/
        JSONObject js = new JSONObject();
        JSONObject folder = new JSONObject();

        String folderName = getName();
        if (getName().startsWith(GTaskStringUtils.MIUI_FOLDER_PREFFIX))
            folderName = folderName.substring(GTaskStringUtils.MIUI_FOLDER_PREFFIX.length(),
                    folderName.length());
        folder.put(NoteColumns.SNIPPET, folderName);
        if (folderName.equals(GTaskStringUtils.FOLDER_DEFAULT)
                || folderName.equals(GTaskStringUtils.FOLDER_CALL_NOTE))
            folder.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
        else
            folder.put(NoteColumns.TYPE, Notes.TYPE_FOLDER);

        js.put(GTaskStringUtils.META_HEAD_NOTE, folder);

        return js;
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
        e.printStackTrace();
        return null;
    }
}

From source file:nl.hnogames.domoticz.Domoticz.UpdateParser.java

@Override
public void parseResult(String result) {
    try {/*from  w  ww.  j  a v  a 2  s . c  om*/
        JSONObject response = new JSONObject(result);
        String version = "";
        if (response.has("revision"))
            version = response.getString("revision");
        if (response.has("HaveUpdate") && !response.getBoolean("HaveUpdate"))
            version = "";

        receiver.onReceiveUpdate(version);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.grarak.kerneladiutor.database.Settings.java

public void putSetting(String category, String setting, String id) {
    try {//from   w w w  .j  a v  a 2 s . c  om
        JSONObject items = new JSONObject();
        items.put("category", category);
        items.put("setting", setting);
        items.put("id", id);
        putItem(items);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}