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

BasicMaxAgeHandler

public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler

Fields Summary
Constructors Summary
public BasicMaxAgeHandler()

        super();
    
Methods Summary
public voidparse(org.apache.http.cookie.SetCookie cookie, java.lang.String value)

        if (cookie == null) {
            throw new IllegalArgumentException("Cookie may not be null");
        }
        if (value == null) {
            throw new MalformedCookieException("Missing value for max-age attribute");
        }
        int age;
        try {
            age = Integer.parseInt(value);
        } catch (NumberFormatException e) {
            throw new MalformedCookieException ("Invalid max-age attribute: " 
                    + value);
        }
        if (age < 0) {
            throw new MalformedCookieException ("Negative max-age attribute: " 
                    + value);
        }
        cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L));