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.example.android.popularmoviesist2.data.FetchTrailerMovieTask.java

@Override
protected String[] doInBackground(String... params) {

    HttpURLConnection urlConnection = null;
    BufferedReader reader = null;
    movieId = params[0];/*from ww w  .ja v a  2 s  . co m*/

    String moviesJsonStr = null;

    final String MOVIE_VIDEO_URL = "http://api.themoviedb.org/3/movie/" + movieId + "/videos";

    final String APIKEY_PARAM = "api_key";

    try {
        Uri builtUri = Uri.parse(MOVIE_VIDEO_URL).buildUpon()
                .appendQueryParameter(APIKEY_PARAM, BuildConfig.OPEN_TMDB_MAP_API_KEY).build();

        URL url = new URL(builtUri.toString());

        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.connect();

        InputStream inputStream = urlConnection.getInputStream();
        StringBuffer buffer = new StringBuffer();
        if (inputStream == null) {
            return null;
        }

        reader = new BufferedReader(new InputStreamReader(inputStream));

        String line;
        while ((line = reader.readLine()) != null) {
            buffer.append(line + "\n");
        }

        if (buffer.length() == 0) {
            return null;
        }

        moviesJsonStr = buffer.toString();
        return getMoviesDataFromJson(moviesJsonStr);

    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    } catch (IOException e) {
        Log.e(LOG_TAG, "Error ", e);
        return null;
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException e) {
                Log.e(LOG_TAG, "Error closing stream", e);
            }
        }
    }

    return null;
}

From source file:com.cdd.bao.importer.KeywordMapping.java

public KeywordMapping(String mapFN) {
    file = new File(mapFN);

    // try to load the file, but it's OK if it fails
    JSONObject json = null;//from  w  ww.j a v a 2s.  c o  m
    try {
        Reader rdr = new FileReader(file);
        json = new JSONObject(new JSONTokener(rdr));
        rdr.close();
    } catch (JSONException ex) {
        Util.writeln("NOTE: reading file " + file.getAbsolutePath() + " failed: " + ex.getMessage());
    } catch (IOException ex) {
        return;
    } // includes file not found, which is OK

    try {
        for (JSONObject obj : json.optJSONArrayEmpty("identifiers").toObjectArray()) {
            Identifier id = new Identifier();
            id.regex = regexOrName(obj.optString("regex"), obj.optString("name"));
            id.prefix = obj.optString("prefix");
            identifiers.add(id);
        }
        for (JSONObject obj : json.optJSONArrayEmpty("textBlocks").toObjectArray()) {
            TextBlock txt = new TextBlock();
            txt.regex = regexOrName(obj.optString("regex"), obj.optString("name"));
            txt.title = obj.optString("title");
            textBlocks.add(txt);
        }
        for (JSONObject obj : json.optJSONArrayEmpty("properties").toObjectArray()) {
            Property prop = new Property();
            prop.regex = regexOrName(obj.optString("regex"), obj.optString("name"));
            prop.propURI = obj.optString("propURI");
            prop.groupNest = obj.optJSONArrayEmpty("groupNest").toStringArray();
            properties.add(prop);
        }
        for (JSONObject obj : json.optJSONArrayEmpty("values").toObjectArray()) {
            Value val = new Value();
            val.regex = regexOrName(obj.optString("regex"), obj.optString("name"));
            val.valueRegex = regexOrName(obj.optString("valueRegex"), obj.optString("valueName"));
            val.valueURI = obj.optString("valueURI");
            val.propURI = obj.optString("propURI");
            val.groupNest = obj.optJSONArrayEmpty("groupNest").toStringArray();
            values.add(val);
        }
        for (JSONObject obj : json.optJSONArrayEmpty("literals").toObjectArray()) {
            Literal lit = new Literal();
            lit.regex = regexOrName(obj.optString("regex"), obj.optString("name"));
            lit.valueRegex = regexOrName(obj.optString("valueRegex"), obj.optString("valueName"));
            lit.propURI = obj.optString("propURI");
            lit.groupNest = obj.optJSONArrayEmpty("groupNest").toStringArray();
            literals.add(lit);
        }
        for (JSONObject obj : json.optJSONArrayEmpty("references").toObjectArray()) {
            Reference ref = new Reference();
            ref.regex = regexOrName(obj.optString("regex"), obj.optString("name"));
            ref.valueRegex = regexOrName(obj.optString("valueRegex"), obj.optString("valueName"));
            ref.prefix = obj.optString("prefix");
            ref.propURI = obj.optString("propURI");
            ref.groupNest = obj.optJSONArrayEmpty("groupNest").toStringArray();
            references.add(ref);
        }
        for (JSONObject obj : json.optJSONArrayEmpty("assertions").toObjectArray()) {
            Assertion asrt = new Assertion();
            asrt.propURI = obj.optString("propURI");
            asrt.groupNest = obj.optJSONArrayEmpty("groupNest").toStringArray();
            asrt.valueURI = obj.optString("valueURI");
            assertions.add(asrt);
        }
    } catch (JSONException ex) {
        Util.writeln("NOTE: parsing error");
        ex.printStackTrace();
        Util.writeln(
                "*** Execution will continue, but part of the mapping has not been loaded and may be overwritten.");
    }
}

From source file:com.beevou.android.authentication.NetworkUtilities.java

/**
 * Connects to the Voiper server, authenticates the provided username and
 * password.//from   www .ja v a  2s.  co m
 * 
 * @param username The user's username
 * @param password The user's password
 * @param handler The hander instance from the calling UI thread.
 * @param context The context of the calling Activity.
 * @return boolean The boolean result indicating whether the user was
 *         successfully authenticated.
 */
/* 
 public static boolean authenticate(String username, String password,
Handler handler, final Context context) {
final HttpResponse resp;
        
final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair(PARAM_USERNAME, username));
params.add(new BasicNameValuePair(PARAM_PASSWORD, password));
HttpEntity entity = null;
try {
    entity = new UrlEncodedFormEntity(params);
} catch (final UnsupportedEncodingException e) {
    // this should never happen.
    throw new AssertionError(e);
}
final HttpPost post = new HttpPost(AUTH_URI);
Log.e("url", AUTH_URI);
post.addHeader(entity.getContentType());
post.setEntity(entity);
maybeCreateHttpClient();
        
try {
    resp = mHttpClient.execute(post);
    if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
               
       HttpEntity httpEntity = resp.getEntity();
       InputStream is = httpEntity.getContent();
               
       try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "n");
            }
            is.close();
            String json = sb.toString();
            Log.e("JSON", json);
        } catch (Exception e) {
            Log.e("Buffer Error", "Error converting result " + e.toString());
        }
               
       if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "Successful authentication");
        }
        sendResult(true, handler, context);
        return true;
    } else {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "Error authenticating" + resp.getStatusLine());
        }
        sendResult(false, handler, context);
        return false;
    }
} catch (final IOException e) {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "IOException when getting authtoken", e);
    }
    sendResult(false, handler, context);
    return false;
} finally {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "getAuthtoken completing");
    }
}
 }*/

public static boolean authenticate(String username, String password, Handler handler, final Context context) {

    JSONObject token = jsonParser.getJSONFromUrl(
            "https://beevou.net/oauth/token?grant_type=password&username=" + username + "&password=" + password
                    + "&client_id=NTEyMWZmNTdkZDVlMDVm&client_secret=438a58c31557b2db11523a2dc350e74fae06e0d2");

    if (token != null) {
        try {
            String accessToken = token.getString("access_token");
            String refreshToken = token.getString("refresh_token");
            //tokenExpiresIn.add(Calendar.SECOND, expirationSecs);
            sendResult(true, handler, context);
            return true;
        } catch (JSONException e) {
            e.printStackTrace();
            sendResult(false, handler, context);
            return false;
        }
    } else {
        sendResult(false, handler, context);
        return false;
    }

}

From source file:com.amossys.hooker.common.InterceptEvent.java

/**
 * @return//from   w w  w  . ja va2  s .c  o  m
 */
public String toJson() {
    JSONObject object = new JSONObject();

    try {
        //      object.put("IdEvent", this.getIdEvent().toString());

        object.put("Timestamp", this.getTimestamp());
        object.put("RelativeTimestamp", this.getRelativeTimestamp());
        object.put("HookerName", this.getHookerName());
        object.put("IntrusiveLevel", this.getIntrusiveLevel());
        object.put("InstanceID", this.getInstanceID());
        object.put("PackageName", this.getPackageName());

        object.put("ClassName", this.getClassName());
        object.put("MethodName", this.getMethodName());

        JSONArray parameters = new JSONArray();
        if (this.getParameters() != null) {
            for (Entry<String, String> parameter : this.getParameters()) {
                JSONObject jsonParameter = new JSONObject();
                jsonParameter.put("ParameterType", parameter.getKey());
                jsonParameter.put("ParameterValue", parameter.getValue());
                parameters.put(jsonParameter);
            }
        }
        object.put("Parameters", parameters);

        JSONObject returns = new JSONObject();
        if (this.getReturns() != null) {
            returns.put("ReturnType", this.getReturns().getKey());
            returns.put("ReturnValue", this.getReturns().getValue());
        }
        object.put("Return", returns);

        JSONArray data = new JSONArray();
        if (this.getData() != null) {
            for (String dataName : this.getData().keySet()) {
                if (dataName != null && this.getData().get(dataName) != null) {
                    JSONObject dataP = new JSONObject();
                    dataP.put("DataName", dataName);
                    dataP.put("DataValue", this.getData().get(dataName));
                }
            }
        }
        object.put("Data", data);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return object.toString();
}

From source file:com.snappy.couchdb.ConnectionHandler.java

public static String getError(JSONObject jsonObject) {

    String error = Integer.toString(R.string.unknow_error);

    if (jsonObject.has("message")) {
        try {/*from  ww  w.j a  v  a2s .  c om*/
            error = jsonObject.getString("message");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else {
        error += jsonObject.toString();
    }
    return error;
}

From source file:de.dmxcontrol.model.StrobeModel.java

@Override
public void onValueChanged(View v, float x, float y) {
    strobe[0] = x * MAX_VALUE;/*from w  w w.  ja  va2s  .co  m*/
    try {
        SendData("Strobe", "double", x);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    notifyListener();
}

From source file:nl.hnogames.domoticzapi.Parsers.TemperaturesParser.java

@Override
public void parseResult(String result) {

    try {/*from w  w w.j  a va  2 s. c o m*/
        JSONArray jsonArray = new JSONArray(result);
        ArrayList<TemperatureInfo> mTemperatures = new ArrayList<>();

        if (jsonArray.length() > 0) {

            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject row = jsonArray.getJSONObject(i);
                mTemperatures.add(new TemperatureInfo(row));
            }
        }

        temperatureReceiver.onReceiveTemperatures(mTemperatures);

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

From source file:edu.cwru.apo.Home.java

public void onRestRequestComplete(Methods method, JSONObject result) {
    if (method == Methods.phone) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("success") == 0) {
                    SharedPreferences.Editor editor = getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE)
                            .edit();// w w w.j av a  2  s  .  c  o m
                    editor.putLong("updateTime", result.getLong("updateTime"));
                    editor.commit();
                    int numbros = result.getInt("numBros");
                    JSONArray caseID = result.getJSONArray("caseID");
                    JSONArray first = result.getJSONArray("first");
                    JSONArray last = result.getJSONArray("last");
                    JSONArray phone = result.getJSONArray("phone");
                    JSONArray family = result.getJSONArray("family");
                    ContentValues values;
                    for (int i = 0; i < numbros; i++) {
                        values = new ContentValues();
                        values.put("_id", caseID.getString(i));
                        values.put("first", first.getString(i));
                        values.put("last", last.getString(i));
                        values.put("phone", phone.getString(i));
                        values.put("family", family.getString(i));
                        database.replace("phoneDB", null, values);
                    }
                } else if (requestStatus.compareTo("timestamp invalid") == 0) {
                    Toast msg = Toast.makeText(this, "Invalid timestamp.  Please try again.",
                            Toast.LENGTH_LONG);
                    msg.show();
                } else if (requestStatus.compareTo("HMAC invalid") == 0) {
                    Auth.loggedIn = false;
                    Toast msg = Toast.makeText(this,
                            "You have been logged out by the server.  Please log in again.", Toast.LENGTH_LONG);
                    msg.show();
                    finish();
                } else {
                    Toast msg = Toast.makeText(this, "Invalid requestStatus", Toast.LENGTH_LONG);
                    msg.show();
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else if (method == Methods.checkAppVersion) {
        if (result != null) {
            try {
                String requestStatus = result.getString("requestStatus");
                if (requestStatus.compareTo("success") == 0) {
                    String appVersion = result.getString("version");
                    String appDate = result.getString("date");
                    final String appUrl = result.getString("url");
                    PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
                    ;
                    if (appVersion.compareTo(pinfo.versionName) != 0) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.setTitle("Upgrade");
                        builder.setMessage("Update available, ready to upgrade?");
                        builder.setIcon(R.drawable.icon);
                        builder.setCancelable(false);
                        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                Intent promptInstall = new Intent("android.intent.action.VIEW",
                                        Uri.parse("https://apo.case.edu:8090/app/" + appUrl));
                                startActivity(promptInstall);
                            }
                        });
                        builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        });
                        AlertDialog alert = builder.create();
                        alert.show();
                    } else {
                        Toast msg = Toast.makeText(this, "No updates found", Toast.LENGTH_LONG);
                        msg.show();
                    }
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NameNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}

From source file:com.cssweb.android.view.KlineViewSingle.java

public void onDraw(Canvas canvas) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);/* w w w . j  a  v  a 2s  .  co  m*/

    tPaint = new Paint();
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setTypeface(Typeface.DEFAULT_BOLD);
    tPaint.setAntiAlias(true);
    tPaint.setTextSize(dTextSize);
    //
    tips = (int) tPaint.measureText("0");
    try {
        if (actualDataLen == 0) {
            return;
        }
        if (zs)
            axisLabelWidth = (int) Math.max(tPaint.measureText("99999.99"), tPaint.measureText("11000"));
        else
            axisLabelWidth = (int) tPaint.measureText("11000");
        klineWidth = width - axisLabelWidth;
        //?spaceWidth???
        visualKLineCount = (int) ((klineWidth - spaceWidth) / (spaceWidth + shapeWidth));

        if (isSingleMoved == false && isTrackStatus == false) {
            if (actualDataLen > visualKLineCount) {
                actualPos = actualDataLen - visualKLineCount;
                count = visualKLineCount;
            } else {
                actualPos = 0;
                count = actualDataLen;
            }
        }

        calcMaxMin(actualPos);

        //
        axisLabelHeight = Font.getFontHeight(dTextSize);
        klineX = axisLabelWidth;
        klineY = axisLabelHeight;

        klineHeight = (int) ((height - axisLabelHeight) * 0.6);
        volumeHeight = (int) ((height - axisLabelHeight) * 0.4);
        axisX = klineX;

        if (!isTrackStatus) {
            moveQuote(actualDataLen - 1);
        } else {
            if (trackLineV == 0) {
                trackLineV = (int) (visualPos * (spaceWidth + shapeWidth) - shapeWidth / 2);
                isTrackNumber = actualPos + visualPos - 1;
            }
            if (isTrackNumber < 0) {
                isTrackNumber = 0;
            } else if (isTrackNumber > actualDataLen - 1) {
                isTrackNumber = actualDataLen - 1;
            }
            paint.setColor(GlobalColor.clrGrayLine);
            canvas.drawLine(klineX + trackLineV, axisLabelHeight, klineX + trackLineV, height - axisLabelHeight,
                    paint);
            moveQuote(isTrackNumber);
            drawQuoteWin(canvas, quoteData, isTrackNumber);
        }

        //
        tPaint.setTextAlign(Paint.Align.LEFT);
        tPaint.setColor(GlobalColor.colorM5);
        canvas.drawText(lblIndicatorName, (float) (klineX + tips), axisLabelHeight - 5, tPaint);

        float size = tPaint.measureText(lblIndicatorName) + tips * 2;
        tPaint.setColor(GlobalColor.colorM10);
        canvas.drawText(lblIndicatorT1, (float) (klineX + size), axisLabelHeight - 5, tPaint);

        size += tPaint.measureText(lblIndicatorT1) + tips;
        if (size <= (klineWidth - tPaint.measureText(lblIndicatorT2))) {
            //tPaint.setColor(GlobalColor.colorM20);
            tPaint.setARGB(255, 255, 0, 255);
            canvas.drawText(lblIndicatorT2, (float) (klineX + size), axisLabelHeight - 5, tPaint);
        }

        size += tPaint.measureText(lblIndicatorT2) + tips;
        if (size <= (klineWidth - tPaint.measureText(lblIndicatorT3))) {
            tPaint.setColor(GlobalColor.colorM60);
            canvas.drawText(lblIndicatorT3, (float) (klineX + size), axisLabelHeight - 5, tPaint);
        }

        //?
        tPaint.setColor(GlobalColor.colorLabelName);
        canvas.drawText(lblmainIndicatorT1, (float) (klineX + tips), klineY + klineHeight + axisLabelHeight - 5,
                tPaint);

        size = tPaint.measureText(lblmainIndicatorT1) + tips * 2;

        tPaint.setColor(GlobalColor.colorM5);
        canvas.drawText(lblmainIndicatorT2, (float) (klineX + size), klineY + klineHeight + axisLabelHeight - 5,
                tPaint);

        size += tPaint.measureText(lblmainIndicatorT2) + tips;
        if (size <= (klineWidth - tPaint.measureText(lblmainIndicatorT3))) {
            tPaint.setColor(GlobalColor.colorM10);
            canvas.drawText(lblmainIndicatorT3, (float) (klineX + size),
                    klineY + klineHeight + axisLabelHeight - 5, tPaint);
        }

        size += tPaint.measureText(lblmainIndicatorT3) + tips;
        if (size <= (klineWidth - tPaint.measureText(lblmainIndicatorT4))) {
            tPaint.setARGB(255, 255, 0, 255);
            canvas.drawText(lblmainIndicatorT4, (float) (klineX + size),
                    klineY + klineHeight + axisLabelHeight - 5, tPaint);
        }

        //???
        rowHeight = klineHeight / rowNum;
        scale = klineHeight / (highPrice - lowPrice);

        double ratio = (highPrice - lowPrice) / rowNum;

        paint.setColor(GlobalColor.clrLine);
        tPaint.setColor(GlobalColor.colorTicklabel);
        tPaint.setTextAlign(Paint.Align.RIGHT);
        for (int i = 0; i <= rowNum; i++) {
            if (i == rowNum || i == 0) {
                canvas.drawLine(klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint);
            } else {
                Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, width, klineY + rowHeight * i,
                        paint);
            }
            if (i != rowNum && isTrackStatus == false) {
                double AxisLabelPrice = highPrice - ratio * i;
                String AxisLabelPriceText;
                AxisLabelPriceText = Utils.dataFormation(AxisLabelPrice, stockdigit);
                canvas.drawText(AxisLabelPriceText, klineX - tips / 4,
                        klineY + rowHeight * i + axisLabelHeight / 2, tPaint);
            }
        }

        //
        if (quoteData != null) {
            //axisX = 0;
            for (int i = actualPos; i < (actualPos + count); i++) {
                if (i == 0)
                    drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(2),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(3),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(4),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(4));
                else
                    drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(2),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(3),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(4),
                            quoteData.getJSONArray("K").getJSONArray(i - 1).getDouble(4));
            }
            if (mainIndicatorType.toUpperCase().equals("MA"))
                drawMA(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (mainIndicatorType.toUpperCase().equals("BOLL"))
                drawBoll(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);

            rowHeight = (volumeHeight - axisLabelHeight * 2) / rowNum;
            klineY = klineHeight + axisLabelHeight * 2;
            volumeHeight = rowNum * rowHeight;

            if (indicatorType.toUpperCase().equals("VOLUME"))
                drawVOLUME(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("MACD"))
                drawMACD(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("CCI"))
                drawCCI(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("BIAS"))
                drawBIAS(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("KDJ"))
                drawKDJ(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("RSI"))
                drawRSI(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("OBV"))
                drawOBV(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);
            else if (indicatorType.toUpperCase().equals("PSY"))
                drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen, "PSY");
            else if (indicatorType.toUpperCase().equals("ROC"))
                drawROC(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen, "ROC");
            else if (indicatorType.toUpperCase().equals("VR"))
                drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen, "VR");
            else if (indicatorType.toUpperCase().equals("WR"))
                drawOther(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen, "WR");

            drawTimeAix(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                    highVolume, actualDataLen);
        }

        //?????
        paint.setColor(GlobalColor.clrLine);
        canvas.drawLine(klineX, 0, width, 0, paint);
        canvas.drawLine(klineX, 0, klineX, height - axisLabelHeight, paint);
        canvas.drawLine(width, 0, width, height - axisLabelHeight, paint);
        //canvas.drawLine(klineX, height - axisLabelHeight, width, height - axisLabelHeight, paint);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.grarak.kerneladiutor.utils.database.ProfileDB.java

public void putProfile(String name, LinkedHashMap<String, String> commands) {
    try {//  w w  w  .  j  av  a2  s. c o  m

        JSONObject items = new JSONObject();
        items.put("name", name);

        JSONArray commandArray = new JSONArray();
        for (int i = 0; i < commands.size(); i++) {
            JSONObject item = new JSONObject();
            item.put("path", commands.keySet().toArray()[i]);
            item.put("command", commands.values().toArray()[i]);
            commandArray.put(item);
        }

        items.put("commands", commandArray);

        items.put("id", UUID.randomUUID());

        putItem(items);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}