当前位置: 首页>>代码示例>>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;未经允许,请勿转载。