com.baidu.sapi2.http
类 RequestParams

java.lang.Object
  继承者 com.baidu.sapi2.http.RequestParams

public class RequestParams
extends Object

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("email", "my@email.com");
 params.put("profile_picture", new File("pic.jpg")); // Upload a File
 params.put("profile_picture2", someInputStream); // Upload an InputStream
 params.put("profile_picture3", new ByteArrayInputStream(someBytes)); // Upload
                                                                      // some
                                                                      // bytes
 
 AsyncHttpClient client = new AsyncHttpClient();
 client.post("http://myendpoint.com", params, responseHandler);
 


字段摘要
protected  ConcurrentHashMap<String,com.baidu.sapi2.http.RequestParams.FileWrapper> fileParams
           
protected  ConcurrentHashMap<String,String> urlParams
           
protected  ConcurrentHashMap<String,ArrayList<String>> urlParamsWithArray
           
 
构造方法摘要
RequestParams()
          Constructs a new empty RequestParams instance.
RequestParams(Map<String,String> source)
          Constructs a new RequestParams instance containing the key/value string params from the specified map.
RequestParams(Object... keysAndValues)
          Constructs a new RequestParams instance and populate it with multiple initial key/value string param.
RequestParams(String key, String value)
          Constructs a new RequestParams instance and populate it with a single initial key/value string param.
 
方法摘要
 org.apache.http.HttpEntity getEntity()
          Returns an HttpEntity containing all request parameters
protected  List<org.apache.http.message.BasicNameValuePair> getParamsList()
           
protected  String getParamString()
           
 void put(String key, ArrayList<String> values)
          Adds param with more than one value.
 void put(String key, File file)
          Adds a file to the request.
 void put(String key, InputStream stream)
          Adds an input stream to the request.
 void put(String key, InputStream stream, String fileName)
          Adds an input stream to the request.
 void put(String key, InputStream stream, String fileName, String contentType)
          Adds an input stream to the request.
 void put(String key, String value)
          Adds a key/value string pair to the request.
 void remove(String key)
          Removes a parameter from the request.
 String toString()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

urlParams

protected ConcurrentHashMap<String,String> urlParams

fileParams

protected ConcurrentHashMap<String,com.baidu.sapi2.http.RequestParams.FileWrapper> fileParams

urlParamsWithArray

protected ConcurrentHashMap<String,ArrayList<String>> urlParamsWithArray
构造方法详细信息

RequestParams

public RequestParams()
Constructs a new empty RequestParams instance.


RequestParams

public RequestParams(Map<String,String> source)
Constructs a new RequestParams instance containing the key/value string params from the specified map.

参数:
source - the source key/value string map to add.

RequestParams

public RequestParams(String key,
                     String value)
Constructs a new RequestParams instance and populate it with a single initial key/value string param.

参数:
key - the key name for the intial param.
value - the value string for the initial param.

RequestParams

public RequestParams(Object... keysAndValues)
Constructs a new RequestParams instance and populate it with multiple initial key/value string param.

参数:
keysAndValues - a sequence of keys and values. Objects are automatically converted to Strings (including the value null).
抛出:
IllegalArgumentException - if the number of arguments isn't even.
方法详细信息

put

public void put(String key,
                String value)
Adds a key/value string pair to the request.

参数:
key - the key name for the new param.
value - the value string for the new param.

put

public void put(String key,
                File file)
         throws FileNotFoundException
Adds a file to the request.

参数:
key - the key name for the new param.
file - the file to add.
抛出:
FileNotFoundException

put

public void put(String key,
                ArrayList<String> values)
Adds param with more than one value.

参数:
key - the key name for the new param.
values - is the ArrayList with values for the param.

put

public void put(String key,
                InputStream stream)
Adds an input stream to the request.

参数:
key - the key name for the new param.
stream - the input stream to add.

put

public void put(String key,
                InputStream stream,
                String fileName)
Adds an input stream to the request.

参数:
key - the key name for the new param.
stream - the input stream to add.
fileName - the name of the file.

put

public void put(String key,
                InputStream stream,
                String fileName,
                String contentType)
Adds an input stream to the request.

参数:
key - the key name for the new param.
stream - the input stream to add.
fileName - the name of the file.
contentType - the content type of the file, eg. application/json

remove

public void remove(String key)
Removes a parameter from the request.

参数:
key - the key name for the parameter to remove.

toString

public String toString()
覆盖:
Object 中的 toString

getEntity

public org.apache.http.HttpEntity getEntity()
Returns an HttpEntity containing all request parameters


getParamsList

protected List<org.apache.http.message.BasicNameValuePair> getParamsList()

getParamString

protected String getParamString()


Copyright © 2013. All Rights Reserved.