You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by se...@apache.org on 2010/12/14 23:18:41 UTC

svn commit: r1049308 - in /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params: AbstractHttpParams.java BasicHttpParams.java DefaultedHttpParams.java HttpParamsSet.java

Author: sebb
Date: Tue Dec 14 22:18:40 2010
New Revision: 1049308

URL: http://svn.apache.org/viewvc?rev=1049308&view=rev
Log:
Re-implement using HttpParamsSet interface

Added:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java   (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java?rev=1049308&r1=1049307&r2=1049308&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/AbstractHttpParams.java Tue Dec 14 22:18:40 2010
@@ -39,7 +39,7 @@ import org.apache.http.params.HttpParams
  *
  * @since 4.0
  */
-public abstract class AbstractHttpParams implements HttpParams {
+public abstract class AbstractHttpParams implements HttpParams, HttpParamsSet {
 
     /**
      * Instantiates parameters.
@@ -110,10 +110,11 @@ public abstract class AbstractHttpParams
 
 
     /**
-     * Provide access to the set of parameters as Map.Entry elements.
+     * Provide read-only access to the set of parameters as Map.Entry elements.
      * Must be overridden by subclasses.
      * @return the Set of Map.Entry<String, Object> elements
      * @since 4.1.1
+     * @throws UnsupportedOperationException
      */
     public Set entrySet() {
         throw new UnsupportedOperationException();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java?rev=1049308&r1=1049307&r2=1049308&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java Tue Dec 14 22:18:40 2010
@@ -167,7 +167,7 @@ public class BasicHttpParams extends Abs
     }
 
     /**
-     * Provide access to the set of parameters as Map.Entry elements.
+     * Provide read-only access to the set of parameters as Map.Entry elements.
      * 
      * @return the Set of Map.Entry<String, Object> elements
      * @since 4.1.1

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java?rev=1049308&r1=1049307&r2=1049308&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/DefaultedHttpParams.java Tue Dec 14 22:18:40 2010
@@ -107,15 +107,18 @@ public final class DefaultedHttpParams e
     }
 
     /**
-     * Provide access to the set of local parameters as Map.Entry elements.
+     * Provide read-only access to the set of local parameters as Map.Entry elements.
      * To get the entrySet for the default parameters,
      * use {@code ((AbstractHttpParams) getDefaults()).entrySet()}
      * @return the Set of Map.Entry<String, Object> elements
      * @since 4.1.1
-     * @throws ClassCastException if local parameters cannot be cast to AbstractHttpParams
+     * @throws UnsupportedOperationException if local parameters does not implement HttpParamsSet
      */
     public Set entrySet() {
-        return ((AbstractHttpParams) local).entrySet();
+        if (local instanceof HttpParamsSet) {
+            return ((HttpParamsSet) local).entrySet();            
+        }
+        throw new UnsupportedOperationException();
     }
 
 }

Added: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java?rev=1049308&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java Tue Dec 14 22:18:40 2010
@@ -0,0 +1,50 @@
+/*
+ * ====================================================================
+ * 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 java.util.Set;
+
+/**
+ * Allow HttpParams to be treated as a read-only Set, 
+ * giving access to the size(), isEmpty() and iterator() methods.
+ *
+ * @see HttpParams
+ *
+ * @since 4.1.1
+ */
+public interface HttpParamsSet {
+
+    /**
+     * Provide read-only access to the set of parameters as Map.Entry elements.
+     * 
+     * @return the Set of Map.Entry<String, Object> elements
+     * @since 4.1.1
+     */
+    Set entrySet();
+    
+}

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpParamsSet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision