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.HttpRequestInterceptor;
33
34 /**
35 * Provides access to an ordered list of request 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 HttpRequestInterceptorList {
42
43 /**
44 * Appends a request interceptor to this list.
45 *
46 * @param interceptor the request interceptor to add
47 */
48 void addRequestInterceptor(HttpRequestInterceptor interceptor);
49
50 /**
51 * Inserts a request interceptor at the specified index.
52 *
53 * @param interceptor the request interceptor to add
54 * @param index the index to insert the interceptor at
55 */
56 void addRequestInterceptor(HttpRequestInterceptor interceptor, int index);
57
58 /**
59 * Obtains the current size of this list.
60 *
61 * @return the number of request interceptors in this list
62 */
63 int getRequestInterceptorCount();
64
65 /**
66 * Obtains a request 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 HttpRequestInterceptor getRequestInterceptor(int index);
75
76 /**
77 * Removes all request interceptors from this list.
78 */
79 void clearRequestInterceptors();
80
81 /**
82 * Removes all request interceptor of the specified class
83 *
84 * @param clazz the class of the instances to be removed.
85 */
86 void removeRequestInterceptorByClass(Class<? extends HttpRequestInterceptor> clazz);
87
88 /**
89 * Sets the request interceptors in this list.
90 * This list will be cleared and re-initialized to contain
91 * all request interceptors from the argument list.
92 * If the argument list includes elements that are not request
93 * interceptors, the behavior is implementation dependent.
94 *
95 * @param list the list of request interceptors
96 */
97 void setInterceptors(List<?> list);
98
99 }
100