T - The object that data from the server should be parsed into.R - The child class extending this object.public abstract class BoxRequest<T extends BoxObject,R extends BoxRequest<T,R>>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BoxRequest.BoxRequestHandler<R extends BoxRequest>
This class handles parsing the response from Box's server into the correct data object if successful or throw the appropriate exception if not.
|
static class |
BoxRequest.ContentTypes
The different content types used to encode data sent to the Box Server.
|
static class |
BoxRequest.Methods
The different type of methods to communicate with the Box server.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JSON_OBJECT |
protected java.util.LinkedHashMap<java.lang.String,java.lang.Object> |
mBodyMap |
protected BoxRequest.ContentTypes |
mContentType |
protected java.util.LinkedHashMap<java.lang.String,java.lang.String> |
mHeaderMap |
protected ProgressListener |
mListener |
protected java.util.HashMap<java.lang.String,java.lang.String> |
mQueryMap |
protected BoxRequest.Methods |
mRequestMethod |
protected java.lang.String |
mRequestUrlString |
protected BoxSession |
mSession |
| Modifier | Constructor and Description |
|---|---|
protected |
BoxRequest(BoxRequest request)
Helper constructor used to copy the fields of one BoxRequest to another.
|
|
BoxRequest(java.lang.Class<T> clazz,
java.lang.String requestUrl,
BoxSession session)
Constructs a new BoxRequest.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.net.URL |
buildUrl() |
protected com.box.androidsdk.content.requests.BoxHttpRequest |
createHttpRequest() |
protected java.lang.String |
createQuery(java.util.Map<java.lang.String,java.lang.String> map) |
protected java.lang.String |
getIfMatchEtag() |
protected java.lang.String |
getIfNoneMatchEtag() |
BoxRequest.BoxRequestHandler |
getRequestHandler()
Gets the request handler.
|
BoxSession |
getSession()
Gets session used to authenticate this request.
|
java.lang.String |
getStringBody()
Gets the string body for the request.
|
protected void |
importRequestContentMapsFrom(BoxRequest source)
Copies data from query and body maps into the current request.
|
protected void |
logDebug(BoxHttpResponse response) |
protected void |
logRequest() |
protected void |
parseHashMapEntry(JsonObject jsonBody,
java.util.Map.Entry<java.lang.String,java.lang.Object> entry) |
protected JsonValue |
parseJsonObject(java.lang.Object obj) |
T |
send()
Synchronously make the request to Box and handle the response appropriately.
|
protected void |
setBody(com.box.androidsdk.content.requests.BoxHttpRequest request) |
R |
setContentType(BoxRequest.ContentTypes contentType) |
protected void |
setHeaders(com.box.androidsdk.content.requests.BoxHttpRequest request) |
protected R |
setIfMatchEtag(java.lang.String etag) |
protected R |
setIfNoneMatchEtag(java.lang.String etag) |
R |
setRequestHandler(BoxRequest.BoxRequestHandler handler) |
R |
setTimeOut(int timeOut)
Set the time out for this request in milliseconds via the method in HttpUrlConnection.
|
BoxFutureTask<T> |
toTask()
Creates a BoxFutureTask to make the request asynchronously.
|
public static final java.lang.String JSON_OBJECT
protected java.lang.String mRequestUrlString
protected BoxRequest.Methods mRequestMethod
protected java.util.HashMap<java.lang.String,java.lang.String> mQueryMap
protected java.util.LinkedHashMap<java.lang.String,java.lang.Object> mBodyMap
protected java.util.LinkedHashMap<java.lang.String,java.lang.String> mHeaderMap
protected BoxRequest.ContentTypes mContentType
protected BoxSession mSession
protected ProgressListener mListener
public BoxRequest(java.lang.Class<T> clazz, java.lang.String requestUrl, BoxSession session)
clazz - The class of the object that should be returned, the class specified by the child in T.requestUrl - the url to use to connect to Box.session - the session used to authenticate the given request.protected BoxRequest(BoxRequest request)
request - the request to copy data from.protected void importRequestContentMapsFrom(BoxRequest source)
source - the request to copy data from.public BoxSession getSession()
public BoxRequest.BoxRequestHandler getRequestHandler()
public R setRequestHandler(BoxRequest.BoxRequestHandler handler)
public R setContentType(BoxRequest.ContentTypes contentType)
public R setTimeOut(int timeOut)
Warning: if the hostname resolves to multiple IP addresses, this client will try each in RFC 3484 order. If connecting to each of these addresses fails, multiple timeouts will elapse before the connect attempt throws an exception. Host names that support both IPv6 and IPv4 always have at least 2 IP addresses.
timeOut - public T send() throws BoxException
BoxException - thrown if there was a problem with handling the request.public BoxFutureTask<T> toTask()
protected com.box.androidsdk.content.requests.BoxHttpRequest createHttpRequest()
throws java.io.IOException,
BoxException
java.io.IOExceptionBoxExceptionprotected java.net.URL buildUrl()
throws java.net.MalformedURLException,
java.io.UnsupportedEncodingException
java.net.MalformedURLExceptionjava.io.UnsupportedEncodingExceptionprotected java.lang.String createQuery(java.util.Map<java.lang.String,java.lang.String> map)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionprotected void setHeaders(com.box.androidsdk.content.requests.BoxHttpRequest request)
protected R setIfMatchEtag(java.lang.String etag)
protected java.lang.String getIfMatchEtag()
protected R setIfNoneMatchEtag(java.lang.String etag)
protected java.lang.String getIfNoneMatchEtag()
protected void setBody(com.box.androidsdk.content.requests.BoxHttpRequest request)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getStringBody()
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException - thrown if there was a problem with the encoding of the body.protected void parseHashMapEntry(JsonObject jsonBody,
java.util.Map.Entry<java.lang.String,java.lang.Object> entry)
protected JsonValue parseJsonObject(java.lang.Object obj)
protected void logDebug(BoxHttpResponse response) throws BoxException
BoxExceptionprotected void logRequest()