• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Entry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.volley.Cache.Entry的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Entry类属于com.android.volley.Cache包,在下文中一共展示了Entry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: pruneIfNeeded

import com.android.volley.Cache.Entry; //导入依赖的package包/类
private void pruneIfNeeded(int neededSpace) {
    if (this.mTotalSize + ((long) neededSpace) >= ((long) this.mMaxCacheSizeInBytes)) {
        if (VolleyLog.DEBUG) {
            VolleyLog.v("Pruning old cache entries.", new Object[0]);
        }
        long before = this.mTotalSize;
        int prunedFiles = 0;
        long startTime = SystemClock.elapsedRealtime();
        Iterator<Map.Entry<String, CacheHeader>> iterator = this.mEntries.entrySet().iterator();
        while (iterator.hasNext()) {
            CacheHeader e = (CacheHeader) ((Map.Entry) iterator.next()).getValue();
            if (getFileForKey(e.key).delete()) {
                this.mTotalSize -= e.size;
            } else {
                VolleyLog.d("Could not delete cache entry for key=%s, filename=%s", e.key, getFilenameForKey(e.key));
            }
            iterator.remove();
            prunedFiles++;
            if (((float) (this.mTotalSize + ((long) neededSpace))) < ((float) this.mMaxCacheSizeInBytes) * HYSTERESIS_FACTOR) {
                break;
            }
        }
        if (VolleyLog.DEBUG) {
            VolleyLog.v("pruned %d files, %d bytes, %d ms", Integer.valueOf(prunedFiles), Long.valueOf(this.mTotalSize - before), Long.valueOf(SystemClock.elapsedRealtime() - startTime));
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:DiskBasedCache.java


示例17: writeStringStringMap

import com.android.volley.Cache.Entry; //导入依赖的package包/类
static void writeStringStringMap(Map<String, String> map, OutputStream os) throws IOException {
    if (map != null) {
        writeInt(os, map.size());
        for (Map.Entry<String, String> entry : map.entrySet()) {
            writeString(os, (String) entry.getKey());
            writeString(os, (String) entry.getValue());
        }
        return;
    }
    writeInt(os, 0);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:DiskBasedCache.java


示例18: addCacheHeaders

import com.android.volley.Cache.Entry; //导入依赖的package包/类
private void addCacheHeaders(Map<String, String> headers, Entry entry) {
    if (entry != null) {
        if (entry.etag != null) {
            headers.put("If-None-Match", entry.etag);
        }
        if (entry.lastModified > 0) {
            headers.put("If-Modified-Since", DateUtils.formatDate(new Date(entry.lastModified)));
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:BasicNetwork.java


示例19: encodeParameters

import com.android.volley.Cache.Entry; //导入依赖的package包/类
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
    StringBuilder encodedParams = new StringBuilder();
    try {
        for (Map.Entry<String, String> entry : params.entrySet()) {
            encodedParams.append(URLEncoder.encode((String) entry.getKey(), paramsEncoding));
            encodedParams.append('=');
            encodedParams.append(URLEncoder.encode((String) entry.getValue(), paramsEncoding));
            encodedParams.append('&');
        }
        return encodedParams.toString().getBytes(paramsEncoding);
    } catch (UnsupportedEncodingException uee) {
        throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:Request.java


示例20: 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", InternalUtils.formatDate(refTime));
	}
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:16,代码来源:BasicNetwork.java



注:本文中的com.android.volley.Cache.Entry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultProxyRoutePlanner类代码示例发布时间:2022-05-21
下一篇:
Java CustomTextField类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap