當前位置: 首頁>>代碼示例>>Java>>正文


Java BoxObject類代碼示例

本文整理匯總了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;
        }
    };
}
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:24,代碼來源:BoxRequestEvent.java

示例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;
}
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:29,代碼來源:BoxRequest.java

示例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);
}
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:15,代碼來源:BoxRequest.java

示例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;
}
 
開發者ID:box,項目名稱:box-android-browse-sdk,代碼行數:10,代碼來源:BoxSimpleLocalCache.java

示例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);
}
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:6,代碼來源:BoxRequestUpload.java

示例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());
    }
}
 
開發者ID:box,項目名稱:box-android-browse-sdk,代碼行數:7,代碼來源:BoxSimpleLocalCache.java

示例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;
}
 
開發者ID:box,項目名稱:box-android-share-sdk,代碼行數:14,代碼來源:BoxShareController.java

示例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;
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:10,代碼來源:BoxCache.java

示例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;
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:10,代碼來源:BoxCache.java

示例10: executeRequest

import com.box.androidsdk.content.models.BoxObject; //導入依賴的package包/類
<E extends BoxObject> BoxFutureTask<E> executeRequest(final Class<E> clazz, final BoxRequest request); 
開發者ID:box,項目名稱:box-android-share-sdk,代碼行數:2,代碼來源:ShareController.java


注:本文中的com.box.androidsdk.content.models.BoxObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。