hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r418578 - in /jakarta/httpcomponents/httpcore/trunk/src: java/org/apache/http/ java/org/apache/http/message/ java/org/apache/http/util/ test/org/apache/http/
Date Sun, 02 Jul 2006 11:34:44 GMT
Author: olegk
Date: Sun Jul  2 04:34:43 2006
New Revision: 418578

URL: http://svn.apache.org/viewvc?rev=418578&view=rev
Log:
[HTTPCORE-5] Made HeaderElement an interface

Added:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java
      - copied, changed from r418575, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeader.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java?rev=418578&r1=418577&r2=418578&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java Sun
Jul  2 04:34:43 2006
@@ -29,12 +29,6 @@
 
 package org.apache.http;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.io.CharArrayBuffer;
-import org.apache.http.util.LangUtils;
-
 /**
  * <p>One element of an HTTP header's value.</p>
  * <p>
@@ -77,312 +71,20 @@
  * @author <a href="mailto:bcholmes@interlog.com">B.C. Holmes</a>
  * @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
- * @author <a href="mailto:oleg at ural.com">Oleg Kalnichevski</a>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
  * @since 1.0
  * @version $Revision$ $Date$
  */
-public class HeaderElement {
-
-    private final String name;
-    private final String value;
-    private final NameValuePair[] parameters;
-
-    private HeaderElement(final NameValuePair[] nvps) {
-        super();
-        if (nvps.length > 0) {
-            NameValuePair nvp = nvps[0];
-            this.name = nvp.getName();
-            this.value = nvp.getValue();
-            int len = nvps.length - 1; 
-            if (len > 0) {
-                this.parameters = new NameValuePair[len];
-                System.arraycopy(nvps, 1, this.parameters, 0, len);
-            } else {
-                this.parameters = new NameValuePair[] {}; 
-            }
-        } else {
-            this.name = "";
-            this.value = null;
-            this.parameters = new NameValuePair[] {}; 
-        }
-    }
-    
-    /**
-     * Constructor with name, value and parameters.
-     *
-     * @param name header element name
-     * @param value header element value. May be <tt>null</tt>
-     * @param parameters header element parameters. May be <tt>null</tt>
-     */
-    public HeaderElement(
-            final String name, 
-            final String value,
-            final NameValuePair[] parameters) {
-        super();
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
-        this.name = name;
-        this.value = value;
-        if (parameters != null) {
-            this.parameters = (NameValuePair[])parameters.clone();
-        } else {
-            this.parameters = new NameValuePair[] {};
-        }
-    }
-
-    /**
-     * Constructor with name and value.
-     * 
-     * @param name header element name
-     * @param value header element value. May be <tt>null</tt>
-     */
-    public HeaderElement(final String name, final String value) {
-       this(name, value, null);
-    }
-
-    /**
-     * Returns the name.
-     *
-     * @return String name The name
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * Returns the value.
-     *
-     * @return String value The current value.
-     */
-    public String getValue() {
-        return this.value;
-    }
-
-    /**
-     * Get parameters, if any.
-     *
-     * @since 2.0
-     * @return parameters as an array of {@link NameValuePair}s
-     */
-    public NameValuePair[] getParameters() {
-        return (NameValuePair[])this.parameters.clone();
-    }
+public interface HeaderElement {
 
-    // --------------------------------------------------------- Public Methods
-
-    /**
-     * This parses the value part of a header. The result is an array of
-     * HeaderElement objects.
-     *
-     * @param buffer    the buffer from which to parse
-     * @param indexFrom where to start parsing in the buffer
-     * @param indexTo   where to stop parsing in the buffer
-     *
-     * @return array of {@link HeaderElement}s.
-     * 
-     * @since 3.0
-     */
-    public static final HeaderElement[] parseAll(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        List elements = new ArrayList(); 
-        int cur = indexFrom;
-        int from = indexFrom;
-        boolean qouted = false;
-        boolean escaped = false;
-        while (cur < indexTo) {
-            char ch = buffer.charAt(cur);
-            if (ch == '"' && !escaped) {
-                qouted = !qouted;
-            }
-            HeaderElement element = null;
-            if ((!qouted) && (ch == ',')) {
-                element = parse(buffer, from, cur);
-                from = cur + 1;
-            } else if (cur == indexTo - 1) {
-                element = parse(buffer, from, indexTo);
-            }
-            if (element != null && !(element.getName().equals("") && element.getValue()
== null)) {
-                elements.add(element);
-            }
-            if (escaped) {
-                escaped = false;
-            } else {
-                escaped = qouted && ch == '\\';
-            }
-            cur++;
-        }
-        return (HeaderElement[])
-            elements.toArray(new HeaderElement[elements.size()]);
-    }
-
-    /**
-     * This parses the value part of a header. The result is an array of
-     * HeaderElement objects.
-     *
-     * @param s  the string representation of the header value
-     *                     (as received from the web server).
-     * @return array of {@link HeaderElement}s.
-     * 
-     * @since 3.0
-     */
-    public static final HeaderElement[] parseAll(final String s) {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length()); 
-        buffer.append(s);
-        return parseAll(buffer, 0, buffer.length());
-    }
-
-    public static HeaderElement parse(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        NameValuePair[] nvps = NameValuePair.parseAll(buffer, indexFrom, indexTo);
-        return new HeaderElement(nvps);
-    }
-
-    public static final HeaderElement parse(final String s) {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length());
-        buffer.append(s);
-        return parse(buffer, 0, buffer.length());
-    }
-
-    public static void format(
-            final CharArrayBuffer buffer, 
-            final HeaderElement element) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (element == null) {
-            throw new IllegalArgumentException("Header element may not be null");
-        }
-        buffer.append(element.getName());
-        if (element.getValue() != null) {
-            buffer.append("=");
-            buffer.append(element.getValue());
-        }
-        NameValuePair[] params = element.getParameters();
-        for (int i = 0; i < params.length; i++) {
-            buffer.append("; ");
-            NameValuePair.format(buffer, params[i], false);
-        }
-    }
-    
-    public static String format(final HeaderElement element) {
-        CharArrayBuffer buffer = new CharArrayBuffer(32);
-        format(buffer, element);
-        return buffer.toString();
-    }
-    
-    public static void formatAll(
-            final CharArrayBuffer buffer, 
-            final HeaderElement[] elements) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (elements == null) {
-            throw new IllegalArgumentException("Array of header element may not be null");
-        }
-        for (int i = 0; i < elements.length; i++) {
-            if (i > 0) {
-                buffer.append(", ");
-            }
-            format(buffer, elements[i]);
-        }
-    }
-    
-    public static String formatAll(final HeaderElement[] elements) {
-        CharArrayBuffer buffer = new CharArrayBuffer(64);
-        formatAll(buffer, elements);
-        return buffer.toString();
-    }
-    
-    /**
-     * Returns parameter with the given name, if found. Otherwise null 
-     * is returned
-     *
-     * @param name The name to search by.
-     * @return NameValuePair parameter with the given name
-     */
-    public NameValuePair getParameterByName(final String name) {
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        } 
-        NameValuePair found = null;
-        for (int i = 0; i < this.parameters.length; i++) {
-            NameValuePair current = this.parameters[ i ];
-            if (current.getName().equalsIgnoreCase(name)) {
-                found = current;
-                break;
-            }
-        }
-        return found;
-    }
+    String getName();
 
-    public boolean equals(final Object object) {
-        if (object == null) return false;
-        if (this == object) return true;
-        if (object instanceof HeaderElement) {
-            HeaderElement that = (HeaderElement) object;
-            return this.name.equals(that.name)
-                && LangUtils.equals(this.value, that.value)
-                && LangUtils.equals(this.parameters, that.parameters);
-        } else {
-            return false;
-        }
-    }
+    String getValue();
 
-    public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.name);
-        hash = LangUtils.hashCode(hash, this.value);
-        for (int i = 0; i < this.parameters.length; i++) {
-            hash = LangUtils.hashCode(hash, this.parameters[i]);
-        }
-        return hash;
-    }
+    NameValuePair[] getParameters();
     
-    public String toString() {
-        CharArrayBuffer buffer = new CharArrayBuffer(64);
-        buffer.append(this.name);
-        if (this.value != null) {
-            buffer.append("=");
-            buffer.append(this.value);
-        }
-        for (int i = 0; i < this.parameters.length; i++) {
-            buffer.append("; ");
-            buffer.append(this.parameters[i]);
-        }
-        return buffer.toString();
-    }
+    NameValuePair getParameterByName(String name);
     
 }
 

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeader.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeader.java?rev=418578&r1=418577&r2=418578&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeader.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeader.java
Sun Jul  2 04:34:43 2006
@@ -127,7 +127,7 @@
      */
     public HeaderElement[] getElements() {
         if (this.value != null) {
-            return HeaderElement.parseAll(this.value);
+            return BasicHeaderElement.parseAll(this.value);
         } else {
             return new HeaderElement[] {}; 
         }

Copied: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java
(from r418575, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java?p2=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java&p1=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java&r1=418575&r2=418578&rev=418578&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HeaderElement.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java
Sun Jul  2 04:34:43 2006
@@ -27,11 +27,13 @@
  *
  */
 
-package org.apache.http;
+package org.apache.http.message;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.http.HeaderElement;
+import org.apache.http.NameValuePair;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.util.LangUtils;
 
@@ -82,13 +84,13 @@
  * @since 1.0
  * @version $Revision$ $Date$
  */
-public class HeaderElement {
+public class BasicHeaderElement implements HeaderElement {
 
     private final String name;
     private final String value;
     private final NameValuePair[] parameters;
 
-    private HeaderElement(final NameValuePair[] nvps) {
+    private BasicHeaderElement(final NameValuePair[] nvps) {
         super();
         if (nvps.length > 0) {
             NameValuePair nvp = nvps[0];
@@ -115,7 +117,7 @@
      * @param value header element value. May be <tt>null</tt>
      * @param parameters header element parameters. May be <tt>null</tt>
      */
-    public HeaderElement(
+    public BasicHeaderElement(
             final String name, 
             final String value,
             final NameValuePair[] parameters) {
@@ -138,7 +140,7 @@
      * @param name header element name
      * @param value header element value. May be <tt>null</tt>
      */
-    public HeaderElement(final String name, final String value) {
+    public BasicHeaderElement(final String name, final String value) {
        this(name, value, null);
     }
 
@@ -263,7 +265,7 @@
             throw new IndexOutOfBoundsException();
         }
         NameValuePair[] nvps = NameValuePair.parseAll(buffer, indexFrom, indexTo);
-        return new HeaderElement(nvps);
+        return new BasicHeaderElement(nvps);
     }
 
     public static final HeaderElement parse(final String s) {
@@ -351,7 +353,7 @@
         if (object == null) return false;
         if (this == object) return true;
         if (object instanceof HeaderElement) {
-            HeaderElement that = (HeaderElement) object;
+            BasicHeaderElement that = (BasicHeaderElement) object;
             return this.name.equals(that.name)
                 && LangUtils.equals(this.value, that.value)
                 && LangUtils.equals(this.parameters, that.parameters);

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java?rev=418578&r1=418577&r2=418578&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/util/HeaderUtils.java Sun
Jul  2 04:34:43 2006
@@ -38,6 +38,7 @@
 import org.apache.http.ProtocolException;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.io.HttpDataReceiver;
+import org.apache.http.message.BasicHeaderElement;
 
 /**
  * A utility class for processing HTTP headers.
@@ -75,7 +76,7 @@
         }
         
         public HeaderElement[] getElements() {
-            return HeaderElement.parseAll(this.buffer, this.posValue, this.buffer.length());
+            return BasicHeaderElement.parseAll(this.buffer, this.posValue, this.buffer.length());
         }
         
         public String toString() {

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java?rev=418578&r1=418577&r2=418578&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java
Sun Jul  2 04:34:43 2006
@@ -31,6 +31,7 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.message.BasicHeaderElement;
 
 import junit.framework.*;
 
@@ -63,7 +64,7 @@
     }
 
     public void testConstructor() throws Exception {
-        HeaderElement element = new HeaderElement("name", "value", 
+        HeaderElement element = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param1", "value1"),
                     new NameValuePair("param2", "value2")
@@ -76,7 +77,7 @@
     }
 
     public void testConstructor2() throws Exception {
-        HeaderElement element = new HeaderElement("name", "value");
+        HeaderElement element = new BasicHeaderElement("name", "value");
         assertEquals("name", element.getName());
         assertEquals("value", element.getValue());
         assertEquals(0, element.getParameters().length);
@@ -84,7 +85,7 @@
 
     public void testCharArrayConstructor() throws Exception {
         String s = "name = value; param1 = value1";
-        HeaderElement element = HeaderElement.parse(s); 
+        HeaderElement element = BasicHeaderElement.parse(s); 
         assertEquals("name", element.getName());
         assertEquals("value", element.getValue());
         assertEquals(1, element.getParameters().length);
@@ -93,7 +94,7 @@
     
     public void testInvalidName() {
         try {
-            new HeaderElement(null, null, null); 
+            new BasicHeaderElement(null, null, null); 
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             //expected
@@ -103,7 +104,7 @@
     public void testParseHeaderElements() throws Exception {
         String headerValue = "name1 = value1; name2; name3=\"value3\" , name4=value4; " +
             "name5=value5, name6= ; name7 = value7; name8 = \" value8\"";
-        HeaderElement[] elements = HeaderElement.parseAll(headerValue);
+        HeaderElement[] elements = BasicHeaderElement.parseAll(headerValue);
         // there are 3 elements
         assertEquals(3,elements.length);
         // 1st element
@@ -136,7 +137,7 @@
     public void testParseEscaped() {
         String s = 
           "test1 =  \"\\\"stuff\\\"\", test2= \"\\\\\", test3 = \"stuff, stuff\"";
-        HeaderElement[] elements = HeaderElement.parseAll(s);
+        HeaderElement[] elements = BasicHeaderElement.parseAll(s);
         assertEquals(3, elements.length);
         assertEquals("test1", elements[0].getName());
         assertEquals("\\\"stuff\\\"", elements[0].getValue());
@@ -148,19 +149,19 @@
 
     public void testFringeCase1() throws Exception {
         String headerValue = "name1 = value1,";
-        HeaderElement[] elements = HeaderElement.parseAll(headerValue);
+        HeaderElement[] elements = BasicHeaderElement.parseAll(headerValue);
         assertEquals("Number of elements", 1, elements.length);
     }
 
     public void testFringeCase2() throws Exception {
         String headerValue = "name1 = value1, ";
-        HeaderElement[] elements = HeaderElement.parseAll(headerValue);
+        HeaderElement[] elements = BasicHeaderElement.parseAll(headerValue);
         assertEquals("Number of elements", 1, elements.length);
     }
 
     public void testFringeCase3() throws Exception {
         String headerValue = ",, ,, ,";
-        HeaderElement[] elements = HeaderElement.parseAll(headerValue);
+        HeaderElement[] elements = BasicHeaderElement.parseAll(headerValue);
         assertEquals("Number of elements", 0, elements.length);
     }
 
@@ -168,61 +169,61 @@
         CharArrayBuffer buffer = new CharArrayBuffer(32);
         buffer.append("name = value");
         try {
-            HeaderElement.parseAll(null, 0, 0);
+            BasicHeaderElement.parseAll(null, 0, 0);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.parseAll(null);
+            BasicHeaderElement.parseAll(null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.parseAll(buffer, -1, 0);
+            BasicHeaderElement.parseAll(buffer, -1, 0);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HeaderElement.parseAll(buffer, 0, 1000);
+            BasicHeaderElement.parseAll(buffer, 0, 1000);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HeaderElement.parseAll(buffer, 2, 1);
+            BasicHeaderElement.parseAll(buffer, 2, 1);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HeaderElement.parse(null, 0, 0);
+            BasicHeaderElement.parse(null, 0, 0);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.parse(null);
+            BasicHeaderElement.parse(null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.parse(buffer, -1, 0);
+            BasicHeaderElement.parse(buffer, -1, 0);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HeaderElement.parse(buffer, 0, 1000);
+            BasicHeaderElement.parse(buffer, 0, 1000);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HeaderElement.parse(buffer, 2, 1);
+            BasicHeaderElement.parse(buffer, 2, 1);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
@@ -231,7 +232,7 @@
     
     public void testParamByName() throws Exception {
         String s = "name = value; param1 = value1; param2 = value2";
-        HeaderElement element = HeaderElement.parse(s); 
+        HeaderElement element = BasicHeaderElement.parse(s); 
         assertEquals("value1", element.getParameterByName("param1").getValue());
         assertEquals("value2", element.getParameterByName("param2").getValue());
         assertNull(element.getParameterByName("param3"));
@@ -244,19 +245,19 @@
     }
 
     public void testHashCode() {
-        HeaderElement element1 = new HeaderElement("name", "value", 
+        HeaderElement element1 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param1", "value1"),
                     new NameValuePair("param2", "value2")
                 } );
-        HeaderElement element2 = new HeaderElement("name", "value", 
+        HeaderElement element2 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param2", "value2"),
                     new NameValuePair("param1", "value1")
                 } );
-        HeaderElement element3 = new HeaderElement("name", "value"); 
-        HeaderElement element4 = new HeaderElement("name", "value"); 
-        HeaderElement element5 = new HeaderElement("name", "value", 
+        HeaderElement element3 = new BasicHeaderElement("name", "value"); 
+        HeaderElement element4 = new BasicHeaderElement("name", "value"); 
+        HeaderElement element5 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param1", "value1"),
                     new NameValuePair("param2", "value2")
@@ -269,19 +270,19 @@
     }
     
     public void testEquals() {
-        HeaderElement element1 = new HeaderElement("name", "value", 
+        HeaderElement element1 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param1", "value1"),
                     new NameValuePair("param2", "value2")
                 } );
-        HeaderElement element2 = new HeaderElement("name", "value", 
+        HeaderElement element2 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param2", "value2"),
                     new NameValuePair("param1", "value1")
                 } );
-        HeaderElement element3 = new HeaderElement("name", "value"); 
-        HeaderElement element4 = new HeaderElement("name", "value"); 
-        HeaderElement element5 = new HeaderElement("name", "value", 
+        HeaderElement element3 = new BasicHeaderElement("name", "value"); 
+        HeaderElement element4 = new BasicHeaderElement("name", "value"); 
+        HeaderElement element5 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
                     new NameValuePair("param1", "value1"),
                     new NameValuePair("param2", "value2")
@@ -298,10 +299,10 @@
     
     public void testToString() {
         String s = "name=value; param1=value1; param2=value2";
-        HeaderElement element = HeaderElement.parse(s);
+        HeaderElement element = BasicHeaderElement.parse(s);
         assertEquals(s, element.toString());
         s = "name; param1=value1; param2=value2";
-        element = HeaderElement.parse(s);
+        element = BasicHeaderElement.parse(s);
         assertEquals(s, element.toString());
     }
     
@@ -311,10 +312,10 @@
         NameValuePair param3 = new NameValuePair("param", "this,that");
         NameValuePair param4 = new NameValuePair("param", null);
         NameValuePair[] params = new NameValuePair[] {param1, param2, param3, param4};
-        HeaderElement element = new HeaderElement("name", "value", params); 
+        HeaderElement element = new BasicHeaderElement("name", "value", params); 
         
         assertEquals("name=value; param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\";
param", 
-                HeaderElement.format(element));
+                BasicHeaderElement.format(element));
     }
     
     public void testElementArrayFormatting() throws Exception {
@@ -322,40 +323,40 @@
         NameValuePair param2 = new NameValuePair("param", "this\\that"); 
         NameValuePair param3 = new NameValuePair("param", "this,that");
         NameValuePair param4 = new NameValuePair("param", null);
-        HeaderElement element1 = new HeaderElement("name1", "value1", new NameValuePair[]
{param1}); 
-        HeaderElement element2 = new HeaderElement("name2", "value2", new NameValuePair[]
{param2}); 
-        HeaderElement element3 = new HeaderElement("name3", "value3", new NameValuePair[]
{param3}); 
-        HeaderElement element4 = new HeaderElement("name4", "value4", new NameValuePair[]
{param4}); 
-        HeaderElement element5 = new HeaderElement("name5", null); 
+        HeaderElement element1 = new BasicHeaderElement("name1", "value1", new NameValuePair[]
{param1}); 
+        HeaderElement element2 = new BasicHeaderElement("name2", "value2", new NameValuePair[]
{param2}); 
+        HeaderElement element3 = new BasicHeaderElement("name3", "value3", new NameValuePair[]
{param3}); 
+        HeaderElement element4 = new BasicHeaderElement("name4", "value4", new NameValuePair[]
{param4}); 
+        HeaderElement element5 = new BasicHeaderElement("name5", null); 
         HeaderElement[] elements = new HeaderElement[] {element1, element2, element3, element4,
element5}; 
         
         assertEquals("name1=value1; param=regular_stuff, name2=value2; " +
                 "param=\"this\\\\that\", name3=value3; param=\"this,that\", " +
                 "name4=value4; param, name5", 
-                HeaderElement.formatAll(elements));
+                BasicHeaderElement.formatAll(elements));
     }
     
     public void testFormatInvalidInput() throws Exception {
         try {
-            HeaderElement.format(null, new HeaderElement("name1", "value1"));
+            BasicHeaderElement.format(null, new BasicHeaderElement("name1", "value1"));
             fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.format(new CharArrayBuffer(10), (HeaderElement) null);
+            BasicHeaderElement.format(new CharArrayBuffer(10), (HeaderElement) null);
             fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.formatAll(null, new HeaderElement[] {new HeaderElement("name1",
"value1")});
+            BasicHeaderElement.formatAll(null, new HeaderElement[] {new BasicHeaderElement("name1",
"value1")});
             fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HeaderElement.formatAll(new CharArrayBuffer(10), (HeaderElement[]) null);
+            BasicHeaderElement.formatAll(new CharArrayBuffer(10), (HeaderElement[]) null);
             fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected



Mime
View raw message