Package com.franz.agraph.http.handler
Class AGJSONHandler
java.lang.Object
com.franz.agraph.http.handler.AGResponseHandler
com.franz.agraph.http.handler.AGJSONHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONArrayFetch the JSONArray parsed from the response.org.json.JSONObjectvoidhandleResponse(org.apache.http.HttpResponse httpResponse, org.apache.http.client.methods.HttpUriRequest httpUriRequest) Parse http response as a JSON object.Methods inherited from class com.franz.agraph.http.handler.AGResponseHandler
getRequestMIMEType, releaseConnection
-
Constructor Details
-
AGJSONHandler
public AGJSONHandler()
-
-
Method Details
-
handleResponse
public void handleResponse(org.apache.http.HttpResponse httpResponse, org.apache.http.client.methods.HttpUriRequest httpUriRequest) throws IOException, AGHttpException Parse http response as a JSON object. We must invoke different parsers if the response contains an array or an object.- Specified by:
handleResponsein classAGResponseHandler- Throws:
IOExceptionAGHttpException
-
getResult
public org.json.JSONObject getResult() throws org.json.JSONException- Returns:
- the JSONObject parsed from the response
- Throws:
org.json.JSONException- if a JSONArray is instead available
-
getArrayResult
public org.json.JSONArray getArrayResult() throws org.json.JSONExceptionFetch the JSONArray parsed from the response. If the value parsed is a JSONObject, return a JSONArray with the JSONObject as its only element.- Returns:
- the JSONArray parsed from the response
- Throws:
org.json.JSONException- if the JSONArray is null
-