hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
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 GMT
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
+ * <http://www.apache.org/>.
+ *
+ */
+
+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 <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
+ * 
+ * @version $Revision$
+ */
+public abstract class AbstractHttpParams implements HttpParams {
+
+    /**
+     * The optional set of default values to defer to.
+     * <br/>
+     * <b>WARNING:</b> 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.
+     * <br/>
+     * <b>WARNING:</b> Handling of default parameters is currently
+     * subject to discussions, and may be changed signifcantly.
+     *
+     * @return  the defaults, or <code>null</code>
+     */
+    public synchronized HttpParams getDefaults() {
+        return this.defaults;
+    }
+    
+    /**
+     * Provides default parameters.
+     * <br/>
+     * <b>WARNING:</b> Handling of default parameters is currently
+     * subject to discussions, and may be changed signifcantly.
+     *
+     * @param params    the new defaults, or <code>null</code> 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.
+ * <br/>
+ * <b>WARNING:</b> Handling of default parameters is currently
+ * subject to discussions, and may be changed signifcantly.
  * 
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
  * @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 <i>not</i> 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.
+ * <br/>
+ * <b>WARNING:</b> This interface includes methods for building hierarchies of
+ * parameters. These methods are clearly marked as <i>not part of the API</i>.
+ * 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 <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
@@ -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
+    /**
+     * <b>WARNING:</b> 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.
+     * <br/>
+     *
+     * 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 <code>null</code>
      * 
      * @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
+     * <b>WARNING:</b> 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.
+     * <br/>
+     *
+     * 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 <code>null</code>
      * 
      * @see #getDefaults()
      */
@@ -207,14 +217,22 @@
     boolean isParameterSet(String name);
         
     /**
-     * Returns <tt>true</tt> if the parameter is set locally, <tt>false</tt>
otherwise.
+     * <b>WARNING:</b> 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.
+     * <br/>
      * 
-     * @param name parameter name
+     * @param name      the parameter name
      * 
-     * @return <tt>true</tt> if the parameter is set locally, <tt>false</tt>
-     * otherwise.
+     * @return  <tt>true</tt> if the parameter is set locally,
+     *          <tt>false</tt> otherwise
+     *
+     * @see #getDefaults()
+     * @see #setDefaults(HttpParams)
      */
     boolean isParameterSetLocally(String name);
+
         
     /**
      * Returns <tt>true</tt> if the parameter is set and is <tt>true</tt>,
<tt>false</tt>



Mime
View raw message