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 17 package java.net; 18 19 import java.io.IOException; 20 import java.io.OutputStream; 21 22 /** 23 * {@code CacheRequest} is a kind of channel for storing resource data in the 24 * {@code ResponseCache}. A protocol handler calls the {@code OutputStream} 25 * which is provided by the {@code CacheRequest} object, to store the resource 26 * data into the cache. It also allows the user to interrupt and abort the 27 * current store operation by calling the method {@code abort}. If an {@code 28 * IOException} occurs while reading the response or writing data to the cache, 29 * the current cache store operation is abandoned. 30 * 31 * @see ResponseCache 32 */ 33 public abstract class CacheRequest { 34 35 /** 36 * This implementation does nothing. 37 */ 38 public CacheRequest() { 39 } 40 41 /** 42 * Aborts the current cache operation. If an {@code IOException} occurs 43 * while reading the response or writing resource data to the cache, the 44 * current cache store operation is aborted. 45 */ 46 public abstract void abort(); 47 48 /** 49 * Returns an {@code OutputStream} which is used to write the response body. 50 * 51 * @return an {@code OutputStream} which is used to write the response body. 52 * @throws IOException 53 * if an I/O error is encountered during writing response body 54 * operation. 55 */ 56 public abstract OutputStream getBody() throws IOException; 57 } 58