001/*
002 * ====================================================================
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 * ====================================================================
020 *
021 * This software consists of voluntary contributions made by many
022 * individuals on behalf of the Apache Software Foundation.  For more
023 * information on the Apache Software Foundation, please see
024 * <http://www.apache.org/>.
025 *
026 */
027
028package org.apache.http.params;
029
030/**
031 * HttpParams interface represents a collection of immutable values that define
032 * a runtime behavior of a component. HTTP parameters should be simple objects:
033 * integers, doubles, strings, collections and objects that remain immutable
034 * at runtime. HttpParams is expected to be used in 'write once - read many' mode.
035 * Once initialized, HTTP parameters are not expected to mutate in
036 * the course of HTTP message processing.
037 * <p>
038 * The purpose of this interface is to define a behavior of other components.
039 * Usually each complex component has its own HTTP parameter collection.
040 * <p>
041 * Instances of this interface can be linked together to form a hierarchy.
042 * In the simplest form one set of parameters can use content of another one
043 * to obtain default values of parameters not present in the local set.
044 *
045 * @since 4.0
046 *
047 * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
048 *  and 'org.apache.http.client.config'
049 */
050@Deprecated
051public interface HttpParams {
052
053    /**
054     * Obtains the value of the given parameter.
055     *
056     * @param name the parent name.
057     *
058     * @return  an object that represents the value of the parameter,
059     *          {@code null} if the parameter is not set or if it
060     *          is explicitly set to {@code null}
061     *
062     * @see #setParameter(String, Object)
063     */
064    Object getParameter(String name);
065
066    /**
067     * Assigns the value to the parameter with the given name.
068     *
069     * @param name parameter name
070     * @param value parameter value
071     */
072    HttpParams setParameter(String name, Object value);
073
074    /**
075     * Creates a copy of these parameters.
076     *
077     * @return  a new set of parameters holding the same values as this one
078     */
079    HttpParams copy();
080
081    /**
082     * Removes the parameter with the specified name.
083     *
084     * @param name parameter name
085     *
086     * @return true if the parameter existed and has been removed, false else.
087     */
088    boolean removeParameter(String name);
089
090    /**
091     * Returns a {@link Long} parameter value with the given name.
092     * If the parameter is not explicitly set, the default value is returned.
093     *
094     * @param name the parent name.
095     * @param defaultValue the default value.
096     *
097     * @return a {@link Long} that represents the value of the parameter.
098     *
099     * @see #setLongParameter(String, long)
100     */
101    long getLongParameter(String name, long defaultValue);
102
103    /**
104     * Assigns a {@link Long} to the parameter with the given name
105     *
106     * @param name parameter name
107     * @param value parameter value
108     */
109    HttpParams setLongParameter(String name, long value);
110
111    /**
112     * Returns an {@link Integer} parameter value with the given name.
113     * If the parameter is not explicitly set, the default value is returned.
114     *
115     * @param name the parent name.
116     * @param defaultValue the default value.
117     *
118     * @return a {@link Integer} that represents the value of the parameter.
119     *
120     * @see #setIntParameter(String, int)
121     */
122    int getIntParameter(String name, int defaultValue);
123
124    /**
125     * Assigns an {@link Integer} to the parameter with the given name
126     *
127     * @param name parameter name
128     * @param value parameter value
129     */
130    HttpParams setIntParameter(String name, int value);
131
132    /**
133     * Returns a {@link Double} parameter value with the given name.
134     * If the parameter is not explicitly set, the default value is returned.
135     *
136     * @param name the parent name.
137     * @param defaultValue the default value.
138     *
139     * @return a {@link Double} that represents the value of the parameter.
140     *
141     * @see #setDoubleParameter(String, double)
142     */
143    double getDoubleParameter(String name, double defaultValue);
144
145    /**
146     * Assigns a {@link Double} to the parameter with the given name
147     *
148     * @param name parameter name
149     * @param value parameter value
150     */
151    HttpParams setDoubleParameter(String name, double value);
152
153    /**
154     * Returns a {@link Boolean} parameter value with the given name.
155     * If the parameter is not explicitly set, the default value is returned.
156     *
157     * @param name the parent name.
158     * @param defaultValue the default value.
159     *
160     * @return a {@link Boolean} that represents the value of the parameter.
161     *
162     * @see #setBooleanParameter(String, boolean)
163     */
164    boolean getBooleanParameter(String name, boolean defaultValue);
165
166    /**
167     * Assigns a {@link Boolean} to the parameter with the given name
168     *
169     * @param name parameter name
170     * @param value parameter value
171     */
172    HttpParams setBooleanParameter(String name, boolean value);
173
174    /**
175     * Checks if a boolean parameter is set to {@code true}.
176     *
177     * @param name parameter name
178     *
179     * @return {@code true} if the parameter is set to value {@code true},
180     *         {@code false} if it is not set or set to {@code false}
181     */
182    boolean isParameterTrue(String name);
183
184    /**
185     * Checks if a boolean parameter is not set or {@code false}.
186     *
187     * @param name parameter name
188     *
189     * @return {@code true} if the parameter is either not set or
190     *         set to value {@code false},
191     *         {@code false} if it is set to {@code true}
192     */
193    boolean isParameterFalse(String name);
194
195}