Return-Path: Delivered-To: apmail-jakarta-httpclient-commits-archive@www.apache.org Received: (qmail 19328 invoked from network); 29 Jun 2006 18:06:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Jun 2006 18:06:34 -0000 Received: (qmail 80506 invoked by uid 500); 29 Jun 2006 18:06:33 -0000 Mailing-List: contact httpclient-commits-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: httpclient-dev@jakarta.apache.org Delivered-To: mailing list httpclient-commits@jakarta.apache.org Received: (qmail 80495 invoked by uid 99); 29 Jun 2006 18:06:33 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jun 2006 11:06:33 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Jun 2006 11:06:32 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 7BB9C1A983A; Thu, 29 Jun 2006 11:06:12 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r418102 - /jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/cookie/Cookie.java Date: Thu, 29 Jun 2006 18:06:12 -0000 To: httpclient-commits@jakarta.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060629180612.7BB9C1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: olegk Date: Thu Jun 29 11:06:11 2006 New Revision: 418102 URL: http://svn.apache.org/viewvc?rev=418102&view=rev Log: * Cookie is no longer a subclass of NameValuePair * Removed #equals and #hashCode methods. The concept of identity equality and value equality of cookies is domain specific. It should be addressed at the application level Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/cookie/Cookie.java Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/cookie/Cookie.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/cookie/Cookie.java?rev=418102&r1=418101&r2=418102&view=diff ============================================================================== --- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/cookie/Cookie.java (original) +++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/cookie/Cookie.java Thu Jun 29 11:06:11 2006 @@ -31,9 +31,6 @@ import java.util.Date; -import org.apache.http.NameValuePair; -import org.apache.http.util.LangUtils; - /** *

* HTTP "magic-cookie" represents a piece of state information @@ -54,13 +51,39 @@ * * @version $Revision$ */ -public class Cookie extends NameValuePair { +public class Cookie { /** - * Default constructor. Creates a blank cookie + * Default Constructor taking a name and a value. The value may be null. + * + * @param name The name. + * @param value The value. */ public Cookie(final String name, final String value) { - super(name, value); + super(); + if (name == null) { + throw new IllegalArgumentException("Name may not be null"); + } + this.name = name; + this.value = value; + } + + /** + * 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; } /** @@ -150,10 +173,6 @@ */ public void setDomain(String domain) { if (domain != null) { - int ndx = domain.indexOf(":"); - if (ndx != -1) { - domain = domain.substring(0, ndx); - } cookieDomain = domain.toLowerCase(); } else { cookieDomain = null; @@ -303,39 +322,10 @@ return hasDomainAttribute; } - /** - * Returns a hash code in keeping with the - * {@link Object#hashCode} general hashCode contract. - * @return A hash code - */ - public int hashCode() { - int hash = LangUtils.HASH_SEED; - hash = LangUtils.hashCode(hash, this.getName()); - hash = LangUtils.hashCode(hash, this.cookieDomain); - hash = LangUtils.hashCode(hash, this.cookiePath); - return hash; - } - - - /** - * Two cookies are equal if the name, path and domain match. - * @param obj The object to compare against. - * @return true if the two objects are equal. - */ - public boolean equals(Object obj) { - if (obj == null) return false; - if (this == obj) return true; - if (obj instanceof Cookie) { - Cookie that = (Cookie) obj; - return LangUtils.equals(this.getName(), that.getName()) - && LangUtils.equals(this.cookieDomain, that.cookieDomain) - && LangUtils.equals(this.cookiePath, that.cookiePath); - } else { - return false; - } - } - // ----------------------------------------------------- Instance Variables + + private final String name; + private final String value; /** Comment attribute. */ private String cookieComment;