Class SimpleCookie

  • All Implemented Interfaces:
    Cookie, java.io.Serializable, java.lang.Comparable<Cookie>

    public class SimpleCookie
    extends java.lang.Object
    implements Cookie
    Simple Cookie implementation.
    Since:
    1.0
    See Also:
    Serialized Form
    • Constructor Detail

      • SimpleCookie

        public SimpleCookie​(java.lang.String name,
                            java.lang.String value)
        Constructor.
        Parameters:
        name - The name
        value - The value
    • Method Detail

      • getName

        @NonNull
        public java.lang.String getName()
        Specified by:
        getName in interface Cookie
        Returns:
        The name of the cookie
      • getValue

        @NonNull
        public java.lang.String getValue()
        Specified by:
        getValue in interface Cookie
        Returns:
        The value of the cookie
      • getDomain

        public java.lang.String getDomain()
        Description copied from interface: Cookie
        Gets the domain name of this Cookie.

        Domain names are formatted according to RFC 2109.

        Specified by:
        getDomain in interface Cookie
        Returns:
        the domain name of this Cookie
      • getPath

        public java.lang.String getPath()
        Description copied from interface: Cookie
        The path of the cookie. The cookie is visible to all paths below the request path on the server.
        Specified by:
        getPath in interface Cookie
        Returns:
        The cookie path
      • 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.

        See here for reference

        Specified by:
        isHttpOnly in interface Cookie
        Returns:
        True if this Cookie is HTTP-only or false if it isn't
      • isSecure

        public boolean isSecure()
        Specified by:
        isSecure in interface Cookie
        Returns:
        True if the cookie is secure
      • getMaxAge

        public long getMaxAge()
        Specified by:
        getMaxAge in interface Cookie
        Returns:
        The maximum age of the cookie in seconds
      • getSameSite

        public java.util.Optional<SameSite> getSameSite()
        Description copied from interface: Cookie
        Checks to see if this Cookie can be sent along cross-site requests. For more information, please look here
        Specified by:
        getSameSite in interface Cookie
        Returns:
        The SameSite attribute of the cookie
      • sameSite

        @NonNull
        public Cookie sameSite​(SameSite sameSite)
        Description copied from interface: Cookie
        Determines if this this Cookie can be sent along cross-site requests. For more information, please look here
        Specified by:
        sameSite in interface Cookie
        Parameters:
        sameSite - SameSite value
        Returns:
        This cookie
      • maxAge

        @NonNull
        public Cookie maxAge​(long maxAge)
        Description copied from interface: Cookie
        Sets the max age of the cookie in seconds.
        Specified by:
        maxAge in interface Cookie
        Parameters:
        maxAge - The max age
        Returns:
        This cookie
      • value

        @NonNull
        public Cookie value​(@NonNull
                            java.lang.String value)
        Description copied from interface: Cookie
        Sets the value.
        Specified by:
        value in interface Cookie
        Parameters:
        value - The value of the cookie
        Returns:
        This cookie
      • domain

        @NonNull
        public Cookie domain​(java.lang.String domain)
        Description copied from interface: Cookie
        Sets the domain of the cookie.
        Specified by:
        domain in interface Cookie
        Parameters:
        domain - The domain of the cookie
        Returns:
        This cookie
      • path

        @NonNull
        public Cookie path​(java.lang.String path)
        Description copied from interface: Cookie
        Sets the path of the cookie.
        Specified by:
        path in interface Cookie
        Parameters:
        path - The path of the cookie
        Returns:
        This cookie
      • secure

        @NonNull
        public Cookie secure​(boolean secure)
        Description copied from interface: Cookie
        Sets whether the cookie is secure.
        Specified by:
        secure in interface Cookie
        Parameters:
        secure - Is the cookie secure
        Returns:
        This cookie
      • httpOnly

        @NonNull
        public Cookie httpOnly​(boolean httpOnly)
        Description copied from interface: Cookie
        Sets whether the cookie is HTTP-Only.
        Specified by:
        httpOnly in interface Cookie
        Parameters:
        httpOnly - Is the cookie HTTP-Only
        Returns:
        This cookie
      • 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>
      • hashCode

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

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