All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eg.agent.android.instrumentation.JSONObjectInstrumentation Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package com.eg.agent.android.instrumentation;

/**
 * Created by Venkateswari.J on 10/26/2017.
 */

import com.eg.agent.android.trace.TraceMachine;

import org.json.JSONException;
import org.json.JSONObject;

public class JSONObjectInstrumentation {
    //private static final ArrayList categoryParams = new ArrayList(Arrays.asList(new String[] { "category", MetricCategory.class.getName(), "JSON" }));
    private static final String categoryParams = "JSONObject";
    private static final String APItype = "JSON";

    @TraceConstructor
    public static JSONObject init(String json)
            throws JSONException {
        if (json == null) {
            throw new JSONException("Failed to initialize JSONObject: json string is null.");
        }

        JSONObject jsonObject;
        try {
            TraceMachine.enterMethod("JSONObject#", categoryParams, APItype);
            jsonObject = new JSONObject(json);

            TraceMachine.exitMethod();
        } catch (JSONException e) {
            TraceMachine.exitMethod();
            throw e;
        }
        return jsonObject;
    }

    @ReplaceCallSite(scope = "org.json.JSONObject")
    public static String toString(JSONObject jsonObject) {

        TraceMachine.enterMethod("JSONObject#toString", categoryParams, APItype);
        String jsonString = jsonObject.toString();
        TraceMachine.exitMethod();
        return jsonString;
    }

    @ReplaceCallSite(scope = "org.json.JSONObject")
    public static String toString(JSONObject jsonObject, int indentFactor)
            throws JSONException {
        TraceMachine.enterMethod("JSONObject#toString", categoryParams, APItype);
        String jsonString;
        try {
            jsonString = jsonObject.toString(indentFactor);
            TraceMachine.exitMethod();
        } catch (JSONException e) {
            TraceMachine.exitMethod();
            throw e;
        }
        return jsonString;
    }
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy