InformationObjectSetpublic class InformationObjectSet extends Object Represents Information Object Set. |
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.Object | get(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 int | hashIntArray(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 void | put(org.apache.harmony.security.x501.AttributeType at)
put(at.oid.getOid(), at);
| public void | put(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);
|
|