com.facebook
Class Response

java.lang.Object
  extended by com.facebook.Response

public class Response
extends Object

Encapsulates the response, successful or otherwise, of a call to the Facebook platform.


Nested Class Summary
static class Response.PagingDirection
          Indicates whether paging is being done forward or backward.
 
Field Summary
static String NON_JSON_RESPONSE_PROPERTY
          Property name of non-JSON results in the GraphObject.
 
Method Summary
 HttpURLConnection getConnection()
          Returns the HttpURLConnection that this response was generated from.
 FacebookRequestError getError()
          Returns information about any errors that may have occurred during the request.
 GraphObject getGraphObject()
          The single graph object returned for this request, if any.
<T extends GraphObject>
T
getGraphObjectAs(Class<T> graphObjectClass)
          The single graph object returned for this request, if any, cast into a particular type of GraphObject.
 GraphObjectList<GraphObject> getGraphObjectList()
          The list of graph objects returned for this request, if any.
<T extends GraphObject>
GraphObjectList<T>
getGraphObjectListAs(Class<T> graphObjectClass)
          The list of graph objects returned for this request, if any, cast into a particular type of GraphObject.
 boolean getIsFromCache()
          Indicates whether the response was retrieved from a local cache or from the server.
 Request getRequest()
          Returns the request that this response is for.
 Request getRequestForPagedResults(Response.PagingDirection direction)
          If a Response contains results that contain paging information, returns a new Request that will retrieve the next page of results, in whichever direction is desired.
 String toString()
          Provides a debugging string for this response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NON_JSON_RESPONSE_PROPERTY

public static final String NON_JSON_RESPONSE_PROPERTY
Property name of non-JSON results in the GraphObject. Certain calls to Facebook result in a non-JSON response (e.g., the string literal "true" or "false"). To present a consistent way of accessing results, these are represented as a GraphObject with a single string property with this name.

See Also:
Constant Field Values
Method Detail

getError

public final FacebookRequestError getError()
Returns information about any errors that may have occurred during the request.

Returns:
the error from the server, or null if there was no server error

getGraphObject

public final GraphObject getGraphObject()
The single graph object returned for this request, if any.

Returns:
the graph object returned, or null if none was returned (or if the result was a list)

getGraphObjectAs

public final <T extends GraphObject> T getGraphObjectAs(Class<T> graphObjectClass)
The single graph object returned for this request, if any, cast into a particular type of GraphObject.

Parameters:
graphObjectClass - the GraphObject-derived interface to cast the graph object into
Returns:
the graph object returned, or null if none was returned (or if the result was a list)
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

getGraphObjectList

public final GraphObjectList<GraphObject> getGraphObjectList()
The list of graph objects returned for this request, if any.

Returns:
the list of graph objects returned, or null if none was returned (or if the result was not a list)

getGraphObjectListAs

public final <T extends GraphObject> GraphObjectList<T> getGraphObjectListAs(Class<T> graphObjectClass)
The list of graph objects returned for this request, if any, cast into a particular type of GraphObject.

Parameters:
graphObjectClass - the GraphObject-derived interface to cast the graph objects into
Returns:
the list of graph objects returned, or null if none was returned (or if the result was not a list)
Throws:
FacebookException - If the passed in Class is not a valid GraphObject interface

getConnection

public final HttpURLConnection getConnection()
Returns the HttpURLConnection that this response was generated from. If the response was retrieved from the cache, this will be null.

Returns:
the connection, or null

getRequest

public Request getRequest()
Returns the request that this response is for.

Returns:
the request that this response is for

getRequestForPagedResults

public Request getRequestForPagedResults(Response.PagingDirection direction)
If a Response contains results that contain paging information, returns a new Request that will retrieve the next page of results, in whichever direction is desired. If no paging information is available, returns null.

Parameters:
direction - enum indicating whether to page forward or backward
Returns:
a Request that will retrieve the next page of results in the desired direction, or null if no paging information is available

toString

public String toString()
Provides a debugging string for this response.

Overrides:
toString in class Object

getIsFromCache

public final boolean getIsFromCache()
Indicates whether the response was retrieved from a local cache or from the server.

Returns:
true if the response was cached locally, false if it was retrieved from the server