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:com.asd.littleprincesbeauty.data.TaskList.java

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

    try {/*from  ww w . j  a  v  a2  s  . c om*/
        // 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:com.asd.littleprincesbeauty.data.TaskList.java

@Override
public void setContentByRemoteJSON(JSONObject js) {
    if (js != null) {
        try {//ww  w  . j a  v  a2s .  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:com.asd.littleprincesbeauty.data.TaskList.java

@Override
public void setContentByLocalJSON(JSONObject js) {
    if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
        Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
    }/*  www .  ja  va 2 s  .  c o m*/

    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:com.asd.littleprincesbeauty.data.TaskList.java

@Override
public JSONObject getLocalJSONFromContent() {
    try {/*from ww w .  jav  a  2 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.EventsParser.java

@Override
public void parseResult(String result) {
    try {//from  w w  w  .  j av a  2 s  . c  om
        JSONArray jsonArray = new JSONArray(result);
        ArrayList<EventInfo> mVars = new ArrayList<>();

        if (jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject row = jsonArray.getJSONObject(i);
                mVars.add(new EventInfo(row));
            }
        }

        if (mVars == null || mVars.size() <= 0)
            onError(new NullPointerException("No Events devined in Domoticz."));
        else
            varsReceiver.onReceiveEvents(mVars);

    } catch (JSONException e) {
        Log.e(TAG, "EventsParser JSON exception");
        e.printStackTrace();
        varsReceiver.onError(e);
    }
}

From source file:com.example.pyrkesa.com.example.pyrkesa.home.Room.java

public JSONObject getJSONObject(JSONArray devicesArray) {
    try {/* w  w w.j  a v a2s .c o m*/
        roomJSON.put("id", this.ID);
        roomJSON.put("name", this.name);
        roomJSON.put("area", this.area);
        roomJSON.put("numb_users", this.numb_users);
        roomJSON.put("devices", devicesArray);
        return roomJSON;
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return roomJSON;
}

From source file:com.autburst.picture.facebook.AsyncRequestListener.java

public void onComplete(String response) {
    try {//from  w ww . j ava2  s.  c  o m
        JSONObject obj = Util.parseJson(response);
        onComplete(obj);
    } catch (JSONException e) {
        e.printStackTrace();
        Log.e("facebook-stream", "JSON Error:" + e.getMessage());
    } catch (FacebookError e) {
        Log.e("facebook-stream", "Facebook Error:" + e.getMessage());
    }

}

From source file:com.owncloud.android.extensions.ExtensionsListActivity.java

public void done(JSONArray a) {
    LinkedList<HashMap<String, String>> ll = new LinkedList<HashMap<String, String>>();
    for (int i = 0; i < a.length(); ++i) {
        try {//from  w w w.j  av  a2  s . co  m
            ExtensionApplicationEntry ela = new ExtensionApplicationEntry(((JSONObject) a.get(i)));
            HashMap<String, String> ss = new HashMap<String, String>();
            ss.put("NAME", ela.getName());
            ss.put("DESC", ela.getDescription());
            ll.add(ss);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    setListAdapter(new SimpleAdapter(this, ll, R.layout.simple_list_item_2, new String[] { "NAME", "DESC" },
            new int[] { android.R.id.text1, android.R.id.text2 }));

}

From source file:fr.cobaltians.cobalt.fragments.CobaltFragment.java

/**
 * Calls the Web callback with an object containing response fields
 * @param callbackId: the Web callback.//  w  w w  . ja v a 2s  . c  om
 * @param data: the object containing response fields
 */
public void sendCallback(final String callbackId, final JSONObject data) {
    if (callbackId != null && callbackId.length() > 0) {
        try {
            JSONObject jsonObj = new JSONObject();
            jsonObj.put(Cobalt.kJSType, Cobalt.JSTypeCallBack);
            jsonObj.put(Cobalt.kJSCallback, callbackId);
            jsonObj.put(Cobalt.kJSData, data);
            executeScriptInWebView(jsonObj);
        } catch (JSONException exception) {
            if (Cobalt.DEBUG)
                Log.e(Cobalt.TAG, TAG + " - sendCallback: JSONException");
            exception.printStackTrace();
        }
    } else if (Cobalt.DEBUG)
        Log.e(Cobalt.TAG, TAG + " - sendCallback: callbackId is null or empty!");
}

From source file:fr.cobaltians.cobalt.fragments.CobaltFragment.java

/**
 * Calls the Web callback with an object containing response fields
 * @param event: the name of the event.//from   ww  w . j av  a  2 s.co  m
 * @param data: the object containing response fields
 * @param callbackID: the Web callback.
 */
public void sendEvent(final String event, final JSONObject data, final String callbackID) {
    if (event != null && event.length() > 0) {
        try {
            JSONObject jsonObj = new JSONObject();
            jsonObj.put(Cobalt.kJSType, Cobalt.JSTypeEvent);
            jsonObj.put(Cobalt.kJSEvent, event);
            jsonObj.put(Cobalt.kJSData, data);
            jsonObj.put(Cobalt.kJSCallback, callbackID);
            executeScriptInWebView(jsonObj);
        } catch (JSONException exception) {
            if (Cobalt.DEBUG)
                Log.e(Cobalt.TAG, TAG + " - sendEvent: JSONException");
            exception.printStackTrace();
        }
    } else if (Cobalt.DEBUG)
        Log.e(Cobalt.TAG, TAG + " - sendEvent: event is null or empty!");
}