|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectqdbm.Depot
public class Depot
The Java API of Depot, the basic API of QDBM. This class depends on the native library `jqdbm'.
Field Summary | |
---|---|
static int |
DCAT
write mode: concatenate values |
static int |
DKEEP
write mode: keep the existing value |
static int |
DOVER
write mode: overwrite the existing value |
static int |
EALLOC
error code: memory allocation error |
static int |
EBROKEN
error code: broken database file |
static int |
ECLOSE
error code: close error |
static int |
EFATAL
error code: with fatal error |
static int |
EKEEP
error code: existing record |
static int |
ELOCK
error code: lock error |
static int |
EMAP
error code: memory mapping error |
static int |
EMISC
error code: miscellaneous error |
static int |
EMKDIR
error code: mkdir error |
static int |
EMODE
error code: invalid mode |
static int |
ENOERR
error code: no error |
static int |
ENOITEM
error code: no item found |
static int |
EOPEN
error code: open error |
static int |
EREAD
error code: read error |
static int |
ERMDIR
error code: rmdir error |
static int |
ESEEK
error code: seek error |
static int |
ESTAT
error code: stat error |
static int |
ESYNC
error code: sync error |
static int |
ETRUNC
error code: trunc error |
static int |
EUNLINK
error code: unlink error |
static int |
EWRITE
error code: write error |
static int |
OCREAT
open mode: writer creating |
static int |
OLCKNB
open mode: lock without blocking |
static int |
ONOLCK
open mode: open without locking |
static int |
OREADER
open mode: open as a reader |
static int |
OSPARSE
open mode: create as a sparse file |
static int |
OTRUNC
open mode: writer truncating |
static int |
OWRITER
open mode: open as a writer |
boolean |
silent
Whether to repress frequent exceptions. |
Constructor Summary | |
---|---|
Depot(java.lang.String name)
Get the database handle as a reader. |
|
Depot(java.lang.String name,
int omode,
int bnum)
Get the database handle. |
Method Summary | |
---|---|
int |
bnum()
Get the number of the elements of the bucket array. |
int |
busenum()
Get the number of the used elements of the bucket array. |
void |
close()
Close the database handle. |
void |
delete(byte[] key)
Delete a record. |
static java.lang.String |
errmsg(int ecode)
Get an error message. |
boolean |
error()
Check whether a fatal error occured or not. |
boolean |
fatalerror()
Check whether the database has a fatal error or not. |
byte[] |
fetch(byte[] key)
Fetch a record. |
protected void |
finalize()
Release the resources. |
byte[] |
firstkey()
Get the first key. |
int |
fsiz()
Get the size of the database file. |
byte[] |
get(byte[] key)
Retrieve whole value of a record. |
byte[] |
get(byte[] key,
int start,
int max)
Retrieve a record. |
int |
inode()
Get the inode number of the database. |
void |
iterinit()
Initialize the iterator of the database handle. |
byte[] |
iternext()
Get the next key of the iterator. |
long |
mtime()
Get the last modified time of the database. |
java.lang.String |
name()
Get the name of the database. |
byte[] |
nextkey()
Get the next key. |
void |
optimize(int bnum)
Optimize the database. |
boolean |
out(byte[] key)
Delete a record. |
boolean |
put(byte[] key,
byte[] val)
Store a record with overwrite. |
boolean |
put(byte[] key,
byte[] val,
int dmode)
Store a record. |
static void |
remove(java.lang.String name)
Remove a database file. |
int |
rnum()
Get the number of the records stored in the database. |
void |
setalign(int align)
Set alignment of the database handle. |
void |
setfbpsiz(int size)
Set the size of the free block pool. |
static byte[] |
snaffle(java.lang.String name,
byte[] key)
Retrieve a record directly from a database file. |
void |
store(byte[] key,
byte[] val,
boolean replace)
Store a record. |
void |
sync()
Synchronize updating contents with the file and the device. |
static java.lang.String |
version()
Get the version information. |
int |
vsiz(byte[] key)
Get the size of the value of a record. |
boolean |
writable()
Check whether the database handle is a writer or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DCAT
public static final int DKEEP
public static final int DOVER
public static final int EALLOC
public static final int EBROKEN
public static final int ECLOSE
public static final int EFATAL
public static final int EKEEP
public static final int ELOCK
public static final int EMAP
public static final int EMISC
public static final int EMKDIR
public static final int EMODE
public static final int ENOERR
public static final int ENOITEM
public static final int EOPEN
public static final int EREAD
public static final int ERMDIR
public static final int ESEEK
public static final int ESTAT
public static final int ESYNC
public static final int ETRUNC
public static final int EUNLINK
public static final int EWRITE
public static final int OCREAT
public static final int OLCKNB
public static final int ONOLCK
public static final int OREADER
public static final int OSPARSE
public static final int OTRUNC
public static final int OWRITER
public boolean silent
Constructor Detail |
---|
public Depot(java.lang.String name) throws DepotException
DepotException
Depot(java.lang.String, int, int)
public Depot(java.lang.String name, int omode, int bnum) throws DepotException
name
- the name of a database file.omode
- the connection mode: `Depot.OWRITER' as a writer, `Depot.OREADER' as
a reader. If the mode is `Depot.OWRITER', the following may be added by bitwise or:
`Depot.OCREAT', which means it creates a new database if not exist, `Depot.OTRUNC',
which means it creates a new database regardless if one exists. Both of `Depot.OREADER'
and `Depot.OWRITER' can be added to by bitwise or: `Depot.ONOLCK', which means it opens a
database file without file locking, or `Depot.OLCKNB', which means locking is performed
without blocking. `Depot.OCREAT' can be added to by bitwise or: `Depot.OSPARSE', which
means it creates a database file as a sparse file.bnum
- the number of elements of the bucket array. If it is not more than 0,
the default value is specified. The size of a bucket array is determined on creating,
and can not be changed except for by optimization of the database. Suggested size of a
bucket array is about from 0.5 to 4 times of the number of all records to store.
DepotException
- if an error occurs.Method Detail |
---|
public int bnum() throws DepotException
DepotException
- if an error occurs.public int busenum() throws DepotException
DepotException
- if an error occurs.public void close() throws DepotException
close
in interface ADBM
DepotException
- if an error occurs.public void delete(byte[] key) throws DepotException
delete
in interface ADBM
key
- a byte array of a key.
DepotException
- if an error occurs or no record corresponds.public static java.lang.String errmsg(int ecode)
ecode
- an error code.
public boolean error() throws DepotException
error
in interface ADBM
DepotException
- if an error occurs.public boolean fatalerror() throws DepotException
DepotException
- if an error occurs.public byte[] fetch(byte[] key) throws DepotException
fetch
in interface ADBM
key
- a byte array of a key.
DepotException
- if an error occurs or no record corresponds.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public byte[] firstkey() throws DepotException
firstkey
in interface ADBM
DepotException
- if an error occurs or no record corresponds.public int fsiz() throws DepotException
DepotException
- if an error occurs.public byte[] get(byte[] key) throws DepotException
DepotException
get(byte[], int, int)
public byte[] get(byte[] key, int start, int max) throws DepotException
key
- a byte array of a key.start
- the array index of the beginning of the value to be read.max
- the max size to read with. If it is negative, the size is unlimited.
DepotException
- if an error occurs, no record corresponds, or the size of the value
of the corresponding record is less than the index specified by the parameter `start'.public int inode() throws DepotException
DepotException
- if an error occurs.public void iterinit() throws DepotException
DepotException
- if an error occurs.public byte[] iternext() throws DepotException
DepotException
- if an error occurs or no record corresponds.public long mtime() throws DepotException
DepotException
- if an error occurs.public java.lang.String name() throws DepotException
DepotException
- if an error occurs.public byte[] nextkey() throws DepotException
nextkey
in interface ADBM
DepotException
- if an error occurs or no record corresponds.public void optimize(int bnum) throws DepotException
bnum
- the number of the elements of the bucket array. If it is not more than 0, the
default value is specified.
DepotException
- if an error occurs.public boolean out(byte[] key) throws DepotException
key
- a byte array of a key.
DepotException
- if an error occurs or no record corresponds.public boolean put(byte[] key, byte[] val) throws DepotException
DepotException
put(byte[], byte[], int)
public boolean put(byte[] key, byte[] val, int dmode) throws DepotException
key
- a byte array of a key.val
- a byte array of a value.dmode
- behavior when the key overlaps, by the following values: `Depot.DOVER',
which means the specified value overwrites the existing one, `Depot.DKEEP', which means the
existing value is kept, `Depot.DCAT', which means the specified value is concatenated at
the end of the existing value.
DepotException
- if an error occurs or replace is cancelled.public static void remove(java.lang.String name) throws DepotException
name
- the name of a database file.
DepotException
- if an error occurs.public int rnum() throws DepotException
DepotException
- if an error occurs.public void setalign(int align) throws DepotException
align
- the basic size of alignment.
DepotException
- if an error occurs.public void setfbpsiz(int size) throws DepotException
size
- the size of the free block pool of a database.
DepotException
- if an error occurs.public static byte[] snaffle(java.lang.String name, byte[] key) throws DepotException
name
- the name of a database file.key
- a byte array of a key.
DepotException
- if an error occurs or no record corresponds.public void store(byte[] key, byte[] val, boolean replace) throws DepotException
store
in interface ADBM
key
- a byte array of a key.val
- a byte array of a value.replace
- whether the existing value is to be overwritten or not.
DepotException
- if an error occurs or replace is cancelled.public void sync() throws DepotException
DepotException
- if an error occurs.public static java.lang.String version()
public int vsiz(byte[] key) throws DepotException
key
- a byte array of a key.
DepotException
- if an error occurs or no record corresponds.public boolean writable() throws DepotException
DepotException
- if an error occurs.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |