Oracle® Application Server
XML Java API Reference
10g Release 3 (10.1.3)

B28238-01


org.apache.soap.transport.http
Class Cookie

java.lang.Object
  extended byorg.apache.soap.transport.http.Cookie


public class Cookie
extends java.lang.Object

A cookie as defined in RFC 2109 and RFC 2965. Since cookie support is a relatively tangential feature, this implementation is very forgiving, allowing many variations from the RFCs and staying mum regarding errors. This class also provides static methods to support management of an array of Cookie instances.


Constructor Summary
Cookie(java.net.URL url, java.lang.String cookieString)
Creates an instance from a cookie string.

Method Summary
static java.lang.String buildCookieValue(java.net.URL url, Cookie[] cookies)
Returns a Cookie or Cookie2 header value for an array of cookies being sent to a URL.
boolean equals(java.lang.Object obj)
Compares two Cookies.
boolean getExpired()
Returns whether the cookie has expired.
static Cookie[] parseCookies(java.net.URL url, java.lang.String setCookieValue)
Creates an array of cookies from a Set-Cookie or Set-Cookie2 header value.
static boolean sameCookie(Cookie cookie1, Cookie cookie2)
Compares two Cookies.
boolean sendToURL(java.net.URL url)
Returns whether the cookie should be sent to the URL.
java.lang.String toString()
Returns the cookie as a string appropriate for a Cookie or Cookie2 header.
static Cookie[] updateCookies(Cookie[] cookies1, Cookie[] cookies2)
Updates an array of cookies with another array of cookies.

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

Constructor Detail

Cookie

public Cookie(java.net.URL url,
              java.lang.String cookieString)
Creates an instance from a cookie string. A Set-Cookie or Set-Cookie2 header consists of a comma-separated list of such strings.
Parameters:
url - The URL from which the cookie came.
cookieString - The cookie string.

Method Detail

buildCookieValue

public static java.lang.String buildCookieValue(java.net.URL url,
                                                Cookie[] cookies)
Returns a Cookie or Cookie2 header value for an array of cookies being sent to a URL.
Parameters:
url - The URL to which the header will be sent.
cookies - The cookies that may be sent in the header.
Returns:
The Cookie or Cookie2 header value.

equals

public boolean equals(java.lang.Object obj)
Compares two Cookies. Two Cookie objects are equal if they have the same name, value, domain, path and port.
Parameters:
obj - The Cookie to compare against.
Returns:
true if the Cookies are the same, false otherwise.

getExpired

public boolean getExpired()
Returns whether the cookie has expired.
Returns:
True if the cookie has expired, false if it has not.

parseCookies

public static Cookie[] parseCookies(java.net.URL url,
                                    java.lang.String setCookieValue)
Creates an array of cookies from a Set-Cookie or Set-Cookie2 header value.
Parameters:
url - The URL from which the header came.
setCookieValue - The value from the Set-Cookie or Set-Cookie2 header.
Returns:
An array of cookies.

sameCookie

public static boolean sameCookie(Cookie cookie1,
                                 Cookie cookie2)
Compares two Cookies. Two Cookie objects are the "same" if they have the same name, domain, path and port.
Parameters:
cookie1 - A Cookie.
cookie2 - A Cookie.
Returns:
true if the Cookies are the same, false otherwise.

sendToURL

public boolean sendToURL(java.net.URL url)
Returns whether the cookie should be sent to the URL.
Returns:
True if the cookie should be sent to the URL, false if it should not.

toString

public java.lang.String toString()
Returns the cookie as a string appropriate for a Cookie or Cookie2 header.
Returns:
A string appropriate for a Cookie header.

updateCookies

public static Cookie[] updateCookies(Cookie[] cookies1,
                                     Cookie[] cookies2)
Updates an array of cookies with another array of cookies. The cookies in the cookies1 array can be updated. The returned array will be a reference to a new array if cookies were added to it.
Parameters:
cookies1 - The array of Cookies being updated.
cookies2 - The array of Cookies by which to update.
Returns:
An updated array, which may be different than cookies1.

Oracle® Application Server
XML Java API Reference
10g Release 3 (10.1.3)

B28238-01


Copyright © 2001 The Apache Software Foundation. All rights reserved.