| AndBase开发框架 1.6

- 首页
- 相关页面
- 命名空间
- 类
- 文件

- 类列表
- 类索引
- 类继承关系
- 类成员

全部 类 命名空间 文件 函数 变量 枚举值 页
类 | Public 成员函数 | Protected 成员函数 | 包函数 | Private 成员函数 | Private 属性 | 静态 Private 属性 | 所有成员列表
com.ab.network.toolbox.Request< T >类 参考abstract
类 com.ab.network.toolbox.Request< T > 继承关系图:

## 类
interface | Method
enum | Priority

## Public 成员函数
| Request (String url, Response.ErrorListener listener)
| Request (int method, String url, Response.ErrorListener listener)
int | getMethod ()
void | setTag (Object tag)
Object | getTag ()
int | getTrafficStatsTag ()
void | setRetryPolicy (RetryPolicy retryPolicy)
void | addMarker (String tag)
void | setRequestQueue (RequestQueue requestQueue)
final void | setSequence (int sequence)
final int | getSequence ()
String | getUrl ()
String | getCacheKey ()
void | setCacheEntry (Cache.Entry entry)
Cache.Entry | getCacheEntry ()
void | cancel ()
boolean | isCanceled ()
Map< String, String > | getHeaders () throws AuthFailureError
String | getPostBodyContentType ()
byte[] | getPostBody () throws AuthFailureError
String | getBodyContentType ()
byte[] | getBody () throws AuthFailureError
final void | setShouldCache (boolean shouldCache)
final boolean | shouldCache ()
Priority | getPriority ()
final int | getTimeoutMs ()
RetryPolicy | getRetryPolicy ()
void | markDelivered ()
boolean | hasHadResponseDelivered ()
void | deliverError (VolleyError error)
int | compareTo (Request< T > other)
String | toString ()

## Protected 成员函数
Map< String, String > | getPostParams () throws AuthFailureError
String | getPostParamsEncoding ()
Map< String, String > | getParams () throws AuthFailureError
String | getParamsEncoding ()
abstract Response< T > | parseNetworkResponse (NetworkResponse response)
VolleyError | parseNetworkError (VolleyError volleyError)
abstract void | deliverResponse (T response)

## 包函数
void | finish (final String tag)

## Private 成员函数
byte[] | encodeParameters (Map< String, String > params, String paramsEncoding)

## Private 属性
final MarkerLog | mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null
final int | mMethod
final String | mUrl
final int | mDefaultTrafficStatsTag
final Response.ErrorListener | mErrorListener
Integer | mSequence
RequestQueue | mRequestQueue
boolean | mShouldCache = true
boolean | mCanceled = false
boolean | mResponseDelivered = false
long | mRequestBirthTime = 0
RetryPolicy | mRetryPolicy
Cache.Entry | mCacheEntry = null
Object | mTag

## 静态 Private 属性
static final String | DEFAULT_PARAMS_ENCODING = "UTF-8"
static final long | SLOW_REQUEST_THRESHOLD_MS = 3000

## 详细描述

Base class for all network requests.

参数

  <T> | The type of parsed response this request expects.

## 构造及析构函数说明

com.ab.network.toolbox.Request< T >.Request | ( | String | url,
|  | Response.ErrorListener | listener
| ) |  |
| inline

Creates a new request with the given URL and error listener. Note that the normal response listener is not provided here as delivery of responses is provided by subclasses, who have a better idea of how to deliver an already-parsed response.

弃用:
  Use Request(int, String, com.android.volley.Response.ErrorListener).

com.ab.network.toolbox.Request< T >.Request | ( | int | method,
|  | String | url,
|  | Response.ErrorListener | listener
| ) |  |
| inline

Creates a new request with the given method (one of the values from Method), URL, and error listener. Note that the normal response listener is not provided here as delivery of responses is provided by subclasses, who have a better idea of how to deliver an already-parsed response.

## 成员函数说明

void com.ab.network.toolbox.Request< T >.addMarker | ( | String | tag | ) |
| inline

Adds an event to this request's event log; for debugging.

void com.ab.network.toolbox.Request< T >.cancel | ( |  | ) |
| inline

Mark this request as canceled. No callback will be delivered.

int com.ab.network.toolbox.Request< T >.compareTo | ( | Request< T > | other | ) |
| inline

Our comparator sorts from high to low priority, and secondarily by sequence number to provide FIFO ordering.

void com.ab.network.toolbox.Request< T >.deliverError | ( | VolleyError | error | ) |
| inline

Delivers error message to the ErrorListener that the Request was initialized with.

参数

  error | Error details

abstract void com.ab.network.toolbox.Request< T >.deliverResponse | ( | T | response | ) |
| abstract protected

Subclasses must implement this to perform delivery of the parsed response to their listeners. The given response is guaranteed to be non-null; responses that fail to parse are not delivered.

