1 /*
2 * ====================================================================
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 * ====================================================================
20 *
21 * This software consists of voluntary contributions made by many
22 * individuals on behalf of the Apache Software Foundation. For more
23 * information on the Apache Software Foundation, please see
24 * <http://www.apache.org/>.
25 *
26 */
27
28 package org.apache.http.protocol;
29
30 import java.util.List;
31
32 import org.apache.http.HttpResponseInterceptor;
33
34 /**
35 * Provides access to an ordered list of response interceptors.
36 * Lists are expected to be built upfront and used read-only afterwards
37 * for {@link HttpProcessor processing}.
38 *
39 * @since 4.0
40 */
41 public interface HttpResponseInterceptorList {
42
43 /**
44 * Appends a response interceptor to this list.
45 *
46 * @param interceptor the response interceptor to add
47 */
48 void addResponseInterceptor(HttpResponseInterceptor interceptor);
49
50 /**
51 * Inserts a response interceptor at the specified index.
52 *
53 * @param interceptor the response interceptor to add
54 * @param index the index to insert the interceptor at
55 */
56 void addResponseInterceptor(HttpResponseInterceptor interceptor, int index);
57
58 /**
59 * Obtains the current size of this list.
60 *
61 * @return the number of response interceptors in this list
62 */
63 int getResponseInterceptorCount();
64
65 /**
66 * Obtains a response interceptor from this list.
67 *
68 * @param index the index of the interceptor to obtain,
69 * 0 for first
70 *
71 * @return the interceptor at the given index, or
72 * <code>null</code> if the index is out of range
73 */
74 HttpResponseInterceptor getResponseInterceptor(int index);
75
76 /**
77 * Removes all response interceptors from this list.
78 */
79 void clearResponseInterceptors();
80
81 /**
82 * Removes all response interceptor of the specified class
83 *
84 * @param clazz the class of the instances to be removed.
85 */
86 void removeResponseInterceptorByClass(Class<? extends HttpResponseInterceptor> clazz);
87
88 /**
89 * Sets the response interceptors in this list.
90 * This list will be cleared and re-initialized to contain
91 * all response interceptors from the argument list.
92 * If the argument list includes elements that are not response
93 * interceptors, the behavior is implementation dependent.
94 *
95 * @param list the list of response interceptors
96 */
97 void setInterceptors(List<?> list);
98
99 }
100