hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r157296 - in jakarta/httpclient/trunk/http-common/src: java/org/apache/http/HeaderElement.java test/org/apache/http/TestHeaderElement.java
Date Sat, 12 Mar 2005 23:12:17 GMT
Author: olegk
Date: Sat Mar 12 15:12:15 2005
New Revision: 157296

URL: http://svn.apache.org/viewcvs?view=rev&rev=157296
Log:
Added HeaderElement#toString method

Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HeaderElement.java
    jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHeaderElement.java

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HeaderElement.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HeaderElement.java?view=diff&r1=157295&r2=157296
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HeaderElement.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HeaderElement.java Sat Mar
12 15:12:15 2005
@@ -295,6 +295,19 @@
         return hash;
     }
     
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        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();
+    }
     
 }
 

Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHeaderElement.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHeaderElement.java?view=diff&r1=157295&r2=157296
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHeaderElement.java (original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/TestHeaderElement.java Sat
Mar 12 15:12:15 2005
@@ -226,4 +226,13 @@
         assertFalse(element1.equals("name = value; param1 = value1; param2 = value2"));
     }
     
+    public void testToString() {
+        String s = "name = value; param1 = value1; param2 = value2";
+        HeaderElement element = new HeaderElement(s.toCharArray());
+        assertEquals(s, element.toString());
+        s = "name; param1 = value1; param2 = value2";
+        element = new HeaderElement(s.toCharArray());
+        assertEquals(s, element.toString());
+    }
+    
 }



Mime
View raw message