Cookies (Tomcat API Documentation)
Keywords: org.apache.tomcat.util.http.Cookies class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util.http
Class Cookies

    java.lang.Object
      org.apache.tomcat.util.http.Cookies

    public final class Cookies

extends java.lang.Object

A collection of cookies - reusable and tuned for server side performance. Based on RFC2965 ( and 2109 ) This class is not synchronized.

Author:
  Costin Manolache, kevin seguin

Field Summary
`static int` | `INITIAL_SIZE`
`protected static boolean[]` | `separators`
`static char[]` | `SEPARATORS`

Constructor Summary
`Cookies()` Construct a new uninitialized cookie collection.
`Cookies(MimeHeaders headers)` Construct a new cookie collection, that will extract the information from headers.

Method Summary
`ServerCookie` | `addCookie()` Register a new, unitialized cookie.
`static boolean` | `equals(java.lang.String s, byte[] b, int start, int end)`
`ServerCookie` | `getCookie(int idx)`
`int` | `getCookieCount()`
`static int` | `getQuotedValueEndPosition(byte[] bytes, int off, int end)` Given a starting position after an initial quote chracter, this gets the position of the end quote.
`static int` | `getTokenEndPosition(byte[] bytes, int off, int end)` Given the starting position of a token, this gets the end of the token, with no separator characters in between.
`static boolean` | `isSeparator(byte c)` Returns true if the byte is a separator character as defined in RFC2619.
`static boolean` | `isWhiteSpace(byte c)` Returns true if the byte is a whitespace character as defined in RFC2619 JVK
`void` | `log(java.lang.String s)`
`void` | `processCookieHeader(byte[] bytes, int off, int len)` Parses a cookie header after the initial "Cookie:" [WS][$]token[WS]=[WS](token|QV)[;|,] RFC 2965 JVK
`void` | `processCookies(MimeHeaders headers)` Add all Cookie found in the headers of a request.
`void` | `recycle()` Recycle.
`void` | `setHeaders(MimeHeaders headers)` Set the headers from which cookies will be pulled.
`java.lang.String` | `toString()` EXPENSIVE!!!

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### INITIAL_SIZE

    public static final int INITIAL_SIZE

See Also:
  Constant Field Values

### SEPARATORS

    public static final char[] SEPARATORS

### separators

    protected static final boolean[] separators

Constructor Detail

### Cookies

    public Cookies(MimeHeaders headers)

  Construct a new cookie collection, that will extract the information from headers.

  Parameters:
    `headers` - Cookies are lazy-evaluated and will extract the information from the provided headers.

### Cookies

    public Cookies()

  Construct a new uninitialized cookie collection. Use `setHeaders(org.apache.tomcat.util.http.MimeHeaders)` to initialize.

Method Detail

### setHeaders

    public void setHeaders(MimeHeaders headers)

  Set the headers from which cookies will be pulled. This has the side effect of recycling the object.

  Parameters:
    `headers` - Cookies are lazy-evaluated and will extract the information from the provided headers.

### recycle

    public void recycle()

  Recycle.

### toString

    public java.lang.String toString()

  EXPENSIVE!!! only for debugging.

  Overrides:
    `toString` in class `java.lang.Object`

### getCookie

    public ServerCookie getCookie(int idx)

### getCookieCount

    public int getCookieCount()

### addCookie

    public ServerCookie addCookie()

  Register a new, unitialized cookie. Cookies are recycled, and most of the time an existing ServerCookie object is returned. The caller can set the name/value and attributes for the cookie

### processCookies

    public void processCookies(MimeHeaders headers)

  Add all Cookie found in the headers of a request.

### equals

    public static boolean equals(java.lang.String s,
                                 byte[] b,
                                 int start,
                                 int end)

### log

    public void log(java.lang.String s)

### isSeparator

    public static final boolean isSeparator(byte c)

  Returns true if the byte is a separator character as defined in RFC2619. Since this is called often, this function should be organized with the most probable outcomes first. JVK

### isWhiteSpace

    public static final boolean isWhiteSpace(byte c)

  Returns true if the byte is a whitespace character as defined in RFC2619 JVK

### processCookieHeader

    public final void processCookieHeader(byte[] bytes,
                                          int off,
                                          int len)

  Parses a cookie header after the initial "Cookie:" [WS][$]token[WS]=[WS](token|QV)[;|,] RFC 2965 JVK

### getTokenEndPosition

    public static final int getTokenEndPosition(byte[] bytes,
                                                int off,
                                                int end)

  Given the starting position of a token, this gets the end of the token, with no separator characters in between. JVK

### getQuotedValueEndPosition

    public static final int getQuotedValueEndPosition(byte[] bytes,
                                                      int off,
                                                      int end)

  Given a starting position after an initial quote chracter, this gets the position of the end quote. This escapes anything after a '\' char JVK RFC 2616

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.