CacheResponse.java revision 72e93344b4d1ffc71e9c832ec23de0657e5b04a5
1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package java.net; 18 19import java.io.IOException; 20import java.io.InputStream; 21import java.util.List; 22import java.util.Map; 23 24/** 25 * {@code CacheResponse} is used for getting resource data from the installed 26 * {@code ResponseCache}. A {@code CacheResponse} object provides an {@code 27 * InputStream} to access the response body and also a method {@code 28 * getHeaders()} to fetch the response headers. 29 * 30 * @see ResponseCache 31 */ 32public abstract class CacheResponse { 33 /** 34 * This implementation does nothing. 35 */ 36 public CacheResponse() { 37 super(); 38 } 39 40 /** 41 * Returns an {@code InputStream} to access the response body. 42 * 43 * @return an {@code InputStream} which can be used to fetch the response 44 * body. 45 * @throws IOException 46 * if an I/O error is encountered while retrieving the response 47 * body. 48 */ 49 public abstract InputStream getBody() throws IOException; 50 51 /** 52 * Returns an immutable {@code Map} which contains the response headers 53 * information. 54 * 55 * @return an immutable {@code Map} which contains the response headers. The 56 * generic map contains response header fields as the key and a list 57 * of strings as values. 58 * @throws IOException 59 * if an I/O error is encountered while retrieving the response 60 * headers. 61 */ 62 public abstract Map<String, List<String>> getHeaders() throws IOException; 63} 64