Class Cookie

java.lang.Object
jakarta.ws.rs.core.Cookie
Direct Known Subclasses:
NewCookie

public class Cookie
extends Object
Represents the value of a HTTP cookie, transferred in a request. RFC 2109 specifies the legal characters for name, value, path and domain. The default version of 1 corresponds to RFC 2109.
Since:
1.0
Author:
Paul Sandoz, Marc Hadley
See Also:
IETF RFC 2109
  • Field Details

  • Constructor Details

  • Method Details

    • valueOf

      @Deprecated public static Cookie valueOf​(String value)
      Deprecated.
      This method will be removed in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(Cookie.class).fromString(value) instead.
      Creates a new instance of Cookie by parsing the supplied string.
      Parameters:
      value - the cookie string.
      Returns:
      the newly created Cookie.
      Throws:
      IllegalArgumentException - if the supplied string cannot be parsed or is null.
    • getName

      public String getName()
      Get the name of the cookie.
      Returns:
      the cookie name.
    • getValue

      public String getValue()
      Get the value of the cookie.
      Returns:
      the cookie value.
    • getVersion

      public int getVersion()
      Get the version of the cookie.
      Returns:
      the cookie version.
    • getDomain

      public String getDomain()
      Get the domain of the cookie.
      Returns:
      the cookie domain.
    • getPath

      public String getPath()
      Get the path of the cookie.
      Returns:
      the cookie path.
    • toString

      @Deprecated public String toString()
      Deprecated.
      The format of the toString() method is subject to change in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(Cookie.class).toString(value) instead if you rely on the format of this method.
      Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.
      Overrides:
      toString in class Object
      Returns:
      a stringified cookie.
    • hashCode

      public int hashCode()
      Generate a hash code by hashing all of the cookies properties.
      Overrides:
      hashCode in class Object
      Returns:
      the cookie hash code.
    • equals

      public boolean equals​(Object obj)
      Compare for equality.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare to.
      Returns:
      true, if the object is a Cookie with the same value for all properties, false otherwise.