org.alfresco.json
Class JSONObjectCallback

java.lang.Object
  extended by org.alfresco.http.AbstractHttpRequestCallback<org.json.simple.JSONObject>
      extended by org.alfresco.json.JSONObjectCallback
All Implemented Interfaces:
HttpRequestCallback<org.json.simple.JSONObject>

public class JSONObjectCallback
extends AbstractHttpRequestCallback<org.json.simple.JSONObject>

A HttpRequestCallback that parses the response body as a JSONObject. Optionally, the RestConstants#JSON_DATA object can be returned (first child of root JSON) if the property 'extractData' is set to true.
An exception is thrown when JSON could not be extracted.

Author:
Frederik Heremans

Constructor Summary
JSONObjectCallback(boolean extractData)
           
 
Method Summary
 org.json.simple.JSONObject onCallSuccess(org.apache.http.HttpResponse method)
          Called when call was successful.
 
Methods inherited from class org.alfresco.http.AbstractHttpRequestCallback
onCallException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONObjectCallback

public JSONObjectCallback(boolean extractData)
Parameters:
extractData - true, if the 'data' object (RestConstants#JSON_DATA) should be returned instead of the whole JSON-body.
Method Detail

onCallSuccess

public org.json.simple.JSONObject onCallSuccess(org.apache.http.HttpResponse method)
Description copied from interface: HttpRequestCallback
Called when call was successful.

Returns:
any result extracted from the response body.


Copyright © 2012. All Rights Reserved.