CacheRequest类无继承类
引入了如下包
import java.io.OutputStream; import java.io.IOException;
该类的类头注释如下:
/** * Represents channels for storing resources in the * ResponseCache. Instances of such a class provide an * OutputStream object which is called by protocol handlers to * store the resource data into the cache, and also an abort() method * which allows a cache store operation to be interrupted and * abandoned. If an IOException is encountered while reading the * response or writing to the cache, the current cache store operation * will be aborted. * * @author Yingxian Wang * @since 1.5 */
大意如下:
相当于在ResponseCache中存储资源的途径
该类的实例会提供一个输出流对象来存储资源到缓存中
并且提供abort方法允许缓存存储操作被打断和抛弃
如果在读取回复或者写入缓存时遇到了IO异常,当前的缓存存储操作将会中止
该类含有如下的成员方法:
获得可向缓存中写入的输出流
public abstract OutputStream getBody() throws IOException;
中止当前的缓存响应
public abstract void abort();
CacheResponse类无继承类
引入了如下包:
import java.io.InputStream; import java.util.Map; import java.util.List; import java.io.IOException;
该类的类头注释如下:
/** * Represent channels for retrieving resources from the * ResponseCache. Instances of such a class provide an * InputStream that returns the entity body, and also a * getHeaders() method which returns the associated response headers. * * @author Yingxian Wang * @since 1.5 */
大意如下:
相当于从ResponseCache中取回资源的途径
该类的实例会提供一个输入流并且完整返回该输入流
并且也会提供getHeaders方法
该方法会返回相关的响应头
该类含有如下的成员方法:
以map方式返回响应头
public abstract Map<String, List<String>> getHeaders() throws IOException;
返回从缓存输入的输入流
public abstract InputStream getBody() throws IOException;
这两个类都是针对缓存操作的,本身说明中和应用和网络操作关系不大(当然可以用在网络上,只是在任何方面都可以用得上,感觉封到IO里可能好些),不是很懂为什么要封在net包。该类主要是对高速缓存的资源管理。