Interface Cookie

  • All Superinterfaces:
    org.refcodes.mixin.KeyAccessor<java.lang.String>, org.refcodes.mixin.KeyAccessor.KeyBuilder<java.lang.String,java.lang.String>, org.refcodes.mixin.KeyAccessor.KeyMutator<java.lang.String>, org.refcodes.mixin.KeyAccessor.KeyProperty<java.lang.String>, org.refcodes.structure.Property, org.refcodes.structure.Property.PropertyBuilder, org.refcodes.structure.Relation<java.lang.String,java.lang.String>, org.refcodes.structure.Relation.RelationBuilder<java.lang.String,java.lang.String>, org.refcodes.mixin.ValueAccessor<java.lang.String>, org.refcodes.mixin.ValueAccessor.ValueBuilder<java.lang.String,java.lang.String>, org.refcodes.mixin.ValueAccessor.ValueMutator<java.lang.String>, org.refcodes.mixin.ValueAccessor.ValueProperty<java.lang.String>
    All Known Subinterfaces:
    RequestCookie, ResponseCookie
    All Known Implementing Classes:
    RequestCookieImpl, ResponseCookieImpl


    public interface Cookie
    extends org.refcodes.structure.Property.PropertyBuilder
    The Cookie represents a HTTP cookie. As the cookies differ between an HTTP-Request and an HTTP-Response, we have the sub-interfaces RequestCookie and ResponseCookie. As of "HTTP cookies explained - NCZOnline": "... There is some confusion over encoding of a cookie value. The commonly held belief is that cookie values must be URL-encoded, but this is a fallacy even though it is the de facto implementation. The original specification indicates that only three types of characters must be encoded: semicolon, comma, and white space. The specification indicates that URL encoding may be used but stops short of requiring it. The RFC makes no mention of encoding whatsoever. Still, almost all implementations perform some sort of URL encoding on cookie values. In the case of name=value formats, the name and value are typically encoded separately while the equals sign is left as is. ..." Therefore we use URL encoding / decoding for the cookie value (regarding fromHttpCookie(String) and toHttpCookie()) to make life easier and not fall into the trap of unescaped values.
    See Also:
    "https://www.nczonline.net/blog/2009/05/05/http-cookies-explained"
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.KeyAccessor

        org.refcodes.mixin.KeyAccessor.KeyBuilder<K extends java.lang.Object,B extends org.refcodes.mixin.KeyAccessor.KeyBuilder<K,B>>, org.refcodes.mixin.KeyAccessor.KeyMutator<K extends java.lang.Object>, org.refcodes.mixin.KeyAccessor.KeyProperty<K extends java.lang.Object>
      • Nested classes/interfaces inherited from interface org.refcodes.structure.Property

        org.refcodes.structure.Property.PropertyBuilder
      • Nested classes/interfaces inherited from interface org.refcodes.structure.Relation

        org.refcodes.structure.Relation.RelationBuilder<K extends java.lang.Object,V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor

        org.refcodes.mixin.ValueAccessor.ValueBuilder<V extends java.lang.Object,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V extends java.lang.Object>, org.refcodes.mixin.ValueAccessor.ValueProperty<V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void fromHttpCookie​(java.lang.String aHttpCookie)
      Sets the cookie according to the provided HTTP cookie text.
      java.lang.String toHttpCookie​()
      Returns the cookie to be assigned to a cookie Header-Field.
      Cookie withHttpCookie​(java.lang.String aHttpCookie)
      Sets the cookie according to the provided HTTP cookie text via fromHttpCookie(String).
      • Methods inherited from interface org.refcodes.mixin.KeyAccessor

        getKey
      • Methods inherited from interface org.refcodes.mixin.KeyAccessor.KeyMutator

        setKey
      • Methods inherited from interface org.refcodes.structure.Property

        toProperty
      • Methods inherited from interface org.refcodes.structure.Property.PropertyBuilder

        withKey, withValue
      • Methods inherited from interface org.refcodes.mixin.ValueAccessor

        getValue
      • Methods inherited from interface org.refcodes.mixin.ValueAccessor.ValueMutator

        setValue
    • Method Detail

      • toHttpCookie

        java.lang.String toHttpCookie​()
        Returns the cookie to be assigned to a cookie Header-Field.
        Returns:
        The cookie value for a Header-Field.
      • withHttpCookie

        Cookie withHttpCookie​(java.lang.String aHttpCookie)
        Sets the cookie according to the provided HTTP cookie text via fromHttpCookie(String).
        Parameters:
        aHttpCookie - The HTTP cookie text.
        Returns:
        A Cookie instance as of the Builder-Pattern.
      • fromHttpCookie

        void fromHttpCookie​(java.lang.String aHttpCookie)
        Sets the cookie according to the provided HTTP cookie text.
        Parameters:
        aHttpCookie - The HTTP cookie text.