Methods Summary |
---|
protected void | checkInUse()
if (!inuse)
throw new IllegalStateException("Method called when DBM not open");
|
public void | close()Public wrapper for close method.
this.dbmclose();
inuse = false;
|
protected native int | dbmclose()
|
protected native byte[] | dbmfetch(byte[] key)
|
protected native int | dbminit(java.lang.String file)
|
protected native int | dbmstore(byte[] key, byte[] content)
|
protected native int | delete(java.lang.Object key)
|
public java.lang.Object | fetch(java.lang.Object key)Fetch using Objects
checkInUse();
byte[] datum = dbmfetch(toByteArray(key));
return toObject(datum);
|
public byte[] | fetch(byte[] key)Fetch using byte arrays
checkInUse();
return dbmfetch(key);
|
public native byte[] | firstkey()
|
public java.lang.Object | firstkeyObject()
return toObject(firstkey());
|
public native byte[] | nextkey(byte[] key)
|
public java.lang.Object | nextkey(java.lang.Object key)
byte[] ba = nextkey(toByteArray(key));
if (ba == null)
return null;
return toObject(ba);
|
public void | store(byte[] key, byte[] value)Store using byte arrays
checkInUse();
dbmstore(key, value);
|
public void | store(java.lang.Object key, java.lang.Object value)Store using Objects
checkInUse();
dbmstore(toByteArray(key), toByteArray(value));
|
protected byte[] | toByteArray(java.lang.Object o)serialize an Object to byte array.
if (bo == null)
bo = new ByteArrayOutputStream(1024);
bo.reset();
ObjectOutputStream os = new ObjectOutputStream(bo);
os.writeObject(o);
os.close();
return bo.toByteArray();
|
protected java.lang.Object | toObject(byte[] b)un-serialize an Object from a byte array.
Object o;
ByteArrayInputStream bi = new ByteArrayInputStream(b);
ObjectInputStream os = new ObjectInputStream(bi);
try {
o = os.readObject();
} catch (ClassNotFoundException ex) {
// Convert ClassNotFoundException to I/O error
throw new IOException(ex.getMessage());
}
os.close();
return o;
|
public java.lang.String | toString()
return "DBM@" + hashCode() + "[" + fileName + "]";
|