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


Java Entry類代碼示例

本文整理匯總了Java中com.android.volley.Cache.Entry的典型用法代碼示例。如果您正苦於以下問題:Java Entry類的具體用法?Java Entry怎麽用?Java Entry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Entry類屬於com.android.volley.Cache包,在下文中一共展示了Entry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: put

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public synchronized void put(String key, Entry entry) {
    pruneIfNeeded(entry.data.length);
    File file = getFileForKey(key);
    try {
        BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
        CacheHeader e = new CacheHeader(key, entry);
        if (e.writeHeader(fos)) {
            fos.write(entry.data);
            fos.close();
            putEntry(key, e);
        } else {
            fos.close();
            VolleyLog.d("Failed to write header for %s", file.getAbsolutePath());
            throw new IOException();
        }
    } catch (IOException e2) {
        if (!file.delete()) {
            VolleyLog.d("Could not clean up file %s", file.getAbsolutePath());
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:DiskBasedCache.java

示例2: parseNetworkResponse

import com.android.volley.Cache.Entry; //導入依賴的package包/類
@Override
public Response<T> parseNetworkResponse(NetworkResponse response) {

    String parsed;
    try {

        String charsetName = HttpHeaderParser.parseCharset(response.headers);
        parsed = new String(response.data, charsetName);
    } catch (UnsupportedEncodingException e) {

        parsed = new String(response.data);
        e.printStackTrace();
    }

    QyerResponse<T> resp = onResponse(parsed);
    if (resp.isSuccess()) {

        Entry entry = HttpHeaderParser.parseCacheHeaders(response);
        mObjResp = Response.success(resp.getData(), entry);
        return mObjResp;
    } else {

        return Response.error(new VolleyError(resp.getMsg()));
    }
}
 
開發者ID:joy-inc,項目名稱:joy-library,代碼行數:26,代碼來源:ObjectRequest.java

示例3: addCacheHeaders

import com.android.volley.Cache.Entry; //導入依賴的package包/類
private void addCacheHeaders(Map<String, String> headers, Cache.Entry entry) {
    // If there's no cache entry, we're done.
    if (entry == null) {
        return;
    }

    if (entry.etag != null) {
        // 設置 If-None-Match
        headers.put("If-None-Match", entry.etag);
    }

    if (entry.lastModified > 0) {
        Date refTime = new Date(entry.lastModified);
        // 設置 If-Modified-Since
        headers.put("If-Modified-Since", DateUtils.formatDate(refTime));
    }
}
 
開發者ID:CaMnter,項目名稱:SaveVolley,代碼行數:18,代碼來源:BasicNetwork.java

示例4: invalidate

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public final void invalidate(String paramString, boolean paramBoolean)
{
  try
  {
    Cache.Entry localEntry = get(paramString);
    if (localEntry != null)
    {
      localEntry.softTtl = 0L;
      if (paramBoolean) {
        localEntry.ttl = 0L;
      }
      put(paramString, localEntry);
    }
    return;
  }
  finally {}
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:18,代碼來源:DiskBasedCache.java

示例5: stripForCache

import com.android.volley.Cache.Entry; //導入依賴的package包/類
private void stripForCache(Response.ResponseWrapper paramResponseWrapper, Cache.Entry paramEntry)
{
  if ((paramResponseWrapper.preFetch.length <= 0) && (paramResponseWrapper.commands == null) && (paramResponseWrapper.notification.length <= 0) && (paramResponseWrapper.serverCookies == null)) {
    return;
  }
  Cache localCache = this.mApiContext.mCache;
  long l = System.currentTimeMillis();
  for (PreFetch localPreFetch : paramResponseWrapper.preFetch)
  {
    Cache.Entry localEntry = new Cache.Entry();
    localEntry.data = localPreFetch.response;
    localEntry.etag = localPreFetch.etag;
    localEntry.serverDate = paramEntry.serverDate;
    localEntry.ttl = (l + localPreFetch.ttl);
    localEntry.softTtl = (l + localPreFetch.softTtl);
    localCache.put(makeCacheKey(Uri.withAppendedPath(DfeApi.BASE_URI, localPreFetch.url).toString()), localEntry);
  }
  paramResponseWrapper.preFetch = PreFetch.emptyArray();
  paramResponseWrapper.commands = null;
  paramResponseWrapper.notification = Notification.emptyArray();
  paramResponseWrapper.serverCookies = null;
  paramEntry.data = MessageNano.toByteArray(paramResponseWrapper);
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:24,代碼來源:DfeRequest.java

示例6: get

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public final String get(String paramString)
{
  Cache.Entry localEntry = this.mCache.get("AddressMetadataCacheManager-" + paramString);
  if ((localEntry == null) || (localEntry.isExpired())) {
    return "";
  }
  try
  {
    String str = new String(localEntry.data, "UTF-8");
    return str;
  }
  catch (UnsupportedEncodingException localUnsupportedEncodingException)
  {
    throw new RuntimeException("UTF-8 not supported.");
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:17,代碼來源:AddressMetadataCacheManager.java

示例7: put

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public final void put(String paramString1, String paramString2)
{
  Cache.Entry localEntry = new Cache.Entry();
  try
  {
    localEntry.data = paramString2.getBytes("UTF-8");
    localEntry.serverDate = System.currentTimeMillis();
    localEntry.ttl = (604800000L + localEntry.serverDate);
    this.mCache.put("AddressMetadataCacheManager-" + paramString1, localEntry);
    return;
  }
  catch (UnsupportedEncodingException localUnsupportedEncodingException)
  {
    throw new RuntimeException("UTF-8 not supported.");
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:17,代碼來源:AddressMetadataCacheManager.java

示例8: getDocument

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public static Document getDocument(PurchaseParams paramPurchaseParams, Cache paramCache)
{
  if (paramPurchaseParams.document != null) {
    return paramPurchaseParams.document;
  }
  Cache.Entry localEntry = paramCache.get("InstantPurchaseDocument-" + paramPurchaseParams.docidStr);
  if ((localEntry == null) || (localEntry.isExpired())) {
    return null;
  }
  try
  {
    byte[] arrayOfByte = localEntry.data;
    Document localDocument = new Document((DocV2)MessageNano.mergeFrom$1ec43da(new DocV2(), arrayOfByte, arrayOfByte.length));
    return localDocument;
  }
  catch (InvalidProtocolBufferNanoException localInvalidProtocolBufferNanoException)
  {
    throw new RuntimeException(localInvalidProtocolBufferNanoException);
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:21,代碼來源:InstantPurchaseUtils.java

示例9: stripForCache

import com.android.volley.Cache.Entry; //導入依賴的package包/類
private void stripForCache(PlayResponse.PlayResponseWrapper paramPlayResponseWrapper, Cache.Entry paramEntry)
{
  if ((paramPlayResponseWrapper.preFetch.length <= 0) && (paramPlayResponseWrapper.commands == null)) {
    return;
  }
  Cache localCache = this.mApiContext.mCache;
  long l = System.currentTimeMillis();
  for (PreFetch localPreFetch : paramPlayResponseWrapper.preFetch)
  {
    Cache.Entry localEntry = new Cache.Entry();
    localEntry.data = localPreFetch.response;
    localEntry.etag = localPreFetch.etag;
    localEntry.serverDate = paramEntry.serverDate;
    localEntry.ttl = (l + localPreFetch.ttl);
    localEntry.softTtl = (l + localPreFetch.softTtl);
    localCache.put(makeCacheKey(Uri.withAppendedPath(PlayDfeApi.BASE_URI, localPreFetch.url).toString()), localEntry);
  }
  paramPlayResponseWrapper.preFetch = PreFetch.emptyArray();
  paramPlayResponseWrapper.commands = null;
  paramEntry.data = MessageNano.toByteArray(paramPlayResponseWrapper);
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:22,代碼來源:DfeRequest.java

示例10: parseNetworkResponse

import com.android.volley.Cache.Entry; //導入依賴的package包/類
protected final Response<Pair<RequestT, ResponseT>> parseNetworkResponse(NetworkResponse paramNetworkResponse)
{
  try
  {
    Class localClass = this.mResponseClass;
    MessageNano localMessageNano1 = (MessageNano)this.mResponseClass.newInstance();
    byte[] arrayOfByte = paramNetworkResponse.data;
    MessageNano localMessageNano2 = (MessageNano)localClass.cast(MessageNano.mergeFrom$1ec43da(localMessageNano1, arrayOfByte, arrayOfByte.length));
    ProtoUtils.logResponse(localMessageNano2, getUrl());
    Cache.Entry localEntry = HttpHeaderParser.parseCacheHeaders(paramNetworkResponse);
    return Response.success(Pair.create(this, localMessageNano2), localEntry);
  }
  catch (InstantiationException localInstantiationException)
  {
    throw new RuntimeException("Failed to instantiate proto object.", localInstantiationException);
  }
  catch (IllegalAccessException localIllegalAccessException)
  {
    throw new RuntimeException("Failed to access proto constructor.", localIllegalAccessException);
  }
  catch (IOException localIOException)
  {
    Log.e("SecureRequest", "Couldn't parse proto response for url=" + getUrl());
  }
  return Response.error(new ParseError(paramNetworkResponse));
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:27,代碼來源:SecureRequest.java

示例11: getBody

import com.android.volley.Cache.Entry; //導入依賴的package包/類
@Override
public byte[] getBody() throws AuthFailureError {
	try {
		if (params != null) {
			List<NameValuePair> pairs = new ArrayList<NameValuePair>();
			for (Map.Entry<String, String> e : params.entrySet()) {
				String key = e.getKey();
				String value = e.getValue();
				if (value != null) {
					pairs.add(new BasicNameValuePair(key, value));
				}
			}
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			HttpEntity entity = new UrlEncodedFormEntity(pairs, PROTOCOL_CHARSET);
			entity.writeTo(bos);
			return bos.toByteArray();
		}
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return null;
}
 
開發者ID:qianweicheng,項目名稱:Qmusic,代碼行數:23,代碼來源:QmusicRequest.java

示例12: addCacheHeaders

import com.android.volley.Cache.Entry; //導入依賴的package包/類
private void addCacheHeaders(Map<String, String> headers, Cache.Entry entry) {
    // If there's no cache entry, we're done.
    if (entry == null) {
        return;
    }

    if (entry.etag != null) {
        headers.put("If-None-Match", entry.etag);
    }

    if (entry.lastModified > 0) {
        Date refTime = new Date(entry.lastModified);
        headers.put("If-Modified-Since", DateUtils.formatDate(refTime));
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:BasicNetwork.java

示例13: CacheHeader

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public CacheHeader(String key, Entry entry) {
    this.key = key;
    this.size = (long) entry.data.length;
    this.etag = entry.etag;
    this.serverDate = entry.serverDate;
    this.lastModified = entry.lastModified;
    this.ttl = entry.ttl;
    this.softTtl = entry.softTtl;
    this.responseHeaders = entry.responseHeaders;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:DiskBasedCache.java

示例14: toCacheEntry

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public Entry toCacheEntry(byte[] data) {
    Entry e = new Entry();
    e.data = data;
    e.etag = this.etag;
    e.serverDate = this.serverDate;
    e.lastModified = this.lastModified;
    e.ttl = this.ttl;
    e.softTtl = this.softTtl;
    e.responseHeaders = this.responseHeaders;
    return e;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:DiskBasedCache.java

示例15: invalidate

import com.android.volley.Cache.Entry; //導入依賴的package包/類
public synchronized void invalidate(String key, boolean fullExpire) {
    Entry entry = get(key);
    if (entry != null) {
        entry.softTtl = 0;
        if (fullExpire) {
            entry.ttl = 0;
        }
        put(key, entry);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:DiskBasedCache.java


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