org.apache.commons.httpclient.cookie

Class CookiePolicy

public abstract class CookiePolicy extends Object

Cookie management policy class. The cookie policy provides corresponding cookie management interfrace for a given type or version of cookie.

RFC 2109 specification is used per default. Other supported specification can be chosen when appropriate or set default when desired

The following specifications are provided:

Since: 2.0

Author: Oleg Kalnichevski Mike Bowler

Field Summary
static StringBROWSER_COMPATIBILITY
The policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.
static intCOMPATIBILITY
The COMPATIBILITY policy provides high compatibilty with common cookie management of popular HTTP agents.
static StringDEFAULT
The default cookie policy.
static StringIGNORE_COOKIES
The policy that ignores cookies.
protected static LogLOG
Log object.
static StringNETSCAPE
The Netscape cookie draft compliant policy.
static intNETSCAPE_DRAFT
The NETSCAPE_DRAFT Netscape draft compliant policy.
static intRFC2109
The RFC2109 RFC 2109 compliant policy.
static StringRFC_2109
The RFC 2109 compliant policy.
Method Summary
static CookieSpecgetCompatibilitySpec()
static CookieSpecgetCookieSpec(String id)
Gets the {@link CookieSpec cookie specification} with the given ID.
static intgetDefaultPolicy()
static CookieSpecgetDefaultSpec()
Returns {@link CookieSpec cookie specification} registered as {@link #DEFAULT}.
static CookieSpecgetSpecByPolicy(int policy)
static CookieSpecgetSpecByVersion(int ver)
Gets the CookieSpec for a particular cookie version.
static voidregisterCookieSpec(String id, Class clazz)
Registers a new {@link CookieSpec cookie specification} with the given identifier.
static voidsetDefaultPolicy(int policy)
static voidunregisterCookieSpec(String id)
Unregisters the {@link CookieSpec cookie specification} with the given ID.

Field Detail

BROWSER_COMPATIBILITY

public static final String BROWSER_COMPATIBILITY
The policy that provides high degree of compatibilty with common cookie management of popular HTTP agents.

Since: 3.0

COMPATIBILITY

public static final int COMPATIBILITY

Deprecated: Use {@link #BROWSER_COMPATIBILITY}

The COMPATIBILITY policy provides high compatibilty with common cookie management of popular HTTP agents.

DEFAULT

public static final String DEFAULT
The default cookie policy.

Since: 3.0

IGNORE_COOKIES

public static final String IGNORE_COOKIES
The policy that ignores cookies.

Since: 3.0

LOG

protected static final Log LOG
Log object.

NETSCAPE

public static final String NETSCAPE
The Netscape cookie draft compliant policy.

Since: 3.0

NETSCAPE_DRAFT

public static final int NETSCAPE_DRAFT

Deprecated: Use {@link #NETSCAPE}

The NETSCAPE_DRAFT Netscape draft compliant policy.

RFC2109

public static final int RFC2109

Deprecated: Use {@link #RFC_2109}

The RFC2109 RFC 2109 compliant policy.

RFC_2109

public static final String RFC_2109
The RFC 2109 compliant policy.

Since: 3.0

Method Detail

getCompatibilitySpec

public static CookieSpec getCompatibilitySpec()

Deprecated: Use {@link CookiePolicy#getCookieSpec(String)}

Returns: cookie specification interface that provides high compatibilty with common cookie management of popular HTTP agents

getCookieSpec

public static CookieSpec getCookieSpec(String id)
Gets the {@link CookieSpec cookie specification} with the given ID.

Parameters: id the {@link CookieSpec cookie specification} ID

Returns: {@link CookieSpec cookie specification}

Throws: IllegalStateException if a policy with the ID cannot be found

Since: 3.0

getDefaultPolicy

public static int getDefaultPolicy()

Deprecated: Use {@link #getDefaultSpec()}

Returns: default cookie policy

See Also: getDefaultSpec

getDefaultSpec

public static CookieSpec getDefaultSpec()
Returns {@link CookieSpec cookie specification} registered as {@link #DEFAULT}. If no default {@link CookieSpec cookie specification} has been registered, {@link RFC2109Spec RFC2109 specification} is returned.

Returns: default {@link CookieSpec cookie specification}

See Also: DEFAULT

getSpecByPolicy

public static CookieSpec getSpecByPolicy(int policy)

Deprecated: Use {@link CookiePolicy#getCookieSpec(String)}

Parameters: policy cookie policy to get the CookieSpec for

Returns: cookie specification interface for the given policy

getSpecByVersion

public static CookieSpec getSpecByVersion(int ver)

Deprecated: Use {@link CookiePolicy#getCookieSpec(String)}

Gets the CookieSpec for a particular cookie version.

Supported versions:

registerCookieSpec

public static void registerCookieSpec(String id, Class clazz)
Registers a new {@link CookieSpec cookie specification} with the given identifier. If a specification with the given ID already exists it will be overridden. This ID is the same one used to retrieve the {@link CookieSpec cookie specification} from {@link #getCookieSpec(String)}.

Parameters: id the identifier for this specification clazz the {@link CookieSpec cookie specification} class to register

Since: 3.0

See Also:

setDefaultPolicy

public static void setDefaultPolicy(int policy)

Deprecated: Use {@link CookiePolicy#registerCookieSpec(String, Class)}

Parameters: policy new default cookie policy

See Also: DEFAULT

unregisterCookieSpec

public static void unregisterCookieSpec(String id)
Unregisters the {@link CookieSpec cookie specification} with the given ID.

Parameters: id the ID of the {@link CookieSpec cookie specification} to unregister

Since: 3.0

Copyright (c) 1999-2005 - Apache Software Foundation