本文整理汇总了Java中com.box.androidsdk.content.models.BoxObject类的典型用法代码示例。如果您正苦于以下问题:Java BoxObject类的具体用法?Java BoxObject怎么用?Java BoxObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoxObject类属于com.box.androidsdk.content.models包,在下文中一共展示了BoxObject类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRequestHandler
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
public static BoxRequestHandler<BoxRequestEvent> createRequestHandler(final BoxRequestEvent request){
return new BoxRequestHandler<BoxRequestEvent>(request) {
public <T extends BoxObject> T onResponse(Class<T> clazz, BoxHttpResponse response) throws IllegalAccessException, InstantiationException, BoxException {
if (Thread.currentThread().isInterrupted()){
disconnectForInterrupt(response);
throw new BoxException("Request cancelled ",new InterruptedException());
}
if (response.getResponseCode() == BoxConstants.HTTP_STATUS_TOO_MANY_REQUESTS) {
return retryRateLimited(response);
}
String contentType = response.getContentType();
T entity = clazz.newInstance();
if (entity instanceof BoxJsonObject && contentType.contains(ContentTypes.JSON.toString())) {
String json = response.getStringBody();
char charA = json.charAt(json.indexOf("event") - 1);
char charB = json.charAt(json.indexOf("user") - 1);
((BoxJsonObject) entity).createFromJson(json);
}
return entity;
}
};
}
示例2: onResponse
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
/**
* Parse the response from the server into the expected object T. clazz is used to create a new instance of this object in this implementation,
* so if using this implementation, it is important that T be an instance of BoxJsonObject.
*
* @param clazz the class to use to construct an instance of T in which to parse data to.
* @param response the response from the server.
* @param <T> the class to return an instance of.
* @return an instance of T parsed from the server response.
* @throws IllegalAccessException thrown if clazz this class does not have access to the constructor for clazz.
* @throws InstantiationException thrown if clazz cannot be instantiated for example if it does not have a default contsructor.
* @throws BoxException thrown for any type of server exception or server response indicating an error.
*/
public <T extends BoxObject> T onResponse(Class<T> clazz, BoxHttpResponse response) throws IllegalAccessException, InstantiationException, BoxException {
if (response.getResponseCode() == BoxConstants.HTTP_STATUS_TOO_MANY_REQUESTS) {
return retryRateLimited(response);
}
if (Thread.currentThread().isInterrupted()){
disconnectForInterrupt(response);
}
String contentType = response.getContentType();
T entity = clazz.newInstance();
if (entity instanceof BoxJsonObject && contentType.contains(ContentTypes.JSON.toString())) {
String json = response.getStringBody();
((BoxJsonObject) entity).createFromJson(json);
}
return entity;
}
示例3: retryRateLimited
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
protected <T extends BoxObject> T retryRateLimited(BoxHttpResponse response) throws BoxException {
if (mNumRateLimitRetries < DEFAULT_NUM_RETRIES) {
mNumRateLimitRetries++;
int defaultWait = DEFAULT_RATE_LIMIT_WAIT + (int) (10 * Math.random());
int retryAfter = getRetryAfterFromResponse(response, defaultWait);
try {
Thread.sleep(retryAfter);
} catch (InterruptedException e) {
throw new BoxException(e.getMessage(), e);
}
return (T) mRequest.send();
}
throw new BoxException.RateLimitAttemptsExceeded("Max attempts exceeded", mNumRateLimitRetries, response);
}
示例4: get
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
@Override
public <T extends BoxObject, R extends BoxRequest & BoxCacheableRequest> T get(R request) throws BoxException {
if (request instanceof BoxRequestsFolder.GetFolderWithAllItems){
// Assume fields have not changed.
return (T)mFullFolderCache.get(((BoxRequestsFolder.GetFolderWithAllItems) request).getId());
}
return null;
}
示例5: onResponse
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
@Override
public <T extends BoxObject> T onResponse(Class<T> clazz, BoxHttpResponse response) throws IllegalAccessException, InstantiationException, BoxException {
BoxIterator list = (BoxIterator) super.onResponse(BoxIteratorBoxEntity.class, response);
return (T)list.get(0);
}
示例6: put
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
@Override
public <T extends BoxObject> void put(BoxResponse<T> response) throws BoxException {
if (response.isSuccess() && response.getRequest() instanceof BoxRequestsFolder.GetFolderWithAllItems){
mFullFolderCache.put(((BoxRequestsFolder.GetFolderWithAllItems) response.getRequest()).getId(), (BoxFolder)response.getResult());
}
}
示例7: executeRequest
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
/**
* Executes a request on given Box model object
*
* @param clazz Name of Box model class
* @param request BoxRequest object
* @return instance of BoxFutureTask that asynchronously executes a request to complete the task
*/
@Override
public <E extends BoxObject> BoxFutureTask<E> executeRequest(Class<E> clazz, BoxRequest request) {
BoxFutureTask<E> task = new BoxFutureTask<E>(clazz, request);
getApiExecutor().submit(task);
return task;
}
示例8: get
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
/**
* Returns the last cached BoxObject for this BoxRequest.
* @param request - The BoxRequest object that can be used for fetching remote data.
* @param <T> A child of BoxObject
* @param <R> A child of BoxRequest that implements BoxCacheableRequest
* @return a BoxObject associated with the request type.
* @throws BoxException thrown if the request fails.
*/
<T extends BoxObject, R extends BoxRequest & BoxCacheableRequest> T get(R request) throws BoxException;
示例9: put
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
/**
* Stores the BoxResponse object in the local store. The original request should included in the
* response object.
*
* @param response - BoxResponse object obtained from a BoxRequest sent using the Box Android SDK.
* @param <T> A child of BoxObject
* @throws BoxException - Exception that should be thrown if there is an issue with storing response.
*/
<T extends BoxObject> void put(BoxResponse<T> response) throws BoxException;
示例10: executeRequest
import com.box.androidsdk.content.models.BoxObject; //导入依赖的package包/类
<E extends BoxObject> BoxFutureTask<E> executeRequest(final Class<E> clazz, final BoxRequest request);