Class DefaultCookie

java.lang.Object
io.netty.handler.codec.http.cookie.DefaultCookie
All Implemented Interfaces:
Cookie, java.lang.Comparable<Cookie>
Direct Known Subclasses:
DefaultCookie

public class DefaultCookie extends java.lang.Object implements Cookie
The default Cookie implementation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private java.lang.String
     
    private boolean
     
    private long
     
    private final java.lang.String
     
    private boolean
     
    private java.lang.String
     
     
    private boolean
     
    private java.lang.String
     
    private boolean
     

    Fields inherited from interface Cookie

    UNDEFINED_MAX_AGE
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultCookie(java.lang.String name, java.lang.String value)
    Creates a new cookie with the specified name and value.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    java.lang.String
    Returns the domain of this Cookie.
    boolean
    equals(java.lang.Object o)
     
    int
     
    boolean
    Checks to see if this Cookie can only be accessed via HTTP.
    boolean
    Checks to see if this Cookie is partitioned
    boolean
    Checks to see if this Cookie is secure
    long
    Returns the maximum age of this Cookie in seconds or Cookie.UNDEFINED_MAX_AGE if unspecified
    java.lang.String
    Returns the name of this Cookie.
    java.lang.String
    Returns the path of this Cookie.
    Checks to see if this Cookie can be sent along cross-site requests.
    void
    setDomain(java.lang.String domain)
    Sets the domain of this Cookie.
    void
    setHttpOnly(boolean httpOnly)
    Determines if this Cookie is HTTP only.
    void
    setMaxAge(long maxAge)
    Sets the maximum age of this Cookie in seconds.
    void
    setPartitioned(boolean partitioned)
    Sets the Partitioned attribute of this Cookie
    void
    setPath(java.lang.String path)
    Sets the path of this Cookie.
    void
    Determines if this this Cookie can be sent along cross-site requests.
    void
    setSecure(boolean secure)
    Sets the security getStatus of this Cookie
    void
    setValue(java.lang.String value)
    Sets the value of this Cookie.
    void
    setWrap(boolean wrap)
    Sets true if the value of this Cookie is to be wrapped with double quotes.
    java.lang.String
     
    protected java.lang.String
    validateValue(java.lang.String name, java.lang.String value)
    Deprecated.
    CookieUtil is package private, will be removed once old Cookie API is dropped
    java.lang.String
    Returns the value of this Cookie.
    boolean
    Returns true if the raw value of this Cookie, was wrapped with double quotes in original Set-Cookie header.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      private final java.lang.String name
    • value

      private java.lang.String value
    • wrap

      private boolean wrap
    • domain

      private java.lang.String domain
    • path

      private java.lang.String path
    • maxAge

      private long maxAge
    • secure

      private boolean secure
    • httpOnly

      private boolean httpOnly
    • sameSite

      private CookieHeaderNames.SameSite sameSite
    • partitioned

      private boolean partitioned
  • Constructor Details

    • DefaultCookie

      public DefaultCookie(java.lang.String name, java.lang.String value)
      Creates a new cookie with the specified name and value.
  • Method Details

    • name

      public java.lang.String name()
      Description copied from interface: Cookie
      Returns the name of this Cookie.
      Specified by:
      name in interface Cookie
      Returns:
      The name of this Cookie
    • value

      public java.lang.String value()
      Description copied from interface: Cookie
      Returns the value of this Cookie.
      Specified by:
      value in interface Cookie
      Returns:
      The value of this Cookie
    • setValue

      public void setValue(java.lang.String value)
      Description copied from interface: Cookie
      Sets the value of this Cookie.
      Specified by:
      setValue in interface Cookie
      Parameters:
      value - The value to set
    • wrap

      public boolean wrap()
      Description copied from interface: Cookie
      Returns true if the raw value of this Cookie, was wrapped with double quotes in original Set-Cookie header.
      Specified by:
      wrap in interface Cookie
      Returns:
      If the value of this Cookie is to be wrapped
    • setWrap

      public void setWrap(boolean wrap)
      Description copied from interface: Cookie
      Sets true if the value of this Cookie is to be wrapped with double quotes.
      Specified by:
      setWrap in interface Cookie
      Parameters:
      wrap - true if wrap
    • domain

      public java.lang.String domain()
      Description copied from interface: Cookie
      Returns the domain of this Cookie.
      Specified by:
      domain in interface Cookie
      Returns:
      The domain of this Cookie
    • setDomain

      public void setDomain(java.lang.String domain)
      Description copied from interface: Cookie
      Sets the domain of this Cookie.
      Specified by:
      setDomain in interface Cookie
      Parameters:
      domain - The domain to use
    • path

      public java.lang.String path()
      Description copied from interface: Cookie
      Returns the path of this Cookie.
      Specified by:
      path in interface Cookie
      Returns:
      The Cookie's path
    • setPath

      public void setPath(java.lang.String path)
      Description copied from interface: Cookie
      Sets the path of this Cookie.
      Specified by:
      setPath in interface Cookie
      Parameters:
      path - The path to use for this Cookie
    • maxAge

      public long maxAge()
      Description copied from interface: Cookie
      Returns the maximum age of this Cookie in seconds or Cookie.UNDEFINED_MAX_AGE if unspecified
      Specified by:
      maxAge in interface Cookie
      Returns:
      The maximum age of this Cookie
    • setMaxAge

      public void setMaxAge(long maxAge)
      Description copied from interface: Cookie
      Sets the maximum age of this Cookie in seconds. If an age of 0 is specified, this Cookie will be automatically removed by browser because it will expire immediately. If Cookie.UNDEFINED_MAX_AGE is specified, this Cookie will be removed when the browser is closed.
      Specified by:
      setMaxAge in interface Cookie
      Parameters:
      maxAge - The maximum age of this Cookie in seconds
    • isSecure

      public boolean isSecure()
      Description copied from interface: Cookie
      Checks to see if this Cookie is secure
      Specified by:
      isSecure in interface Cookie
      Returns:
      True if this Cookie is secure, otherwise false
    • setSecure

      public void setSecure(boolean secure)
      Description copied from interface: Cookie
      Sets the security getStatus of this Cookie
      Specified by:
      setSecure in interface Cookie
      Parameters:
      secure - True if this Cookie is to be secure, otherwise false
    • isHttpOnly

      public boolean isHttpOnly()
      Description copied from interface: Cookie
      Checks to see if this Cookie can only be accessed via HTTP. If this returns true, the Cookie cannot be accessed through client side script - But only if the browser supports it. For more information, please look here
      Specified by:
      isHttpOnly in interface Cookie
      Returns:
      True if this Cookie is HTTP-only or false if it isn't
    • setHttpOnly

      public void setHttpOnly(boolean httpOnly)
      Description copied from interface: Cookie
      Determines if this Cookie is HTTP only. If set to true, this Cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.
      Specified by:
      setHttpOnly in interface Cookie
      Parameters:
      httpOnly - True if the Cookie is HTTP only, otherwise false.
    • sameSite

      public CookieHeaderNames.SameSite sameSite()
      Checks to see if this Cookie can be sent along cross-site requests. For more information, please look here
      Returns:
      same-site-flag value
    • setSameSite

      public void setSameSite(CookieHeaderNames.SameSite sameSite)
      Determines if this this Cookie can be sent along cross-site requests. For more information, please look here
      Parameters:
      sameSite - same-site-flag value
    • isPartitioned

      public boolean isPartitioned()
      Checks to see if this Cookie is partitioned
      Returns:
      True if this Cookie is partitioned, otherwise false
    • setPartitioned

      public void setPartitioned(boolean partitioned)
      Sets the Partitioned attribute of this Cookie
      Parameters:
      partitioned - True if this Cookie is to be partitioned, otherwise false
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • compareTo

      public int compareTo(Cookie c)
      Specified by:
      compareTo in interface java.lang.Comparable<Cookie>
    • validateValue

      @Deprecated protected java.lang.String validateValue(java.lang.String name, java.lang.String value)
      Deprecated.
      CookieUtil is package private, will be removed once old Cookie API is dropped
      Validate a cookie attribute value, throws a IllegalArgumentException otherwise. Only intended to be used by DefaultCookie.
      Parameters:
      name - attribute name
      value - attribute value
      Returns:
      the trimmed, validated attribute value
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object