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

com.eg.agent.android.instrumentation.JSONArrayInstrumentation 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.JSONArray;
import org.json.JSONException;

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

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

    @TraceConstructor
    public static JSONArray init(String json)
            throws JSONException {
        if (json == null) {
            throw new JSONException("Failed to initialize JSONArray: json string is null.");
        }
        JSONArray jsonArray;
        try {
            TraceMachine.enterMethod("JSONArray#", categoryParams, APItype);
            jsonArray = new JSONArray(json);
            exitMethod();
        } catch (JSONException e) {
            exitMethod();
            throw e;
        }

        return jsonArray;
    }

    @ReplaceCallSite(scope = "org.json.JSONArray")
    public static String toString(JSONArray jsonArray) {
        TraceMachine.enterMethod("JSONArray#toString", categoryParams, APItype);
        String jsonString = jsonArray.toString();
        exitMethod();
        return jsonString;
    }

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy