FileDocCategorySizeDatePackage
InformationObjectSet.javaAPI DocAndroid 1.5 API3008Wed May 06 22:41:06 BST 2009org.apache.harmony.security.asn1

InformationObjectSet

public class InformationObjectSet extends Object
Represents Information Object Set.
see
ASN.1

Fields Summary
private final int
capacity
private final Entry[]
pool
Constructors Summary
public InformationObjectSet()

        this(64, 10);
    
public InformationObjectSet(int capacity, int size)

        this.capacity = capacity;
        pool = new Entry[capacity][size];
    
Methods Summary
public java.lang.Objectget(int[] oid)

        int index = hashIntArray(oid) % capacity;

        // look for OID in the pool 
        Entry[] list = pool[index];
        for (int i = 0; list[i] != null; i++) {
            if (Arrays.equals(oid, list[i].oid)) {
                return list[i].object;
            }
        }
        return null;
    
private inthashIntArray(int[] array)

        int intHash = 0;
        for (int i = 0; i < array.length && i < 4; i++) {
            intHash += array[i] << (8 * i); //TODO what about to find better one?
        }
        return intHash & 0x7FFFFFFF; // only positive
    
public voidput(org.apache.harmony.security.x501.AttributeType at)

        put(at.oid.getOid(), at);
    
public voidput(int[] oid, java.lang.Object object)


        int index = hashIntArray(oid) % capacity;
        // look for OID in the pool 
        Entry[] list = pool[index];
        int i = 0;
        for (; list[i] != null; i++) {

            // check wrong static initialization: no duplicate OIDs
            if (Arrays.equals(oid, list[i].oid)) {
                throw new Error(); //FIXME message
            }
        }

        // check : to avoid NPE
        if (i == (capacity - 1)) {
            throw new Error(); //FIXME message
        }
        list[i] = new Entry(oid, object);