FileDocCategorySizeDatePackage
AttributeTypeAndValueComparator.javaAPI DocAndroid 1.5 API3227Wed May 06 22:41:06 BST 2009org.apache.harmony.security.x501

AttributeTypeAndValueComparator

public class AttributeTypeAndValueComparator extends Object implements Comparator
AttributeTypeAndValue comparator

Fields Summary
Constructors Summary
Methods Summary
public intcompare(java.lang.Object obj1, java.lang.Object obj2)
compares two AttributeTypeAndValues

param
obj1 first AttributeTypeAndValue
param
obj2 second AttributeTypeAndValue
return
-1 of first AttributeTypeAndValue "less" than second AttributeTypeAndValue 1 otherwise, 0 if they are equal

        if (obj1 == obj2) {
            return 0;
        }

        AttributeTypeAndValue atav1 = (AttributeTypeAndValue) obj1;
        AttributeTypeAndValue atav2 = (AttributeTypeAndValue) obj2;
        String kw1 = atav1.getType().getName();
        String kw2 = atav2.getType().getName();
        if (kw1 != null && kw2 == null) {
            return -1;
        }
        if (kw1 == null && kw2 != null) {
            return 1;
        }
        if (kw1 != null && kw2 != null) {
            return kw1.compareTo(kw2);
        }

        return compateOids(atav1.getType(), atav2.getType());
    
private static intcompateOids(org.apache.harmony.security.utils.ObjectIdentifier oid1, org.apache.harmony.security.utils.ObjectIdentifier oid2)
compares two Object identifiers

param
oid1 first OID
param
oid2 second OID
return
-1 of first OID "less" than second OID 1 otherwise, 0 if they are equal

        if (oid1 == oid2) {
            return 0;
        }

        int[] ioid1 = oid1.getOid();
        int[] ioid2 = oid2.getOid();
        int min = ioid1.length < ioid2.length ? ioid1.length : ioid2.length;
        for (int i = 0; i < min; ++i) {
            if (ioid1[i] < ioid2[i]) {
                return -1;
            }
            if (ioid1[i] > ioid2[i]) {
                return 1;
            }
            if ((i + 1) == ioid1.length && (i + 1) < ioid2.length) {
                return -1;
            }
            if ((i + 1) < ioid1.length && (i + 1) == ioid2.length) {
                return 1;
            }
        }
        return 0;
    
public booleanequals(java.lang.Object obj)

return
false

        return false;