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:nl.hnogames.domoticzapi.Parsers.MobileDeviceParser.java

@Override
public void parseResult(String result) {
    try {//from  w  ww .  j  a  v a2 s.co m
        JSONObject jsonResult = new JSONObject(result);
        if (jsonResult.has("status")) {
            if (jsonResult.getString("status").equals("OK")) {
                mobileReceiver.onSuccess();
                return;
            }
        }
        mobileReceiver.onError(null);
    } catch (JSONException e) {
        Log.e(TAG, "MobileDeviceParser JSON exception");
        e.printStackTrace();
        mobileReceiver.onError(e);
    }
}

From source file:org.gdg.bari.entities.TableTurn.java

public byte[] persist(/*Card shootedCard, Set<Card> takenCardSet*/) {
    JSONObject retVal = new JSONObject();

    try {/*from w  ww.j  ava 2  s  . c o  m*/
        retVal.put("data", data);
        retVal.put("turnCounter", turnCounter);

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String st = retVal.toString();

    Log.d(TAG, "==== PERSISTING\n" + st);

    return st.getBytes(Charset.forName("UTF-16"));
}

From source file:org.gdg.bari.entities.TableTurn.java

static public TableTurn unpersist(byte[] byteArray) {

    if (byteArray == null) {
        Log.d(TAG, "Empty array---possible bug.");
        return new TableTurn();
    }/*ww  w  .j  a  va  2 s  .co  m*/

    String st = null;
    try {
        st = new String(byteArray, "UTF-16");
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
        return null;
    }

    Log.d(TAG, "====UNPERSIST \n" + st);

    TableTurn retVal = new TableTurn();

    try {
        JSONObject obj = new JSONObject(st);

        if (obj.has("data")) {
            retVal.data = obj.getString("data");
        }
        if (obj.has("turnCounter")) {
            retVal.turnCounter = obj.getInt("turnCounter");
        }

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return retVal;
}

From source file:com.knurld.dropboxdemo.KnurldActivity.java

public void recordEnrollment(View view) {
    Intent intent = new Intent(this, RecordWAVActivity.class);
    JSONArray vocabArray = knurldService.getAppModel().getVocabulary();
    String vocab = "";
    for (int i = 0; i < vocabArray.length(); i++) {
        try {//  w w  w.  j  a v  a  2s  .c om
            vocab += vocabArray.getString(i) + " ";
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    intent.putExtra(KNURLD_INSTRUCTIONS, vocab);

    startActivity(intent);
}

From source file:com.teleca.jamendo.activity.RadioActivity.java

private void loadRecommendedRadios() throws WSError {
    try {/*from   w w w . j  a va2s  .  co  m*/
        mRecommendedRadios = new JamendoGet2ApiImpl().getRadiosByIds(recommended_ids);
    } catch (JSONException e) {
        mRecommendedRadios = new Radio[0];
        e.printStackTrace();
    }
}

From source file:com.df.kia.carCheck.VehicleInfoLayout.java

/**
 * ??JSONObject//www  . j a  va 2 s .  c o  m
 * @return
 */
public JSONObject generateJSONObject() {
    JSONObject procedures = new JSONObject();

    try {
        procedures.put("vin", getEditViewText(rootView, R.id.vin_edit));
        procedures.put("engineSerial", getEditViewText(rootView, R.id.engineSerial_edit));
        procedures.put("plateNumber", getEditViewText(rootView, R.id.plateNumber_edit));
        procedures.put("licenseModel", getEditViewText(rootView, R.id.licenseModel_edit));
        procedures.put("vehicleType", getEditViewText(rootView, R.id.vehicleType_edit));
        procedures.put("mileage", getEditViewText(rootView, R.id.mileage_edit));
        procedures.put("exteriorColor", getEditViewText(rootView, R.id.exteriorColor_edit));
        procedures.put("regDate", getEditViewText(rootView, R.id.regDate_edit));
        procedures.put("builtDate", getEditViewText(rootView, R.id.builtDate_edit));
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return procedures;
}

From source file:com.df.kia.carCheck.VehicleInfoLayout.java

/**
 * ???/*from   w ww  .ja  v  a 2s . c  o m*/
 * ??
 * @param procedures
 * @param seriesId
 * @param modelId
 */
public void fillInData(JSONObject procedures, String seriesId, String modelId, OnUiUpdated listener) {
    try {
        mUiUpdatedCallback = listener;

        //            setEditViewText(rootView, R.id.vin_edit, procedures.getString("vin"));
        //            setEditViewText(rootView, R.id.engineSerial_edit, procedures.getString("engineSerial"));
        //            setEditViewText(rootView, R.id.plateNumber_edit, procedures.getString("plateNumber"));
        //            setEditViewText(rootView, R.id.licenseModel_edit, procedures.getString("licenseModel"));
        //            setEditViewText(rootView, R.id.vehicleType_edit, procedures.getString("vehicleType"));
        //            setEditViewText(rootView, R.id.mileage_edit, procedures.getString("mileage"));
        //            setEditViewText(rootView, R.id.exteriorColor_edit, procedures.getString("exteriorColor"));
        //            setEditViewText(rootView, R.id.regDate_edit, procedures.getString("regDate"));
        //            setEditViewText(rootView, R.id.builtDate_edit, procedures.getString("builtDate"));

        setEditViewText(rootView, R.id.vin_edit, procedures.getString("vin"));

        if (procedures.has("engineSerial"))
            setEditViewText(rootView, R.id.engineSerial_edit, procedures.getString("engineSerial"));
        else
            setEditViewText(rootView, R.id.engineSerial_edit, procedures.getString("engineno"));
        if (procedures.has("plateNumber"))
            setEditViewText(rootView, R.id.plateNumber_edit, procedures.getString("plateNumber"));
        else
            setEditViewText(rootView, R.id.plateNumber_edit, procedures.getString("license"));
        if (procedures.has("licenseModel"))
            setEditViewText(rootView, R.id.licenseModel_edit, procedures.getString("licenseModel"));
        else
            setEditViewText(rootView, R.id.licenseModel_edit, procedures.getString("model2"));
        if (procedures.has("vehicleType"))
            setEditViewText(rootView, R.id.vehicleType_edit, procedures.getString("vehicleType"));
        else
            setEditViewText(rootView, R.id.vehicleType_edit, procedures.getString("licensetype"));
        if (procedures.has("mileage"))
            setEditViewText(rootView, R.id.mileage_edit, procedures.getString("mileage"));
        else
            setEditViewText(rootView, R.id.mileage_edit, procedures.getString("mileage"));
        if (procedures.has("exteriorColor"))
            setEditViewText(rootView, R.id.exteriorColor_edit, procedures.getString("exteriorColor"));
        else
            setEditViewText(rootView, R.id.exteriorColor_edit, procedures.getString("color"));
        if (procedures.has("regDate"))
            setEditViewText(rootView, R.id.regDate_edit, procedures.getString("regDate"));
        else
            setEditViewText(rootView, R.id.regDate_edit, procedures.getString("regdate"));
        if (procedures.has("builtDate"))
            setEditViewText(rootView, R.id.builtDate_edit, procedures.getString("builtDate"));
        else
            setEditViewText(rootView, R.id.builtDate_edit, procedures.getString("leavefactorydate"));

        // ??
        Country country = null;
        Brand brand = null;
        Manufacturer manufacturer = null;
        Series series = null;
        Model model = null;

        boolean found = false;

        for (Country country1 : vehicleModel.getCountries()) {
            for (Brand brand1 : country1.brands) {
                for (Manufacturer manufacturer1 : brand1.manufacturers) {
                    for (Series series1 : manufacturer1.serieses) {
                        if (series1.id.equals(seriesId)) {
                            manufacturer = manufacturer1;
                            brand = brand1;
                            country = country1;
                            series = series1;
                            model = series.getModelById(modelId);

                            found = true;
                            break;
                        }
                    }
                    if (found)
                        break;
                }
                if (found)
                    break;
            }
            if (found)
                break;
        }

        mCarSettings.setCountry(country);
        mCarSettings.setBrand(brand);
        mCarSettings.setManufacturer(manufacturer);
        mCarSettings.setSeries(series);
        mCarSettings.setModel(model);

        getCarSettingsFromServer(seriesId + "," + modelId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.df.kia.carCheck.VehicleInfoLayout.java

/**
 * ???//from w  w  w  .j a va  2s.  c om
 * ??
 * @param procedures
 */
public void fillInData(JSONObject procedures) {
    try {
        setEditViewText(rootView, R.id.vin_edit, procedures.getString("vin"));
        setEditViewText(rootView, R.id.engineSerial_edit, procedures.getString("engineSerial"));
        setEditViewText(rootView, R.id.plateNumber_edit, procedures.getString("plateNumber"));
        setEditViewText(rootView, R.id.licenseModel_edit, procedures.getString("licenseModel"));
        setEditViewText(rootView, R.id.vehicleType_edit, procedures.getString("vehicleType"));
        setEditViewText(rootView, R.id.mileage_edit, procedures.getString("mileage"));
        setEditViewText(rootView, R.id.exteriorColor_edit, procedures.getString("exteriorColor"));
        setEditViewText(rootView, R.id.regDate_edit, procedures.getString("regDate"));
        setEditViewText(rootView, R.id.builtDate_edit, procedures.getString("builtDate"));
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:net.geco.model.iojson.PersistentStore.java

public void loadData(Stage stage, Factory factory) {
    Registry registry = new Registry();
    stage.setRegistry(registry);//from   w  w  w .j av  a2 s  . co m
    try {
        BufferedReader reader = GecoResources.getSafeReaderFor(getStorePath(stage.getBaseDir()));
        importDataIntoRegistry(new JSONStore(reader, K.MAXID), registry, factory);
        reader.close();
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.emergent.android.weave.client.WeaveUtil.java

public static void dump(JSONObject jsonObject) {
    try {// w  w w. java  2s.com
        String out = jsonObject.toString(2);
        System.out.println(out);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}