Class CookieUtils


  • public class CookieUtils
    extends Object
    • Method Detail

      • newCookieList

        public static List newCookieList()
        Get a new (empty) CookieData list return An empty ArrayList
      • parseCookie

        public static CookieData parseCookie​(URL url,
                                             String value)
        Parse an HTTP cookie
        Parameters:
        value - Cookie value
        Returns:
        A CookieData object representing this cookie
      • storeCookie

        public static void storeCookie​(List cookieList,
                                       CookieData cookie)
        Maintain a list of CookieData objects (add, replace, or delete a cookie)
        Parameters:
        cookieList - CookieData list
        cookie - A CookieData object
      • inDomain

        public static boolean inDomain​(String urlString,
                                       CookieData cookie)
        Does the cookie domain match the URL?
        Parameters:
        urlString - URL String to match
        cookie - CookieData object (the cookie)
        Returns:
        true if the cookie domain matches the URL
      • inDomain

        public static boolean inDomain​(URL url,
                                       CookieData cookie)
        Does the cookie domain match the URL?
        Parameters:
        url - URL to match
        cookie - CookieData object (the cookie)
        Returns:
        true if the cookie domain matches the URL
      • inPath

        public static boolean inPath​(String urlString,
                                     CookieData cookie)
        Does the cookie path match the URL "file"?
        Parameters:
        urlString - String URL to match
        cookie - CookieData object (the cookie)
        Returns:
        true if the cookie domain matches the URL
      • inPath

        public static boolean inPath​(URL url,
                                     CookieData cookie)
        Does the cookie path match the URL "file"?
        Parameters:
        url - URL to match
        cookie - CookieData object (the cookie)
        Returns:
        true if the cookie domain matches the URL
      • findCookiesForServer

        public static List findCookiesForServer​(List cookieList,
                                                URL url)
        Find all stored cookies which associated with this server
        Parameters:
        cookieList - List of stored cookies (CookieData objects)
        url - URL representing the request to lookup (server)
        Returns:
        A List of associated cookies
      • getCookies

        public static List getCookies​(List cookieList,
                                      URL url,
                                      String name,
                                      boolean exact)
        Find cookies associated with this server (by name)
        Parameters:
        cookieList - List of stored cookies (CookieData objects)
        url - URL representing the request to lookup (server)
        name - Cookie name
        exact - true for exact name match, false to match on name prefix
        Returns:
        A List of associated cookies
      • getCookiesByName

        public static List getCookiesByName​(List cookieList,
                                            URL url,
                                            String name)
        Find cookies associated with this server (exact name match)
        Parameters:
        cookieList - List of stored cookies (CookieData objects)
        url - URL representing the request to lookup (server)
        name - Cookie name
        Returns:
        A List of associated cookies
      • getCookiesByPrefix

        public static List getCookiesByPrefix​(List cookieList,
                                              URL url,
                                              String name)
        Find cookies associated with this server (match on name "prefix")
        Parameters:
        cookieList - List of stored cookies (CookieData objects)
        url - URL representing the request to lookup (server)
        name - Cookie name
        Returns:
        A List of associated cookies