FileDocCategorySizeDatePackage
CookieIdentityComparator.javaAPI DocAndroid 1.5 API2463Wed May 06 22:41:10 BST 2009org.apache.http.cookie

CookieIdentityComparator

public class CookieIdentityComparator extends Object implements Serializable, Comparator
This cookie comparator can be used to compare identity of cookies.

Cookies are considered identical if their names are equal and their domain attributes match ignoring case.

author
Oleg Kalnichevski

Fields Summary
private static final long
serialVersionUID
Constructors Summary
Methods Summary
public intcompare(org.apache.http.cookie.Cookie c1, org.apache.http.cookie.Cookie c2)


            
        int res = c1.getName().compareTo(c2.getName());
        if (res == 0) {
            // do not differentiate empty and null domains 
            String d1 = c1.getDomain();
            if (d1 == null) {
                d1 = "";
            }
            String d2 = c2.getDomain();
            if (d2 == null) {
                d2 = "";
            }
            res = d1.compareToIgnoreCase(d2);
        }
        return res;