java.lang.Objectjava.net.ResponseCache
public abstract class ResponseCache
表示 URLConnection 缓存的实现。这种类的实例可以通过执行 ResponseCache.setDefault(ResponseCache) 向系统注册,系统将调用此对象以便:
| 构造方法摘要 | |
|---|---|
ResponseCache() |
|
| 方法摘要 | |
|---|---|
abstract CacheResponse |
get(URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders) 根据请求的 uri、请求方法和请求头获取缓存的响应。 |
static ResponseCache |
getDefault() 获取系统级响应缓存。 |
abstract CacheRequest |
put(URI uri, URLConnection conn) 协议处理程序在获得资源后调用此方法,ResponseCache 必须决定是否在其缓存中存储资源。 |
static void |
setDefault(ResponseCache responseCache) 设置(或取消设置)系统级缓存。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public ResponseCache()
| 方法详细信息 |
|---|
public static ResponseCache getDefault()
ResponseCache
SecurityException - 如果安装了安全管理器并且它拒绝
NetPermission
("getResponseCache")
setDefault(ResponseCache)
public static void setDefault(ResponseCache responseCache)
responseCache - 响应缓存,或者为
null,表示取消设置缓存。
SecurityException - 如果安装了安全管理器并且它拒绝
NetPermission
("setResponseCache")
getDefault()
public abstract CacheResponse get(URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders) throws IOException
uri - 用于引用所请求的网络资源的
URI
rqstMethod - 表示请求方法的
String
rqstHeaders - 从请求头字段名称到表示当前请求头的字段值列表的映射
CacheResponse 实例,如果可从缓存中得到;否则返回 null
IOException - 如果发生 I/O 错误
IllegalArgumentException - 如果参数中的任何一个为 null
URLConnection.setUseCaches(boolean),
URLConnection.getUseCaches(),
URLConnection.setDefaultUseCaches(boolean),
URLConnection.getDefaultUseCaches()
public abstract CacheRequest put(URI uri, URLConnection conn) throws IOException
uri - 用于引用所请求的网络资源的
URI
conn - 用于获取要缓存的响应的 URLConnection 实例
CacheRequest。返回 null 指示调用方不打算缓存响应。
IOException - 如果发生 I/O 错误
IllegalArgumentException - 如果参数中的任何一个为 null