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.params; 29 30 /** 31 * HttpParams interface represents a collection of immutable values that define 32 * a runtime behavior of a component. HTTP parameters should be simple objects: 33 * integers, doubles, strings, collections and objects that remain immutable 34 * at runtime. HttpParams is expected to be used in 'write once - read many' mode. 35 * Once initialized, HTTP parameters are not expected to mutate in 36 * the course of HTTP message processing. 37 * <p> 38 * The purpose of this interface is to define a behavior of other components. 39 * Usually each complex component has its own HTTP parameter collection. 40 * <p> 41 * Instances of this interface can be linked together to form a hierarchy. 42 * In the simplest form one set of parameters can use content of another one 43 * to obtain default values of parameters not present in the local set. 44 * 45 * @since 4.0 46 * 47 * @deprecated (4.3) use configuration classes provided 'org.apache.http.config' 48 * and 'org.apache.http.client.config' 49 */ 50 @Deprecated 51 public interface HttpParams { 52 53 /** 54 * Obtains the value of the given parameter. 55 * 56 * @param name the parent name. 57 * 58 * @return an object that represents the value of the parameter, 59 * {@code null} if the parameter is not set or if it 60 * is explicitly set to {@code null} 61 * 62 * @see #setParameter(String, Object) 63 */ 64 Object getParameter(String name); 65 66 /** 67 * Assigns the value to the parameter with the given name. 68 * 69 * @param name parameter name 70 * @param value parameter value 71 */ 72 HttpParams setParameter(String name, Object value); 73 74 /** 75 * Creates a copy of these parameters. 76 * 77 * @return a new set of parameters holding the same values as this one 78 */ 79 HttpParams copy(); 80 81 /** 82 * Removes the parameter with the specified name. 83 * 84 * @param name parameter name 85 * 86 * @return true if the parameter existed and has been removed, false else. 87 */ 88 boolean removeParameter(String name); 89 90 /** 91 * Returns a {@link Long} parameter value with the given name. 92 * If the parameter is not explicitly set, the default value is returned. 93 * 94 * @param name the parent name. 95 * @param defaultValue the default value. 96 * 97 * @return a {@link Long} that represents the value of the parameter. 98 * 99 * @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 }