Accela SDK for Android  V3.0
 All Classes Functions Variables Pages
com.accela.mobile.http.RequestParams Class Reference

Public Member Functions

 RequestParams ()
 
 RequestParams (Map< String, String > source)
 
 RequestParams (String rootKey, JSONObject jsonContent)
 
 RequestParams (String key, String value)
 
void put (String key, String value)
 
void put (String key, File file) throws FileNotFoundException
 
void put (String key, InputStream stream)
 
void put (String key, InputStream stream, String fileName)
 
void put (String key, InputStream stream, String fileName, String contentType)
 
void remove (String key)
 
String toString ()
 
HttpEntity getEntity ()
 
StringEntity getStringEntity (Boolean isJson)
 
String getParaValue (String paraName)
 
Boolean hasKey (String key)
 
String getJsonString ()
 

Protected Member Functions

List< BasicNameValuePair > getParamsList ()
 
String getParamString ()
 

Protected Attributes

ConcurrentHashMap< String, String > urlParams
 
ConcurrentHashMap< String,
FileWrapper > 
fileParams
 

Detailed Description

 Accela Amobile
 File: RequestParams.java
 Accela, Inc.
 Copyright (C): 2013
 Description:
 Request parameters wrapper object, used to wrap parameters which will be sent together with HTTP GET/POST/PUT requests.
 Notes:
A collection of string request parameters or files to send along with
requests made from an AsyncHttpClient instance.
For example:
RequestParams params = new RequestParams();
params.put("username", "james");
params.put("password", "123456");
params.put("file1", new File("file.jpg")); // Upload a File
params.put("file2", someInputStream); // Upload an InputStream
params.put("file3", new ByteArrayInputStream(someBytes)); // Upload some bytes
 Revision History  

   @since 1.0
 

Constructor & Destructor Documentation

com.accela.mobile.http.RequestParams.RequestParams ( )
inline

Constructor without parameters.

Returns
An initialized RequestParams instance.
Since
1.0
com.accela.mobile.http.RequestParams.RequestParams ( Map< String, String >  source)
inline

Constructs a new RequestParams instance containing the key/value string parameters from the specified map.

Parameters
sourceThe source key/value string map to add.
Returns
An initialized RequestParams instance.
@since 1.0
com.accela.mobile.http.RequestParams.RequestParams ( String  rootKey,
JSONObject  jsonContent 
)
inline

Constructs a new RequestParams instance containing a JSON object. Typically this constructor is only used in POSTrequest when the post data is a JSON object which contains child JSON objects.

Parameters
rootKeyThe name of the root key.
jsonContentThe JSON object which maps to the root key.
Returns
An initialized RequestParams instance.
@since 1.0
com.accela.mobile.http.RequestParams.RequestParams ( String  key,
String  value 
)
inline

Constructs a new RequestParams instance and populate it with a single initial key/value string parameter.

Parameters
keyThe key name for the initial parameter.
valueThe value string for the initial parameter.
Returns
An initialized RequestParams instance.
@since 1.0

Member Function Documentation

HttpEntity com.accela.mobile.http.RequestParams.getEntity ( )
inline

Get the HttpEntity which contains all request parameters

Returns
A HttpEntity object.
@since 1.0
String com.accela.mobile.http.RequestParams.getJsonString ( )
inline

Convert the key-value parameters to JSON string.

Returns
A text string which presents the JSON content.
@since 3.0
List<BasicNameValuePair> com.accela.mobile.http.RequestParams.getParamsList ( )
inlineprotected

Protected method, used to get the list of the current URL parameters.

String com.accela.mobile.http.RequestParams.getParamString ( )
inlineprotected

Protected method, used to get the string which contains all request parameters.

String com.accela.mobile.http.RequestParams.getParaValue ( String  paraName)
inline

Get a parameter's value by its name

Parameters
paraNameThe parameter name.
Returns
The parameter's value.
@since 1.0
StringEntity com.accela.mobile.http.RequestParams.getStringEntity ( Boolean  isJson)
inline

Get the StringEntity which contains all request parameters

Parameters
isJsonIndicate whether it is JSON structure.
Returns
The StringEntity object got from the current RequestParams object.
@since 1.0
Boolean com.accela.mobile.http.RequestParams.hasKey ( String  key)
inline

Check whether a parameter exists or not.

Parameters
keyA key name.
Returns
Return true if the parameter exists; Otherwise, return false.
@since 1.0
void com.accela.mobile.http.RequestParams.put ( String  key,
String  value 
)
inline

Adds a key/value string pair to the request.

Parameters
keyThe key name for the new parameter.
valueThe value string for the new parameter.
Returns
Void.
@since 1.0
void com.accela.mobile.http.RequestParams.put ( String  key,
File  file 
) throws FileNotFoundException
inline

Adds a file to the request.

Parameters
keyThe key name for the new parameter.
fileThe file to add.
Returns
Void.
@since 1.0
void com.accela.mobile.http.RequestParams.put ( String  key,
InputStream  stream 
)
inline

Adds an input stream to the request.

Parameters
keyThe key name for the new parameter.
streamThe input stream to add.
Returns
Void.
@since 1.0
void com.accela.mobile.http.RequestParams.put ( String  key,
InputStream  stream,
String  fileName 
)
inline

Adds an input stream to the request.

Parameters
keyThe key name for the new parameter.
streamThe input stream to add.
fileNameThe name of the file.
Returns
Void.
@since 1.0
void com.accela.mobile.http.RequestParams.put ( String  key,
InputStream  stream,
String  fileName,
String  contentType 
)
inline

Adds an input stream to the request.

Parameters
keyThe key name for the new parameter.
streamThe input stream to add.
fileNameThe name of the file.
contentTypeThe content type of the file, eg. application/json.
Returns
Void.
@since 1.0
void com.accela.mobile.http.RequestParams.remove ( String  key)
inline

Removes a parameter from the request.

Parameters
keyThe key name for the parameter to remove.
Returns
Void.
@since 1.0
String com.accela.mobile.http.RequestParams.toString ( )
inline

Assemble the current object's content into a string.

Returns
A string.
@since 1.0

The documentation for this class was generated from the following file: