Package rife.engine

Record Class SiteCookie

java.lang.Object
java.lang.Record
rife.engine.SiteCookie
Record Components:
name - the name of the cookie
value - the value of the cookie
host - the host that set the cookie, which is the only host that it's sent to when there's no domain
domain - the domain the cookie was set for, which includes its subdomains, or null for only the host that set it
path - the path the cookie applies to
expires - when the cookie expires, in milliseconds since the epoch, or -1 for a session cookie, which isn't stored and is forgotten together with its jar
secure - whether the cookie is only sent with secure requests
httpOnly - whether the cookie was marked as not visible to scripts
sameSite - the SameSite attribute, or null when it wasn't set

public record SiteCookie(String name, String value, String host, String domain, String path, long expires, boolean secure, boolean httpOnly, String sameSite) extends Record
A cookie as it's kept by a SiteCookieJar, with an absolute expiry so that it can be stored and restored later.
Since:
1.11.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    SiteCookie(String name, String value, String host, String domain, String path, long expires, boolean secure, boolean httpOnly, String sameSite)
    Creates an instance of a SiteCookie record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the domain record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    long
    Returns the value of the expires record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the host record component.
    boolean
    Returns the value of the httpOnly record component.
    boolean
    isExpired(long now)
    Indicates whether this cookie has expired at a particular moment.
    boolean
    Indicates whether this is a session cookie, which isn't stored and is forgotten together with its jar.
    Returns the value of the name record component.
    Returns the value of the path record component.
    Returns the value of the sameSite record component.
    boolean
    Returns the value of the secure record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

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

    • SiteCookie

      public SiteCookie(String name, String value, String host, String domain, String path, long expires, boolean secure, boolean httpOnly, String sameSite)
      Creates an instance of a SiteCookie record class.
      Parameters:
      name - the value for the name record component
      value - the value for the value record component
      host - the value for the host record component
      domain - the value for the domain record component
      path - the value for the path record component
      expires - the value for the expires record component
      secure - the value for the secure record component
      httpOnly - the value for the httpOnly record component
      sameSite - the value for the sameSite record component
  • Method Details

    • isSessionCookie

      public boolean isSessionCookie()
      Indicates whether this is a session cookie, which isn't stored and is forgotten together with its jar.
      Returns:
      true if the cookie has no expiry; or

      false otherwise

      Since:
      1.11.0
    • isExpired

      public boolean isExpired(long now)
      Indicates whether this cookie has expired at a particular moment.
      Parameters:
      now - the moment in milliseconds since the epoch
      Returns:
      true if the cookie has expired; or

      false otherwise

      Since:
      1.11.0
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • value

      public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • host

      public String host()
      Returns the value of the host record component.
      Returns:
      the value of the host record component
    • domain

      public String domain()
      Returns the value of the domain record component.
      Returns:
      the value of the domain record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • expires

      public long expires()
      Returns the value of the expires record component.
      Returns:
      the value of the expires record component
    • secure

      public boolean secure()
      Returns the value of the secure record component.
      Returns:
      the value of the secure record component
    • httpOnly

      public boolean httpOnly()
      Returns the value of the httpOnly record component.
      Returns:
      the value of the httpOnly record component
    • sameSite

      public String sameSite()
      Returns the value of the sameSite record component.
      Returns:
      the value of the sameSite record component