Return-Path: Delivered-To: apmail-jakarta-httpcomponents-commits-archive@www.apache.org Received: (qmail 11141 invoked from network); 26 May 2007 16:22:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 May 2007 16:22:21 -0000 Received: (qmail 35384 invoked by uid 500); 26 May 2007 16:22:26 -0000 Delivered-To: apmail-jakarta-httpcomponents-commits-archive@jakarta.apache.org Received: (qmail 35371 invoked by uid 500); 26 May 2007 16:22:26 -0000 Mailing-List: contact httpcomponents-commits-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: httpcomponents-dev@jakarta.apache.org Delivered-To: mailing list httpcomponents-commits@jakarta.apache.org Received: (qmail 35362 invoked by uid 99); 26 May 2007 16:22:26 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 May 2007 09:22:26 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 May 2007 09:22:20 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id EEDF01A981A; Sat, 26 May 2007 09:21:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r541912 - in /jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params: AbstractHttpParams.java BasicHttpParams.java HttpParams.java Date: Sat, 26 May 2007 16:21:59 -0000 To: httpcomponents-commits@jakarta.apache.org From: rolandw@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070526162159.EEDF01A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rolandw Date: Sat May 26 09:21:57 2007 New Revision: 541912 URL: http://svn.apache.org/viewvc?view=rev&rev=541912 Log: params refactoring, step 1+2 Added: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java (with props) Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java Added: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java?view=auto&rev=541912 ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java (added) +++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java Sat May 26 09:21:57 2007 @@ -0,0 +1,165 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.params; + +import org.apache.http.params.HttpParams; + + +/** + * Abstract base class for parameter collections. + * Type specific setters and getters are mapped to the abstract, + * generic getters and setters. + * + * @author Oleg Kalnichevski + * @author Roland Weber + * + * @version $Revision$ + */ +public abstract class AbstractHttpParams implements HttpParams { + + /** + * The optional set of default values to defer to. + *
+ * WARNING: Handling of default parameters is currently + * subject to discussions, and may be changed signifcantly. + */ + protected HttpParams defaults; + + /** + * Instantiates parameters. + */ + protected AbstractHttpParams() { + super(); + } + + + + /** + * Obtains default parameters, if set. + *
+ * WARNING: Handling of default parameters is currently + * subject to discussions, and may be changed signifcantly. + * + * @return the defaults, or null + */ + public synchronized HttpParams getDefaults() { + return this.defaults; + } + + /** + * Provides default parameters. + *
+ * WARNING: Handling of default parameters is currently + * subject to discussions, and may be changed signifcantly. + * + * @param params the new defaults, or null to unset + */ + public synchronized void setDefaults(final HttpParams params) { + + // check we're not becoming our own defaults, directly or indirectly + // that would trigger an endless loop when looking up an unknown param + HttpParams ancestor = params; + while (ancestor != null) { + // check for object identity, not .equals + if (ancestor == this) { + throw new IllegalArgumentException + ("cyclic default params detected"); + } + ancestor = ancestor.getDefaults(); + } + + this.defaults = params; + } + + + + public long getLongParameter(final String name, long defaultValue) { + Object param = getParameter(name); + if (param == null) { + return defaultValue; + } + return ((Long)param).longValue(); + } + + public HttpParams setLongParameter(final String name, long value) { + setParameter(name, new Long(value)); + return this; + } + + public int getIntParameter(final String name, int defaultValue) { + Object param = getParameter(name); + if (param == null) { + return defaultValue; + } + return ((Integer)param).intValue(); + } + + public HttpParams setIntParameter(final String name, int value) { + setParameter(name, new Integer(value)); + return this; + } + + public double getDoubleParameter(final String name, double defaultValue) { + Object param = getParameter(name); + if (param == null) { + return defaultValue; + } + return ((Double)param).doubleValue(); + } + + public HttpParams setDoubleParameter(final String name, double value) { + setParameter(name, new Double(value)); + return this; + } + + public boolean getBooleanParameter(final String name, boolean defaultValue) { + Object param = getParameter(name); + if (param == null) { + return defaultValue; + } + return ((Boolean)param).booleanValue(); + } + + public HttpParams setBooleanParameter(final String name, boolean value) { + setParameter(name, value ? Boolean.TRUE : Boolean.FALSE); + return this; + } + + public boolean isParameterTrue(final String name) { + return getBooleanParameter(name, false); + } + + public boolean isParameterFalse(final String name) { + return !getBooleanParameter(name, false); + } + +} // class AbstractHttpParams Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/AbstractHttpParams.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java?view=diff&rev=541912&r1=541911&r2=541912 ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java (original) +++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/BasicHttpParams.java Sat May 26 09:21:57 2007 @@ -44,21 +44,22 @@ * If a particular parameter value has not been explicitly defined * in the collection itself, its value will be drawn from the parent * collection of parameters. + *
+ * WARNING: Handling of default parameters is currently + * subject to discussions, and may be changed signifcantly. * * @author Oleg Kalnichevski * * @version $Revision$ */ -public class BasicHttpParams implements HttpParams, Serializable { +public class BasicHttpParams extends AbstractHttpParams + implements HttpParams, Serializable { - static final long serialVersionUID = -8296449161405728403L; - - /** The set of default values to defer to. */ - private HttpParams defaults = null; + static final long serialVersionUID = 4571099216197814749L; /** Map of HTTP parameters that this collection contains. */ - private HashMap parameters = null; - + private HashMap parameters; + /** * Creates a new collection of parameters with the given parent. * The collection will defer to its parent for a default value @@ -72,32 +73,11 @@ super(); setDefaults(defaults); // perform ancestor check } - + public BasicHttpParams() { this(null); } - public synchronized HttpParams getDefaults() { - return this.defaults; - } - - public synchronized void setDefaults(final HttpParams params) { - - // check we're not becoming our own defaults, directly or indirectly - // that would trigger an endless loop when looking up an unknown param - HttpParams ancestor = params; - while (ancestor != null) { - // check for object identity, not .equals - if (ancestor == this) { - throw new IllegalArgumentException - ("cyclic default params detected"); - } - ancestor = ancestor.getDefaults(); - } - - this.defaults = params; - } - public synchronized Object getParameter(final String name) { // See if the parameter has been explicitly defined Object param = null; @@ -139,58 +119,6 @@ } } - public long getLongParameter(final String name, long defaultValue) { - Object param = getParameter(name); - if (param == null) { - return defaultValue; - } - return ((Long)param).longValue(); - } - - public HttpParams setLongParameter(final String name, long value) { - setParameter(name, new Long(value)); - return this; - } - - public int getIntParameter(final String name, int defaultValue) { - Object param = getParameter(name); - if (param == null) { - return defaultValue; - } - return ((Integer)param).intValue(); - } - - public HttpParams setIntParameter(final String name, int value) { - setParameter(name, new Integer(value)); - return this; - } - - public double getDoubleParameter(final String name, double defaultValue) { - Object param = getParameter(name); - if (param == null) { - return defaultValue; - } - return ((Double)param).doubleValue(); - } - - public HttpParams setDoubleParameter(final String name, double value) { - setParameter(name, new Double(value)); - return this; - } - - public boolean getBooleanParameter(final String name, boolean defaultValue) { - Object param = getParameter(name); - if (param == null) { - return defaultValue; - } - return ((Boolean)param).booleanValue(); - } - - public HttpParams setBooleanParameter(final String name, boolean value) { - setParameter(name, value ? Boolean.TRUE : Boolean.FALSE); - return this; - } - public boolean isParameterSet(final String name) { return getParameter(name) != null; } @@ -199,16 +127,8 @@ return this.parameters != null && this.parameters.get(name) != null; } - public boolean isParameterTrue(final String name) { - return getBooleanParameter(name, false); - } - - public boolean isParameterFalse(final String name) { - return !getBooleanParameter(name, false); - } - /** - * Removes all parameters from this collection. + * Removes all parameters from this collection. */ public synchronized void clear() { this.parameters = null; @@ -241,7 +161,7 @@ * Copies the locally defined parameters to the argument parameters. * Default parameters accessible via {@link #getDefaults} * are not copied. - * This method is called from {@link #copyParams()}. + * This method is called from {@link #copy()}. * * @param target the parameters to which to copy */ Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java?view=diff&rev=541912&r1=541911&r2=541912 ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java (original) +++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/params/HttpParams.java Sat May 26 09:21:57 2007 @@ -33,10 +33,12 @@ /** * Represents a collection of HTTP protocol and framework parameters. - * Parameters may be linked together to form a hierarchy. - * If a particular parameter value has not been explicitly defined - * in the collection itself, its value will be drawn from the parent - * collection of parameters. + *
+ * WARNING: This interface includes methods for building hierarchies of + * parameters. These methods are clearly marked as not part of the API. + * The handling of default parameters is currently subject to discussions and + * may be changed signifcantly, or removed. Do not try to evaluate, build or + * modify parameter hierarchies in your application. * * @author Oleg Kalnichevski * @@ -46,25 +48,33 @@ */ public interface HttpParams { - /** - * Returns the parent collection that this collection will defer to - * for a default value if a particular parameter is not explicitly - * set in the collection itself + /** + * WARNING: This method is not part of the API. + * It is exclusively for internal use by the HTTP Components framework. + * Do not call it in your application. Do not try to evaluate, build or + * modify parameter hierarchies in your application. + *
+ * + * Returns the parent collection that the collection may defer to + * for a default value if a particular parameter is not explicitly set. * - * @return the parent collection to defer to, if a particular parameter - * is not explictly set in the collection itself. + * @return the parent collection, or null * * @see #setDefaults(HttpParams) */ HttpParams getDefaults(); /** - * Assigns the parent collection that this collection will defer to - * for a default value if a particular parameter is not explicitly - * set in the collection itself + * WARNING: This method is not part of the API. + * It is exclusively for internal use by the HTTP Components framework. + * Do not call it in your application. Do not try to evaluate, build or + * modify parameter hierarchies in your application. + *
+ * + * Provides the parent collection that this collection may defer to + * for a default value if a particular parameter is not explicitly set. * - * @param params the parent collection to defer to, if a particular - * parameter is not explictly set in the collection itself. + * @param params the parent collection, or null * * @see #getDefaults() */ @@ -207,14 +217,22 @@ boolean isParameterSet(String name); /** - * Returns true if the parameter is set locally, false otherwise. + * WARNING: This method is not part of the API. + * It is exclusively for internal use by the HTTP Components framework. + * Do not call it in your application. Do not try to evaluate, build or + * modify parameter hierarchies in your application. + *
* - * @param name parameter name + * @param name the parameter name * - * @return true if the parameter is set locally, false - * otherwise. + * @return true if the parameter is set locally, + * false otherwise + * + * @see #getDefaults() + * @see #setDefaults(HttpParams) */ boolean isParameterSetLocally(String name); + /** * Returns true if the parameter is set and is true, false