参数

  response | The parsed response returned by parseNetworkResponse(NetworkResponse)

byte [] com.ab.network.toolbox.Request< T >.encodeParameters | ( | Map< String, String > | params,
|  | String | paramsEncoding
| ) |  |
| inline private

Converts `params` into an application/x-www-form-urlencoded encoded string.

void com.ab.network.toolbox.Request< T >.finish | ( | final String | tag | ) |
| inline package

Notifies the request queue that this request has finished (successfully or with error).

Also dumps all events from this request's event log; for debugging.

byte [] com.ab.network.toolbox.Request< T >.getBody | ( |  | ) | throws AuthFailureError
| inline

Returns the raw POST or PUT body to be sent.

异常

  AuthFailureError | in the event of auth failure

String com.ab.network.toolbox.Request< T >.getBodyContentType | ( |  | ) |
| inline

Cache.Entry com.ab.network.toolbox.Request< T >.getCacheEntry | ( |  | ) |
| inline

Returns the annotated cache entry, or null if there isn't one.

String com.ab.network.toolbox.Request< T >.getCacheKey | ( |  | ) |
| inline

Returns the cache key for this request. By default, this is the URL.

Map<String, String> com.ab.network.toolbox.Request< T >.getHeaders | ( |  | ) | throws AuthFailureError
| inline

Returns a list of extra HTTP headers to go along with this request. Can throw AuthFailureError as authentication may be required to provide these values.

异常

  AuthFailureError | In the event of auth failure

int com.ab.network.toolbox.Request< T >.getMethod | ( |  | ) |
| inline

Return the method for this request. Can be one of the values in Method.

Map<String, String> com.ab.network.toolbox.Request< T >.getParams | ( |  | ) | throws AuthFailureError
| inline protected

Returns a Map of parameters to be used for a POST or PUT request. Can throw AuthFailureError as authentication may be required to provide these values.

Note that you can directly override getBody() for custom data.

异常

  AuthFailureError | in the event of auth failure

String com.ab.network.toolbox.Request< T >.getParamsEncoding | ( |  | ) |
| inline protected

Returns which encoding should be used when converting POST or PUT parameters returned by getParams() into a raw POST or PUT body.

This controls both encodings:

1. The string encoding used when converting parameter names and values into bytes prior to URL encoding them.
2. The string encoding used when converting the URL encoded parameters into a raw byte array.

byte [] com.ab.network.toolbox.Request< T >.getPostBody | ( |  | ) | throws AuthFailureError
| inline

Returns the raw POST body to be sent.

异常

  AuthFailureError | In the event of auth failure

弃用:
  Use getBody() instead.

String com.ab.network.toolbox.Request< T >.getPostBodyContentType | ( |  | ) |
| inline

弃用:
  Use getBodyContentType() instead.

Map<String, String> com.ab.network.toolbox.Request< T >.getPostParams | ( |  | ) | throws AuthFailureError
| inline protected

Returns a Map of POST parameters to be used for this request, or null if a simple GET should be used. Can throw AuthFailureError as authentication may be required to provide these values.

Note that only one of getPostParams() and getPostBody() can return a non-null value.

异常

  AuthFailureError | In the event of auth failure

弃用:
  Use getParams() instead.

String com.ab.network.toolbox.Request< T >.getPostParamsEncoding | ( |  | ) |
| inline protected

Returns which encoding should be used when converting POST parameters returned by getPostParams() into a raw POST body.

This controls both encodings:

1. The string encoding used when converting parameter names and values into bytes prior to URL encoding them.
2. The string encoding used when converting the URL encoded parameters into a raw byte array.

弃用:
  Use getParamsEncoding() instead.

Priority com.ab.network.toolbox.Request< T >.getPriority | ( |  | ) |
| inline

Returns the Priority of this request; Priority#NORMAL by default.

RetryPolicy com.ab.network.toolbox.Request< T >.getRetryPolicy | ( |  | ) |
| inline

Returns the retry policy that should be used for this request.

final int com.ab.network.toolbox.Request< T >.getSequence | ( |  | ) |
| inline

Returns the sequence number of this request.

Object com.ab.network.toolbox.Request< T >.getTag | ( |  | ) |
| inline

Returns this request's tag.

参见
  Request::setTag(Object)

final int com.ab.network.toolbox.Request< T >.getTimeoutMs | ( |  | ) |
| inline

Returns the socket timeout in milliseconds per retry attempt. (This value can be changed per retry attempt if a backoff is specified via backoffTimeout()). If there are no retry attempts remaining, this will cause delivery of a TimeoutError error.

int com.ab.network.toolbox.Request< T >.getTrafficStatsTag | ( |  | ) |
| inline

返回
  A tag for use with TrafficStats#setThreadStatsTag(int)

String com.ab.network.toolbox.Request< T >.getUrl | ( |  | ) |
| inline

Returns the URL of this request.

