0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.net;
0N/A
0N/Aimport java.util.List;
0N/Aimport java.util.Map;
0N/A
0N/A/**
0N/A * A CookieStore object represents a storage for cookie. Can store and retrieve
0N/A * cookies.
0N/A *
0N/A * <p>{@link CookieManager} will call <tt>CookieStore.add</tt> to save cookies
0N/A * for every incoming HTTP response, and call <tt>CookieStore.get</tt> to
0N/A * retrieve cookie for every outgoing HTTP request. A CookieStore
0N/A * is responsible for removing HttpCookie instances which have expired.
0N/A *
0N/A * @author Edward Wang
0N/A * @since 1.6
0N/A */
0N/Apublic interface CookieStore {
0N/A /**
0N/A * Adds one HTTP cookie to the store. This is called for every
0N/A * incoming HTTP response.
0N/A *
0N/A * <p>A cookie to store may or may not be associated with an URI. If it
0N/A * is not associated with an URI, the cookie's domain and path attribute
0N/A * will indicate where it comes from. If it is associated with an URI and
0N/A * its domain and path attribute are not speicifed, given URI will indicate
0N/A * where this cookie comes from.
0N/A *
0N/A * <p>If a cookie corresponding to the given URI already exists,
0N/A * then it is replaced with the new one.
0N/A *
0N/A * @param uri the uri this cookie associated with.
0N/A * if <tt>null</tt>, this cookie will not be associated
0N/A * with an URI
0N/A * @param cookie the cookie to store
0N/A *
0N/A * @throws NullPointerException if <tt>cookie</tt> is <tt>null</tt>
0N/A *
0N/A * @see #get
0N/A *
0N/A */
0N/A public void add(URI uri, HttpCookie cookie);
0N/A
0N/A
0N/A /**
0N/A * Retrieve cookies associated with given URI, or whose domain matches the
0N/A * given URI. Only cookies that have not expired are returned.
0N/A * This is called for every outgoing HTTP request.
0N/A *
0N/A * @return an immutable list of HttpCookie,
0N/A * return empty list if no cookies match the given URI
0N/A *
0N/A * @throws NullPointerException if <tt>uri</tt> is <tt>null</tt>
0N/A *
0N/A * @see #add
0N/A *
0N/A */
0N/A public List<HttpCookie> get(URI uri);
0N/A
0N/A
0N/A /**
0N/A * Get all not-expired cookies in cookie store.
0N/A *
0N/A * @return an immutable list of http cookies;
0N/A * return empty list if there's no http cookie in store
0N/A */
0N/A public List<HttpCookie> getCookies();
0N/A
0N/A
0N/A /**
0N/A * Get all URIs which identify the cookies in this cookie store.
0N/A *
0N/A * @return an immutable list of URIs;
0N/A * return empty list if no cookie in this cookie store
0N/A * is associated with an URI
0N/A */
0N/A public List<URI> getURIs();
0N/A
0N/A
0N/A /**
0N/A * Remove a cookie from store.
0N/A *
0N/A * @param uri the uri this cookie associated with.
0N/A * if <tt>null</tt>, the cookie to be removed is not associated
0N/A * with an URI when added; if not <tt>null</tt>, the cookie
0N/A * to be removed is associated with the given URI when added.
0N/A * @param cookie the cookie to remove
0N/A *
0N/A * @return <tt>true</tt> if this store contained the specified cookie
0N/A *
0N/A * @throws NullPointerException if <tt>cookie</tt> is <tt>null</tt>
0N/A */
0N/A public boolean remove(URI uri, HttpCookie cookie);
0N/A
0N/A
0N/A /**
0N/A * Remove all cookies in this cookie store.
0N/A *
0N/A * @return <tt>true</tt> if this store changed as a result of the call
0N/A */
0N/A public boolean removeAll();
0N/A}