1 /*
2 * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore/src/main/java/org/apache/http/params/HttpParams.java $
3 * $Revision: 744530 $
4 * $Date: 2009-02-14 18:09:27 +0100 (Sat, 14 Feb 2009) $
5 *
6 * ====================================================================
7 * Licensed to the Apache Software Foundation (ASF) under one
8 * or more contributor license agreements. See the NOTICE file
9 * distributed with this work for additional information
10 * regarding copyright ownership. The ASF licenses this file
11 * to you under the Apache License, Version 2.0 (the
12 * "License"); you may not use this file except in compliance
13 * with the License. You may obtain a copy of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing,
18 * software distributed under the License is distributed on an
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 * KIND, either express or implied. See the License for the
21 * specific language governing permissions and limitations
22 * under the License.
23 * ====================================================================
24 *
25 * This software consists of voluntary contributions made by many
26 * individuals on behalf of the Apache Software Foundation. For more
27 * information on the Apache Software Foundation, please see
28 * <http://www.apache.org/>.
29 *
30 */
31
32 package org.apache.http.params;
33
34 /**
35 *
36 * HttpParams interface represents a collection of immutable values that define
37 * a runtime behavior of a component. HTTP parameters should be simple objects:
38 * integers, doubles, strings, collections and objects that remain immutable
39 * at runtime. HttpParams is expected to be used in the 'write once - ready
40 * many' mode. Once initialized HTTP parameters are not expected to mutate in
41 * the course of HTTP message processing.
42 * <p>
43 * The purpose of this intreface is to define a behavior of other components.
44 * Usually each complex component has its own HTTP parameter collection.
45 * <p>
46 * Instances of this interface can be linked together to form a hierarchy.
47 * In the simplest form one set of parameters can use content of another one
48 * to obtain default values of parameters not present in the local set.
49 *
50 * @see DefaultedHttpParams
51 *
52 *
53 * @version $Revision: 744530 $
54 *
55 * @since 4.0
56 */
57 public interface HttpParams {
58
59 /**
60 * Obtains the value of the given parameter.
61 *
62 * @param name the parent name.
63 *
64 * @return an object that represents the value of the parameter,
65 * <code>null</code> if the parameter is not set or if it
66 * is explicitly set to <code>null</code>
67 *
68 * @see #setParameter(String, Object)
69 */
70 Object getParameter(String name);
71
72 /**
73 * Assigns the value to the parameter with the given name.
74 *
75 * @param name parameter name
76 * @param value parameter value
77 */
78 HttpParams setParameter(String name, Object value);
79
80 /**
81 * Creates a copy of these parameters.
82 *
83 * @return a new set of parameters holding the same values as this one
84 */
85 HttpParams copy();
86
87 /**
88 * Removes the parameter with the specified name.
89 *
90 * @param name parameter name
91 *
92 * @return true if the parameter existed and has been removed, false else.
93 */
94 boolean removeParameter(String name);
95
96 /**
97 * Returns a {@link Long} parameter value with the given name.
98 * If the parameter is not explicitly set, the default value is returned.
99 *
100 * @param name the parent name.
101 * @param defaultValue the default value.
102 *
103 * @return a {@link Long} that represents the value of the parameter.
104 *
105 * @see #setLongParameter(String, long)
106 */
107 long getLongParameter(String name, long defaultValue);
108
109 /**
110 * Assigns a {@link Long} to the parameter with the given name
111 *
112 * @param name parameter name
113 * @param value parameter value
114 */
115 HttpParams setLongParameter(String name, long value);
116
117 /**
118 * Returns an {@link Integer} parameter value with the given name.
119 * If the parameter is not explicitly set, the default value is returned.
120 *
121 * @param name the parent name.
122 * @param defaultValue the default value.
123 *
124 * @return a {@link Integer} that represents the value of the parameter.
125 *
126 * @see #setIntParameter(String, int)
127 */
128 int getIntParameter(String name, int defaultValue);
129
130 /**
131 * Assigns an {@link Integer} to the parameter with the given name
132 *
133 * @param name parameter name
134 * @param value parameter value
135 */
136 HttpParams setIntParameter(String name, int value);
137
138 /**
139 * Returns a {@link Double} parameter value with the given name.
140 * If the parameter is not explicitly set, the default value is returned.
141 *
142 * @param name the parent name.
143 * @param defaultValue the default value.
144 *
145 * @return a {@link Double} that represents the value of the parameter.
146 *
147 * @see #setDoubleParameter(String, double)
148 */
149 double getDoubleParameter(String name, double defaultValue);
150
151 /**
152 * Assigns a {@link Double} to the parameter with the given name
153 *
154 * @param name parameter name
155 * @param value parameter value
156 */
157 HttpParams setDoubleParameter(String name, double value);
158
159 /**
160 * Returns a {@link Boolean} parameter value with the given name.
161 * If the parameter is not explicitly set, the default value is returned.
162 *
163 * @param name the parent name.
164 * @param defaultValue the default value.
165 *
166 * @return a {@link Boolean} that represents the value of the parameter.
167 *
168 * @see #setBooleanParameter(String, boolean)
169 */
170 boolean getBooleanParameter(String name, boolean defaultValue);
171
172 /**
173 * Assigns a {@link Boolean} to the parameter with the given name
174 *
175 * @param name parameter name
176 * @param value parameter value
177 */
178 HttpParams setBooleanParameter(String name, boolean value);
179
180 /**
181 * Checks if a boolean parameter is set to <code>true</code>.
182 *
183 * @param name parameter name
184 *
185 * @return <tt>true</tt> if the parameter is set to value <tt>true</tt>,
186 * <tt>false</tt> if it is not set or set to <code>false</code>
187 */
188 boolean isParameterTrue(String name);
189
190 /**
191 * Checks if a boolean parameter is not set or <code>false</code>.
192 *
193 * @param name parameter name
194 *
195 * @return <tt>true</tt> if the parameter is either not set or
196 * set to value <tt>false</tt>,
197 * <tt>false</tt> if it is set to <code>true</code>
198 */
199 boolean isParameterFalse(String name);
200
201 }