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