michael@0: /* michael@0: * ==================================================================== michael@0: * Licensed to the Apache Software Foundation (ASF) under one michael@0: * or more contributor license agreements. See the NOTICE file michael@0: * distributed with this work for additional information michael@0: * regarding copyright ownership. The ASF licenses this file michael@0: * to you under the Apache License, Version 2.0 (the michael@0: * "License"); you may not use this file except in compliance michael@0: * with the License. You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, michael@0: * software distributed under the License is distributed on an michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY michael@0: * KIND, either express or implied. See the License for the michael@0: * specific language governing permissions and limitations michael@0: * under the License. michael@0: * ==================================================================== michael@0: * michael@0: * This software consists of voluntary contributions made by many michael@0: * individuals on behalf of the Apache Software Foundation. For more michael@0: * information on the Apache Software Foundation, please see michael@0: * . michael@0: * michael@0: */ michael@0: michael@0: package ch.boye.httpclientandroidlib.params; michael@0: michael@0: /** michael@0: * HttpParams interface represents a collection of immutable values that define michael@0: * a runtime behavior of a component. HTTP parameters should be simple objects: michael@0: * integers, doubles, strings, collections and objects that remain immutable michael@0: * at runtime. HttpParams is expected to be used in 'write once - read many' mode. michael@0: * Once initialized, HTTP parameters are not expected to mutate in michael@0: * the course of HTTP message processing. michael@0: *

michael@0: * The purpose of this interface is to define a behavior of other components. michael@0: * Usually each complex component has its own HTTP parameter collection. michael@0: *

michael@0: * Instances of this interface can be linked together to form a hierarchy. michael@0: * In the simplest form one set of parameters can use content of another one michael@0: * to obtain default values of parameters not present in the local set. michael@0: * michael@0: * @see DefaultedHttpParams michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: public interface HttpParams { michael@0: michael@0: /** michael@0: * Obtains the value of the given parameter. michael@0: * michael@0: * @param name the parent name. michael@0: * michael@0: * @return an object that represents the value of the parameter, michael@0: * null if the parameter is not set or if it michael@0: * is explicitly set to null michael@0: * michael@0: * @see #setParameter(String, Object) michael@0: */ michael@0: Object getParameter(String name); michael@0: michael@0: /** michael@0: * Assigns the value to the parameter with the given name. michael@0: * michael@0: * @param name parameter name michael@0: * @param value parameter value michael@0: */ michael@0: HttpParams setParameter(String name, Object value); michael@0: michael@0: /** michael@0: * Creates a copy of these parameters. michael@0: * michael@0: * @return a new set of parameters holding the same values as this one michael@0: * michael@0: * @deprecated michael@0: */ michael@0: HttpParams copy(); michael@0: michael@0: /** michael@0: * Removes the parameter with the specified name. michael@0: * michael@0: * @param name parameter name michael@0: * michael@0: * @return true if the parameter existed and has been removed, false else. michael@0: */ michael@0: boolean removeParameter(String name); michael@0: michael@0: /** michael@0: * Returns a {@link Long} parameter value with the given name. michael@0: * If the parameter is not explicitly set, the default value is returned. michael@0: * michael@0: * @param name the parent name. michael@0: * @param defaultValue the default value. michael@0: * michael@0: * @return a {@link Long} that represents the value of the parameter. michael@0: * michael@0: * @see #setLongParameter(String, long) michael@0: */ michael@0: long getLongParameter(String name, long defaultValue); michael@0: michael@0: /** michael@0: * Assigns a {@link Long} to the parameter with the given name michael@0: * michael@0: * @param name parameter name michael@0: * @param value parameter value michael@0: */ michael@0: HttpParams setLongParameter(String name, long value); michael@0: michael@0: /** michael@0: * Returns an {@link Integer} parameter value with the given name. michael@0: * If the parameter is not explicitly set, the default value is returned. michael@0: * michael@0: * @param name the parent name. michael@0: * @param defaultValue the default value. michael@0: * michael@0: * @return a {@link Integer} that represents the value of the parameter. michael@0: * michael@0: * @see #setIntParameter(String, int) michael@0: */ michael@0: int getIntParameter(String name, int defaultValue); michael@0: michael@0: /** michael@0: * Assigns an {@link Integer} to the parameter with the given name michael@0: * michael@0: * @param name parameter name michael@0: * @param value parameter value michael@0: */ michael@0: HttpParams setIntParameter(String name, int value); michael@0: michael@0: /** michael@0: * Returns a {@link Double} parameter value with the given name. michael@0: * If the parameter is not explicitly set, the default value is returned. michael@0: * michael@0: * @param name the parent name. michael@0: * @param defaultValue the default value. michael@0: * michael@0: * @return a {@link Double} that represents the value of the parameter. michael@0: * michael@0: * @see #setDoubleParameter(String, double) michael@0: */ michael@0: double getDoubleParameter(String name, double defaultValue); michael@0: michael@0: /** michael@0: * Assigns a {@link Double} to the parameter with the given name michael@0: * michael@0: * @param name parameter name michael@0: * @param value parameter value michael@0: */ michael@0: HttpParams setDoubleParameter(String name, double value); michael@0: michael@0: /** michael@0: * Returns a {@link Boolean} parameter value with the given name. michael@0: * If the parameter is not explicitly set, the default value is returned. michael@0: * michael@0: * @param name the parent name. michael@0: * @param defaultValue the default value. michael@0: * michael@0: * @return a {@link Boolean} that represents the value of the parameter. michael@0: * michael@0: * @see #setBooleanParameter(String, boolean) michael@0: */ michael@0: boolean getBooleanParameter(String name, boolean defaultValue); michael@0: michael@0: /** michael@0: * Assigns a {@link Boolean} to the parameter with the given name michael@0: * michael@0: * @param name parameter name michael@0: * @param value parameter value michael@0: */ michael@0: HttpParams setBooleanParameter(String name, boolean value); michael@0: michael@0: /** michael@0: * Checks if a boolean parameter is set to true. michael@0: * michael@0: * @param name parameter name michael@0: * michael@0: * @return true if the parameter is set to value true, michael@0: * false if it is not set or set to false michael@0: */ michael@0: boolean isParameterTrue(String name); michael@0: michael@0: /** michael@0: * Checks if a boolean parameter is not set or false. michael@0: * michael@0: * @param name parameter name michael@0: * michael@0: * @return true if the parameter is either not set or michael@0: * set to value false, michael@0: * false if it is set to true michael@0: */ michael@0: boolean isParameterFalse(String name); michael@0: michael@0: }