List of usage examples for org.json JSONException toString
public String toString()
From source file:com.asd.littleprincesbeauty.data.Task.java
@Override public void setContentByLocalJSON(JSONObject js) { if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE) || !js.has(GTaskStringUtils.META_HEAD_DATA)) { Log.w(TAG, "setContentByLocalJSON: nothing is avaiable"); }/*from w w w .ja va2 s . c o m*/ try { JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA); if (note.getInt(NoteColumns.TYPE) != Notes.TYPE_NOTE) { Log.e(TAG, "invalid type"); return; } for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); if (TextUtils.equals(data.getString(DataColumns.MIME_TYPE), DataConstants.NOTE)) { setName(data.getString(DataColumns.CONTENT)); break; } } } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); } }
From source file:com.asd.littleprincesbeauty.data.Task.java
@Override public JSONObject getLocalJSONFromContent() { String name = getName();/* w w w .j a v a 2 s .c om*/ try { if (mMetaInfo == null) { // new task created from web if (name == null) { Log.w(TAG, "the note seems to be an empty one"); return null; } JSONObject js = new JSONObject(); JSONObject note = new JSONObject(); JSONArray dataArray = new JSONArray(); JSONObject data = new JSONObject(); data.put(DataColumns.CONTENT, name); dataArray.put(data); js.put(GTaskStringUtils.META_HEAD_DATA, dataArray); note.put(NoteColumns.TYPE, Notes.TYPE_NOTE); js.put(GTaskStringUtils.META_HEAD_NOTE, note); return js; } else { // synced task JSONObject note = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); JSONArray dataArray = mMetaInfo.getJSONArray(GTaskStringUtils.META_HEAD_DATA); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); if (TextUtils.equals(data.getString(DataColumns.MIME_TYPE), DataConstants.NOTE)) { data.put(DataColumns.CONTENT, getName()); break; } } note.put(NoteColumns.TYPE, Notes.TYPE_NOTE); return mMetaInfo; } } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); return null; } }
From source file:com.asd.littleprincesbeauty.data.Task.java
public void setMetaInfo(MetaData metaData) { if (metaData != null && metaData.getNotes() != null) { try {//from www.ja v a 2 s .c om mMetaInfo = new JSONObject(metaData.getNotes()); } catch (JSONException e) { Log.w(TAG, e.toString()); mMetaInfo = null; } } }
From source file:org.openmrs.mobile.listeners.visit.FindVisitsByPatientUUIDListener.java
@Override public void onResponse(JSONObject response) { mLogger.d(response.toString());/*from ww w . j a v a 2 s.c o m*/ try { JSONArray visitResultJSON = response.getJSONArray(BaseManager.RESULTS_KEY); if (visitResultJSON.length() > 0) { for (int i = 0; i < visitResultJSON.length(); i++) { Visit visit = VisitMapper.map(visitResultJSON.getJSONObject(i)); long visitId = visitDAO.getVisitsIDByUUID(visit.getUuid()); if (visitId > 0) { visitDAO.updateVisit(visit, visitId, mPatientID); } else { visitDAO.saveVisit(visit, mPatientID); } } } } catch (JSONException e) { mErrorOccurred = true; mLogger.d(e.toString()); } finally { updateData(); } }
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void put(String key, UMO umo) { try {/* w ww . j ava 2 s .co m*/ mJSONObject.put(key, umo.getWrappedObject()); } catch (JSONException e) { Log.e(TAG, e.toString()); } }
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void putAttributeStr(String annotationName, String value) { try {/*from www. j a v a 2s.c o m*/ mJSONObject.put(annotationName, value); } catch (JSONException e) { Log.e(TAG, e.toString()); } }
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void putAttributeInt(String annotationName, Integer value) { try {/* w w w . jav a 2 s .co m*/ mJSONObject.put(annotationName, value.intValue()); } catch (JSONException e) { Log.e(TAG, e.toString()); } }
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void putAttributeLong(String annotationName, Long value) { try {/*w w w.ja v a 2s . c o m*/ mJSONObject.put(annotationName, value.longValue()); } catch (JSONException e) { Log.e(TAG, e.toString()); } }
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void putAttributeFloat(String annotationName, Float value) { try {// w ww. j a va2 s .c o m mJSONObject.put(annotationName, value.floatValue()); } catch (JSONException e) { Log.e(TAG, e.toString()); } }
From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java
@Override public void putAttributeDouble(String annotationName, Double value) { try {//from w w w.jav a2 s . com mJSONObject.put(annotationName, value.doubleValue()); } catch (JSONException e) { Log.e(TAG, e.toString()); } }