boolean com.ab.network.toolbox.Request< T >.hasHadResponseDelivered | ( |  | ) |
| inline

Returns true if this request has had a response delivered for it.

boolean com.ab.network.toolbox.Request< T >.isCanceled | ( |  | ) |
| inline

Returns true if this request has been canceled.

void com.ab.network.toolbox.Request< T >.markDelivered | ( |  | ) |
| inline

Mark this request as having a response delivered on it. This can be used later in the request's lifetime for suppressing identical responses.

VolleyError com.ab.network.toolbox.Request< T >.parseNetworkError | ( | VolleyError | volleyError | ) |
| inline protected

Subclasses can override this method to parse 'networkError' and return a more specific error.

The default implementation just returns the passed 'networkError'.

参数

  volleyError | the error retrieved from the network

返回
  an NetworkError augmented with additional information

abstract Response<T> com.ab.network.toolbox.Request< T >.parseNetworkResponse | ( | NetworkResponse | response | ) |
| abstract protected

Subclasses must implement this to parse the raw network response and return an appropriate response type. This method will be called from a worker thread. The response will not be delivered if you return null.

参数

  response | Response from the network

返回
  The parsed response, or null in the case of an error

void com.ab.network.toolbox.Request< T >.setCacheEntry | ( | Cache.Entry | entry | ) |
| inline

Annotates this request with an entry retrieved for it from cache. Used for cache coherency support.

void com.ab.network.toolbox.Request< T >.setRequestQueue | ( | RequestQueue | requestQueue | ) |
| inline

Associates this request with the given queue. The request queue will be notified when this request has finished.

void com.ab.network.toolbox.Request< T >.setRetryPolicy | ( | RetryPolicy | retryPolicy | ) |
| inline

Sets the retry policy for this request.

final void com.ab.network.toolbox.Request< T >.setSequence | ( | int | sequence | ) |
| inline

Sets the sequence number of this request. Used by RequestQueue.

final void com.ab.network.toolbox.Request< T >.setShouldCache | ( | boolean | shouldCache | ) |
| inline

Set whether or not responses to this request should be cached.

void com.ab.network.toolbox.Request< T >.setTag | ( | Object | tag | ) |
| inline

Set a tag on this request. Can be used to cancel all requests with this tag by RequestQueue#cancelAll(Object).

final boolean com.ab.network.toolbox.Request< T >.shouldCache | ( |  | ) |
| inline

Returns true if responses to this request should be cached.

String com.ab.network.toolbox.Request< T >.toString | ( |  | ) |
| inline

## 类成员变量说明

final String com.ab.network.toolbox.Request< T >.DEFAULT_PARAMS_ENCODING = "UTF-8"
| static private

Default encoding for POST or PUT parameters. See getParamsEncoding().

Cache.Entry com.ab.network.toolbox.Request< T >.mCacheEntry = null
| private

When a request can be retrieved from cache but must be refreshed from the network, the cache entry will be stored here so that in the event of a "Not Modified" response, we can be sure it hasn't been evicted from cache.

boolean com.ab.network.toolbox.Request< T >.mCanceled = false
| private

Whether or not this request has been canceled.

final int com.ab.network.toolbox.Request< T >.mDefaultTrafficStatsTag
| private

Default tag for TrafficStats.

final Response.ErrorListener com.ab.network.toolbox.Request< T >.mErrorListener
| private

Listener interface for errors.

final MarkerLog com.ab.network.toolbox.Request< T >.mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null
| private

An event log tracing the lifetime of this request; for debugging.

final int com.ab.network.toolbox.Request< T >.mMethod
| private

Request method of this request. Currently supports GET, POST, PUT, and DELETE.

long com.ab.network.toolbox.Request< T >.mRequestBirthTime = 0
| private

RequestQueue com.ab.network.toolbox.Request< T >.mRequestQueue
| private

The request queue this request is associated with.

boolean com.ab.network.toolbox.Request< T >.mResponseDelivered = false
| private

Whether or not a response has been delivered for this request yet.

RetryPolicy com.ab.network.toolbox.Request< T >.mRetryPolicy
| private

The retry policy for this request.

Integer com.ab.network.toolbox.Request< T >.mSequence
| private

Sequence number of this request, used to enforce FIFO ordering.

boolean com.ab.network.toolbox.Request< T >.mShouldCache = true
| private

Whether or not responses to this request should be cached.

Object com.ab.network.toolbox.Request< T >.mTag
| private

An opaque token tagging this request; used for bulk cancellation.

final String com.ab.network.toolbox.Request< T >.mUrl
| private

URL of this request.

final long com.ab.network.toolbox.Request< T >.SLOW_REQUEST_THRESHOLD_MS = 3000
| static private

Threshold at which we should log the request (even when debug logging is not enabled).

该类的文档由以下文件生成:

- src/com/ab/network/toolbox/Request.java