Java 8 CacheRequest - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CacheRequest class.

This code example shows how to use the following methods:getBody
    AbstractHttpInputStream(InputStream in, HttpURLConnectionImpl httpURLConnection,
            CacheRequest cacheRequest) throws IOException {
        this.in = in;
        this.httpURLConnection = httpURLConnection;
        this.cacheRequest = cacheRequest;
        this.cacheOut = cacheRequest != null ? cacheRequest.getBody() : null;
    } 
 
    /** 
     * read() is implemented using read(byte[], int, int) so subclasses only 
     * need to override the latter. 
     */ 
    @Override public final int read() throws IOException { 
        byte[] buffer = new byte[1];
        int count = read(buffer, 0, 1);
        return count == -1 ? -1 : buffer[0] & 0xff;
    } 
 
    /** 
     * skip(long) is implemented using read(byte[], int, int) so subclasses 
5
CodeRank
This code example shows how to use the following methods:getBody
        } 
 
        public void close() throws IOException { 
            if (SDK < GINGERBREAD) {
                if (mCacheRequest != null) {
                    OutputStream output = mCacheRequest.getBody();
                    output.close();
                } 
            } else { 
                // The platform will close the output stream 
            } 
        } 
 
        public void abort() { 
            if (mCacheRequest != null) {
                mCacheRequest.abort();
            } 
        } 
 
        public URLConnection getConnection() {
3
CodeRank
This code example shows how to use the following methods:getBody
            mCacheRequest = cacheRequest;
        } 
 
        @Override 
        public OutputStream getBody() throws IOException {
            return mCacheRequest.getBody();
        } 
 
        @Override 
        public void abort() { 
            // Drop all calls to abort() from the platform 
            // because sometimes abort() is called even 
            // when the request is successful. 
            // The FileResponseCacheContentHandler will call abort() 
            // on mCacheRequest directly when appropriate. 
        } 
    } 
} 
3
CodeRank
This code example shows how to use the following methods:getBody
    AbstractHttpInputStream(InputStream in, HttpURLConnectionImpl httpURLConnection,
            CacheRequest cacheRequest) throws IOException {
        this.in = in;
        this.httpURLConnection = httpURLConnection;
        this.cacheRequest = cacheRequest;
        this.cacheOut = cacheRequest != null ? cacheRequest.getBody() : null;
    } 
 
    /** 
     * read() is implemented using read(byte[], int, int) so subclasses only 
     * need to override the latter. 
     */ 
    @Override public final int read() throws IOException { 
        byte[] buffer = new byte[1];
        int count = read(buffer, 0, 1);
        return count == -1 ? -1 : buffer[0] & 0xff;
    } 
 
    /** 
     * skip(long) is implemented using read(byte[], int, int) so subclasses 
4
CodeRank
This code example shows how to use the following methods:getBody
            mCacheRequest = cacheRequest;
        } 
 
        @Override 
        public OutputStream getBody() throws IOException {
            return mCacheRequest.getBody();
        } 
 
        @Override 
        public void abort() { 
            // Drop all calls to abort() from the platform 
            // because sometimes abort() is called even 
            // when the request is successful. 
            // The FileResponseCacheContentHandler will call abort() 
            // on mCacheRequest directly when appropriate. 
        } 
    } 
} 
3
CodeRank
This code example shows how to use the following methods:getBody
            // on mCacheRequest directly when appropriate. 
        } 
 
        @Override 
        public OutputStream getBody() throws IOException {
            return mCacheRequest.getBody();
        } 
    } 
 
    private static final String MAX_AGE_PREFIX = "max-age=";
 
    private static final String TAG = "FileResponseCache";
 
    /** 
     * Creates a {@link ContentHandler} wrapper to capture a 
     * {@link URLConnection} using the currently installed 
     * {@link FileResponseCache}. 
     * <p> 
     * A wrapper is required to work-around platform bugs and to guard against 
     * cache corruption. It also provides a nice mechanism for passing 
3
CodeRank
This code example shows how to use the following methods:getBody
  AbstractHttpInputStream(InputStream in, HttpEngine httpEngine, CacheRequest cacheRequest)
      throws IOException { 
    this.in = in;
    this.httpEngine = httpEngine;
 
    OutputStream cacheBody = cacheRequest != null ? cacheRequest.getBody() : null;
 
    // some apps return a null body; for compatibility we treat that like a null cache request 
    if (cacheBody == null) {
      cacheRequest = null;
    } 
 
    this.cacheBody = cacheBody;
    this.cacheRequest = cacheRequest;
  } 
 
  /** 
   * read() is implemented using read(byte[], int, int) so subclasses only 
   * need to override the latter. 
   */ 
4
CodeRank
This code example shows how to use the following methods:abort
     * requires that the entire transfer be completed. If the intention was 
     * to cancel the transfer, closing the connection is the only solution. 
     */ 
    protected final void unexpectedEndOfInput() { 
        if (cacheRequest != null) {
            cacheRequest.abort();
        } 
        httpEngine.release(false);
    } 
} 
4
CodeRank
See Code Examples for Java 8 CacheRequest Methods: