FileDocCategorySizeDatePackage
AbstractCookieSpec.javaAPI DocAndroid 1.5 API3987Wed May 06 22:41:10 BST 2009org.apache.http.impl.cookie

AbstractCookieSpec

public abstract class AbstractCookieSpec extends Object implements CookieSpec
Abstract cookie specification which can delegate the job of parsing, validation or matching cookie attributes to a number of arbitrary {@link CookieAttributeHandler}s.
author
Oleg Kalnichevski
since
4.0

Fields Summary
private final Map
attribHandlerMap
Stores attribute name -> attribute handler mappings
Constructors Summary
public AbstractCookieSpec()
Default constructor

        super();
        this.attribHandlerMap = new HashMap<String, CookieAttributeHandler>(10);        
    
Methods Summary
protected org.apache.http.cookie.CookieAttributeHandlerfindAttribHandler(java.lang.String name)
Finds an attribute handler {@link CookieAttributeHandler} for the given attribute. Returns null if no attribute handler is found for the specified attribute.

param
name attribute name. e.g. Domain, Path, etc.
return
an attribute handler or null

        return this.attribHandlerMap.get(name);
    
protected org.apache.http.cookie.CookieAttributeHandlergetAttribHandler(java.lang.String name)
Gets attribute handler {@link CookieAttributeHandler} for the given attribute.

param
name attribute name. e.g. Domain, Path, etc.
throws
IllegalStateException if handler not found for the specified attribute.

        CookieAttributeHandler handler = findAttribHandler(name);
        if (handler == null) {
            throw new IllegalStateException("Handler not registered for " +
                                            name + " attribute.");
        } else {
            return handler;
        }
    
protected java.util.CollectiongetAttribHandlers()

        return this.attribHandlerMap.values();
    
public voidregisterAttribHandler(java.lang.String name, org.apache.http.cookie.CookieAttributeHandler handler)

        if (name == null) {
            throw new IllegalArgumentException("Attribute name may not be null");
        }
        if (handler == null) {
            throw new IllegalArgumentException("Attribute handler may not be null");
        }
        this.attribHandlerMap.put(name, handler);