public class Request extends Object
Client's send method.| Modifier and Type | Field and Description |
|---|---|
static String |
ALBUM_ID |
static String |
APP_ID |
static String |
FRIEND_ID |
static String |
GROUP_ID |
static String |
GUID |
static String |
HISTORY |
static String |
ITEM_ID |
static String |
MOOD_ID |
static String |
P_ID |
static String |
SELECTOR |
| Constructor and Description |
|---|
Request(String restUrlTemplate,
String rpcMethod,
String restMethod)
Creates and returns a new
Request configured with the passed
RESTful URL template, RPC method name, and HTTP method. |
| Modifier and Type | Method and Description |
|---|---|
void |
addComponent(String name,
String value)
Sets the request component with the specified name to the specified value.
|
void |
addParameter(String name,
String value)
Adds an extended request parameter, e.g. count or startIndex, to be passed
as query parameters in the URL if executed using REST or in the request
body if executed via a RPC.
|
void |
addParameters(Map<String,String> parameters)
Adds extended request parameters for each name-value pair in the passed
Map. |
void |
addRestPayloadParameter(String name,
Object value)
Adds a new parameter with the specified name and value to the set of
parameters used by the
Client to generate the JSON payload for a
REST request; this method should not be called by clients directly unless
custom requests are being executed. |
<T extends Model> |
addRestPayloadParameters(T modelObject)
For each property in the passed model object, adds a new parameter to the
set of parameters used by the
Client to generate the JSON payload
for a REST request ; this method should not be called by clients directly
unless custom requests are being executed. |
void |
addRestQueryStringParameter(String name,
String value)
Adds a new parameter with the specified name and value to the set of
parameters used by the
Client to generate the query string that
gets appended to the RESTful URL; this method should not be called by
clients directly unless custom requests are being executed. |
void |
addRpcPayloadParameter(String name,
Object value)
Adds a new parameter with the specified name and value to the set of
parameters used by the
Client to generate the JSON payload for a
RPC request; this method should not be called by clients directly unless
custom requests are being executed. |
void |
addRpcQueryStringParameter(String name,
String value)
Adds a new parameter with the specified name and value to the set of
parameters used by the
Client to generate the query string that
gets appended to the RPC endpoint; this method should not be called by
clients directly unless custom requests are being executed. |
String |
getComponent(String name)
Returns the request component with the specified name, e.g. guid or
groupId, or null if no request component with the specified name exists.
|
String |
getContentType()
|
byte[] |
getCustomPayload()
Returns the request's custom payload if provided; if not null, this value
overrides the JSON payload generated by the
Client. |
Class<? extends Model> |
getModelClass()
Returns the model class that developers use to access response data after
a request has been successfully executed.
|
String |
getRestMethod()
Returns the associated HTTP method for REST requests, e.g.
|
Map<String,Object> |
getRestPayloadParameters()
Returns the set of name-value pairs used by the
Client to generate
the JSON payload for a RESTful request; guaranteed not to be null. |
Map<String,String> |
getRestQueryStringParameters()
Returns the set of name-value pairs used by the
Client to generate
the query string that gets appended to the RESTful URL; guaranteed not to
be null. |
String |
getRestUrlTemplate()
Returns the RESTful URL template for the requested resource type, e.g.
|
String |
getRpcMethod()
Returns the associated RPC method name, e.g. people.get.
|
Map<String,Object> |
getRpcPayloadParameters()
Returns the set of name-value pairs used by the
Client to generate
the JSON payload for a RPC request; guaranteed not to be null. |
Map<String,String> |
getRpcQueryStringParameters()
Returns the set of name-value pairs used by the
Client to generate
the query string that gets appended to the RPC endpoint; guaranteed not
to be null. |
void |
setAppId(String appId)
Sets the request's appid component which is passed as a parameter when the
request is executed.
|
void |
setContentType(String contentType)
Sets a custom content (MIME) type which is later used as the value of the
Content-Type request header when the request is executed; leave null
except when passing a custom payload such as binary image data.
|
void |
setCountParameter(int count)
Sets the "count" extended request parameter to the specified value; used
to specify the page size for a paged collection.
|
void |
setCustomPayload(byte[] payload)
Sets the payload to pass in the corresponding HTTP request's body as POST
data when the request is executed, overriding the JSON payload generated
by the
Client; leave null except when uploading special content,
e.g. binary image data, and make sure to call setContentType as well. |
void |
setFieldsParameter(String[] fields)
Sets the "fields" extended request parameter to the specified value; used
to specify which field names to include in the representation or in the
members of a collection.
|
void |
setGroupId(String groupId)
Sets the request's groupId component which is passed as a parameter when
the request is executed.
|
void |
setGuid(String guid)
Sets the request's guid component which is passed as a parameter when the
request is executed.
|
void |
setModelClass(Class<? extends Model> modelClass)
Sets the model class that developers will use to access response data
after a request has been successfully executed; this method should not be
called by clients directly unless custom requests are being executed.
|
void |
setPId(String pid)
Sets the request's pId (person ID) component which is passed as a
parameter when the request is executed.
|
void |
setRestUrlTemplate(String template)
Sets the REST URL template for this request.
|
void |
setSelector(String selector)
Sets the request's selector component which is passed as a parameter when
the request is executed.
|
void |
setStartIndexParameter(int startIndex)
Sets the "startIndex" extended request parameter to the specified value;
used to specify the index into a paged collection.
|
public static final String GUID
public static final String GROUP_ID
public static final String SELECTOR
public static final String APP_ID
public static final String P_ID
public static final String ALBUM_ID
public static final String ITEM_ID
public static final String MOOD_ID
public static final String FRIEND_ID
public static final String HISTORY
public Request(String restUrlTemplate, String rpcMethod, String restMethod)
Request configured with the passed
RESTful URL template, RPC method name, and HTTP method.restUrlTemplate - RESTful URL template to use when executing request
using RESTrpcMethod - RPC method name to use when executing request via
a RPCrestMethod - HTTP method to use when executing request using
RESTpublic String getRpcMethod()
public String getRestMethod()
public String getRestUrlTemplate()
public String getContentType()
public byte[] getCustomPayload()
Client.public String getComponent(String name)
name - Name of the request component to return.public Map<String,Object> getRpcPayloadParameters()
Client to generate
the JSON payload for a RPC request; guaranteed not to be null.public Map<String,Object> getRestPayloadParameters()
Client to generate
the JSON payload for a RESTful request; guaranteed not to be null.public Map<String,String> getRpcQueryStringParameters()
Client to generate
the query string that gets appended to the RPC endpoint; guaranteed not
to be null.public Map<String,String> getRestQueryStringParameters()
Client to generate
the query string that gets appended to the RESTful URL; guaranteed not to
be null.public Class<? extends Model> getModelClass()
public void setRestUrlTemplate(String template)
template - REST URL template for this requestpublic void setGuid(String guid)
guid - GUID (OpenSocial user ID) to set or "@me" for the current
viewerpublic void setAppId(String appId)
appId - application ID to set or "@app" for the current applicationpublic void setGroupId(String groupId)
groupId - OpenSocial group ID to set, usually "@self" or "@friends"public void setSelector(String selector)
selector - OpenSocial selector to set, usually "@self" or "@friends"public void setPId(String pid)
pid - OpenSocial pId to setpublic void setContentType(String contentType)
contentType - custom Content-Type request header value to setpublic void setCustomPayload(byte[] payload)
Client; leave null except when uploading special content,
e.g. binary image data, and make sure to call setContentType as well.payload - custom request payload to setpublic void addComponent(String name, String value)
name - name of request component to setvalue - new value of specified request componentpublic void addParameter(String name, String value)
name - name of the extended parameter to setvalue - value of the specified extended parameterpublic void addParameters(Map<String,String> parameters)
Map.parameters - Map of name-value pairs to pass as extended request
parametersaddParameter(String, String)public void setCountParameter(int count)
count - new value of "count" extended request parameteraddParameter(String, String),
setStartIndexParameter(int)public void setStartIndexParameter(int startIndex)
startIndex - new value of "startIndex" extended request parameteraddParameter(String, String),
setCountParameter(int)public void setFieldsParameter(String[] fields)
fields - array of field names to pass as extended request parameteraddParameter(String, String)public void addRpcPayloadParameter(String name, Object value)
Client to generate the JSON payload for a
RPC request; this method should not be called by clients directly unless
custom requests are being executed.name - name of RPC payload parameter to setvalue - value of the specified RPC payload parameter, usually of type
String, List, or Mappublic void addRestPayloadParameter(String name, Object value)
Client to generate the JSON payload for a
REST request; this method should not be called by clients directly unless
custom requests are being executed.name - name of REST payload parameter to setvalue - value of the specified REST payload parameter, usually of
type String, List, or Mappublic <T extends Model> void addRestPayloadParameters(T modelObject)
Client to generate the JSON payload
for a REST request ; this method should not be called by clients directly
unless custom requests are being executed.modelObject - Map of name-value pairs to pass as REST payload
parameterspublic void addRpcQueryStringParameter(String name, String value)
Client to generate the query string that
gets appended to the RPC endpoint; this method should not be called by
clients directly unless custom requests are being executed.name - name of the RPC query string parameter to setvalue - value of the specified RPC query string parameterpublic void addRestQueryStringParameter(String name, String value)
Client to generate the query string that
gets appended to the RESTful URL; this method should not be called by
clients directly unless custom requests are being executed.name - name of the REST query string parameter to setvalue - value of the specified REST query string parameterpublic void setModelClass(Class<? extends Model> modelClass)
modelClass - class extending Model to use to access response
dataCopyright © 2012. All Rights Reserved.