Register a new, initialized 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. @return the new cookie
()
| 48 | * @return the new cookie |
| 49 | */ |
| 50 | public ServerCookie addCookie() { |
| 51 | if (limit > -1 && cookieCount >= limit) { |
| 52 | throw new IllegalArgumentException(sm.getString("cookies.maxCountFail", Integer.valueOf(limit))); |
| 53 | } |
| 54 | |
| 55 | if (cookieCount >= serverCookies.length) { |
| 56 | int newSize = limit > -1 ? Math.min(2 * cookieCount, limit) : 2 * cookieCount; |
| 57 | ServerCookie[] scookiesTmp = new ServerCookie[newSize]; |
| 58 | System.arraycopy(serverCookies, 0, scookiesTmp, 0, cookieCount); |
| 59 | serverCookies = scookiesTmp; |
| 60 | } |
| 61 | |
| 62 | ServerCookie c = serverCookies[cookieCount]; |
| 63 | if (c == null) { |
| 64 | c = new ServerCookie(); |
| 65 | serverCookies[cookieCount] = c; |
| 66 | } |
| 67 | cookieCount++; |
| 68 | return c; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | /** |