org.apache.tapestry5.internal.services

## Class CookiesImpl

- java.lang.Object
- - org.apache.tapestry5.internal.services.CookiesImpl

- All Implemented Interfaces:
    Cookies

      public class CookiesImpl
      extends Object
      implements Cookies

  Implementation of the `Cookies` service interface.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CookiesImpl(Request request, CookieSource cookieSource, CookieSink cookieSink, String contextPath, long defaultMaxAge)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CookieBuilder` | `getBuilder(String name, String value)` Returns a `CookieBuilder` to build and write a `Cookie`.
    `String` | `readCookieValue(String name)` Returns the value of the first cookie whose name matches.
    `void` | `removeCookieValue(String name)` Removes a previously written cookie, by writing a new cookie with a maxAge of 0.
    `void` | `writeCookieValue(String name, String value)` Creates or updates a cookie value.
    `void` | `writeCookieValue(String name, String value, int maxAge)` As with `Cookies.writeCookieValue(String, String)` but an explicit maximum age may be set.
    `void` | `writeCookieValue(String name, String value, String path)` As with `Cookies.writeCookieValue(String, String)` but an explicit path may be set.
    `void` | `writeCookieValue(String name, String value, String path, String domain)` As with `Cookies.writeCookieValue(String, String, String)` but an explicit domain and path may be set.
    `void` | `writeDomainCookieValue(String name, String value, String domain)` As with `Cookies.writeCookieValue(String, String)` but an explicit domain may be set.
    `void` | `writeDomainCookieValue(String name, String value, String domain, int maxAge)` As with `Cookies.writeCookieValue(String, String)` but an explicit domain and maximum age may be set.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CookiesImpl

          public CookiesImpl(Request request,
                             CookieSource cookieSource,
                             CookieSink cookieSink,
                             @Symbol(value="tapestry.context-path")
                             String contextPath,
                             @Symbol(value="tapestry.default-cookie-max-age") @IntermediateType(value=TimeInterval.class)
                             long defaultMaxAge)

      Parameters:
        `request` -
        `cookieSource` -
        `cookieSink` -
        `contextPath` -
        `defaultMaxAge` - default cookie expiration time in milliseconds

  - ### Method Detail

    - #### readCookieValue

          public String readCookieValue(String name)

      Description copied from interface: `Cookies`
      Returns the value of the first cookie whose name matches. Returns null if no such cookie exists. This method is only aware of cookies that are part of the incoming request; it does not know about additional cookies added since then (via `Cookies.writeCookieValue(String, String)`).
      Specified by:
        `readCookieValue` in interface `Cookies`

    - #### writeCookieValue

          public void writeCookieValue(String name,
                                       String value)

      Description copied from interface: `Cookies`
      Creates or updates a cookie value. The value is stored using a max age (in seconds) defined by the symbol `org.apache.tapestry5.default-cookie-max-age`. The factory default for this value is the equivalent of one week.
      Specified by:
        `writeCookieValue` in interface `Cookies`

    - #### writeCookieValue

          public void writeCookieValue(String name,
                                       String value,
                                       int maxAge)

      Description copied from interface: `Cookies`
      As with `Cookies.writeCookieValue(String, String)` but an explicit maximum age may be set.
      Specified by:
        `writeCookieValue` in interface `Cookies`
      Parameters:
        `name` - the name of the cookie
        `value` - the value to be stored in the cookie
        `maxAge` - the maximum age, in seconds, to store the cookie

    - #### writeCookieValue

          public void writeCookieValue(String name,
                                       String value,
                                       String path)

      Description copied from interface: `Cookies`
      As with `Cookies.writeCookieValue(String, String)` but an explicit path may be set.
      Specified by:
        `writeCookieValue` in interface `Cookies`

    - #### writeDomainCookieValue

          public void writeDomainCookieValue(String name,
                                             String value,
                                             String domain)

      Description copied from interface: `Cookies`
      As with `Cookies.writeCookieValue(String, String)` but an explicit domain may be set.
      Specified by:
        `writeDomainCookieValue` in interface `Cookies`

    - #### writeDomainCookieValue

          public void writeDomainCookieValue(String name,
                                             String value,
                                             String domain,
                                             int maxAge)

      Description copied from interface: `Cookies`
      As with `Cookies.writeCookieValue(String, String)` but an explicit domain and maximum age may be set.
      Specified by:
        `writeDomainCookieValue` in interface `Cookies`

    - #### writeCookieValue

          public void writeCookieValue(String name,
                                       String value,
                                       String path,
                                       String domain)

      Description copied from interface: `Cookies`
      As with `Cookies.writeCookieValue(String, String, String)` but an explicit domain and path may be set.
      Specified by:
        `writeCookieValue` in interface `Cookies`

    - #### removeCookieValue

          public void removeCookieValue(String name)

      Description copied from interface: `Cookies`
      Removes a previously written cookie, by writing a new cookie with a maxAge of 0. Only deletes a cookie with the default path and no domain set. For deleting other cookies use `CookieBuilder.delete()`. An instance of the `CookieBuilder` API can be obtained with `Cookies.getBuilder(String, String)`.
      Specified by:
        `removeCookieValue` in interface `Cookies`

    - #### getBuilder

          public CookieBuilder getBuilder(String name,
                                          String value)

      Description copied from interface: `Cookies`
      Returns a `CookieBuilder` to build and write a `Cookie`. The default implementation creates a cookie who's value is stored using a max age (in seconds) defined by the symbol `org.apache.tapestry5.default-cookie-max-age`. The factory default for this value is the equivalent of one week. The default path is the context path (see `Request.getContextPath()`) of the current Request, the default secure setting is to send the cookie over secure channels only, if the original request was secure (see `Request.isSecure()`
      Specified by:
        `getBuilder` in interface `Cookies`
      Parameters:
        `name` - the name of the cookie
        `value` - the value of the cookie
      Returns:
        a `CookieBuilder` for setting additional cookie attributes and writing it out

5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.