| 
 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectqdbm.Villa
public class Villa
The Java API of Villa, the advanced API of QDBM. This class depends on the native library `jqdbm'.
| Field Summary | |
|---|---|
| static int | CMPDECcomparing mode: compare as decimal strings | 
| static int | CMPLEXcomparing mode: compare by lexical order | 
| static int | CMPNUMcomparing mode: compare as long integers | 
| static int | CMPOBJcomparing mode: compare as comparable objects | 
| static int | CPAFTERinsertion mode: insert after the current record | 
| static int | CPBEFOREinsertion mode: insert before the current record | 
| static int | CPCURRENTinsertion mode: overwrite the current record | 
| static int | DCATwrite mode: concatenate values | 
| static int | DDUPwrite mode: allow duplication of records | 
| static int | DDUPRwrite mode: allow duplication with reverse order | 
| static int | DKEEPwrite mode: keep the existing value | 
| static int | DOVERwrite mode: overwrite the existing value | 
| static int | EALLOCerror code: memory allocation error | 
| static int | EBROKENerror code: broken database file | 
| static int | ECLOSEerror code: close error | 
| static int | EFATALerror code: with fatal error | 
| static int | EKEEPerror code: existing record | 
| static int | ELOCKerror code: lock error | 
| static int | EMAPerror code: memory mapping error | 
| static int | EMISCerror code: miscellaneous error | 
| static int | EMKDIRerror code: mkdir error | 
| static int | EMODEerror code: invalid mode | 
| static int | ENOERRerror code: no error | 
| static int | ENOITEMerror code: no item found | 
| static int | EOPENerror code: open error | 
| static int | EREADerror code: read error | 
| static int | ERMDIRerror code: rmdir error | 
| static int | ESEEKerror code: seek error | 
| static int | ESTATerror code: stat error | 
| static int | ESYNCerror code: sync error | 
| static int | ETRUNCerror code: trunc error | 
| static int | EUNLINKerror code: unlink error | 
| static int | EWRITEerror code: write error | 
| static int | JBACKWARDjump mode: jump mode: step backward | 
| static int | JFORWARDjump mode: jump mode: step forward | 
| static int | OCREATopen mode: writer creating | 
| static int | OLCKNBopen mode: lock without blocking | 
| static int | ONOLCKopen mode: open without locking | 
| static int | OREADERopen mode: open as a reader | 
| static int | OTRUNCopen mode: writer truncating | 
| static int | OWRITERopen mode: open as a writer | 
| static int | OXCOMPopen mode: compress leaves with BZIP2 | 
| static int | OYCOMPopen mode: compress leaves with LZO | 
| static int | OZCOMPopen mode: compress leaves with ZLIB | 
|  boolean | silentWhether to repress frequent exceptions. | 
| Constructor Summary | |
|---|---|
| Villa(java.lang.String name)Get the database handle as a reader. | |
| Villa(java.lang.String name,
      int omode,
      int cmode)Get the database handle. | |
| Method Summary | |
|---|---|
|  void | close()Close the database handle. | 
|  boolean | curfirst()Move the cursor to the first record. | 
|  boolean | curjump(byte[] key)Move the cursor to a position around a record for stepping forward. | 
|  boolean | curjump(byte[] key,
        int jmode)Move the cursor to a position around a record. | 
|  boolean | curjumpobj(java.lang.Object key,
           int jmode)Move the cursor to a position around a record composed of serializable objects. | 
|  byte[] | curkey()Get the key of the record where the cursor is. | 
|  java.lang.Object | curkeyobj()Get the key of the record composed of serializable objects, where the cursor is. | 
|  boolean | curlast()Move the cursor to the last record. | 
|  boolean | curnext()Move the cursor to the next record. | 
|  boolean | curout()Delete the record where the cursor is. | 
|  boolean | curprev()Move the cursor to the next record. | 
|  boolean | curput(byte[] val)Insert a record as the successor of the cursor. | 
|  boolean | curput(byte[] val,
       int cpmode)Insert a record around the cursor. | 
|  boolean | curputobj(java.lang.Object val,
          int cpmode)Insert a record around the cursor. | 
|  byte[] | curval()Get the value of the record where the cursor is. | 
|  java.lang.Object | curvalobj()Get the value of the record where the cursor is. | 
|  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 a record. | 
|  int | getindex()Get the index of the native table for database handles. | 
|  java.lang.Object | getobj(java.lang.Object key)Retrieve a record composed of serializable objects. | 
|  int | inode()Get the inode number of the database. | 
|  int | lnum()Get the number of the leaf nodes of B+ tree. | 
|  long | mtime()Get the last modified time of the database. | 
|  VillaCursor | mulcuropen()Get a multiple cursor. | 
|  java.lang.String | name()Get the name of the database. | 
|  byte[] | nextkey()Get the next key. | 
|  int | nnum()Get the number of the non-leaf nodes of B+ tree. | 
|  void | optimize()Optimize the database. | 
|  boolean | out(byte[] key)Delete a record. | 
|  boolean | outobj(java.lang.Object key)Delete a record composed of serializable objects. | 
|  boolean | put(byte[] key,
    byte[] val)Store a record with overwrite. | 
|  boolean | put(byte[] key,
    byte[] val,
    int dmode)Store a record. | 
|  boolean | putobj(java.lang.Object key,
       java.lang.Object val,
       int dmode)Store a record composed of serializable objects. | 
| static void | remove(java.lang.String name)Remove a database file. | 
|  int | rnum()Get the number of the records stored in a database. | 
|  void | settuning(int lrecmax,
          int nidxmax,
          int lcnum,
          int ncnum)Set the tuning parameters for performance. | 
|  void | store(byte[] key,
      byte[] val,
      boolean replace)Store a record. | 
|  void | sync()Synchronize updating contents with the file and the device. | 
|  void | tranabort()Abort the transaction. | 
|  void | tranbegin()Begin the transaction. | 
|  void | trancommit()Commit the transaction. | 
| static java.lang.String | version()Get the version information. | 
|  int | vnum(byte[] key)Get the number of records corresponding a key. | 
|  int | vnumobj(java.lang.Object key)Get the number of records corresponding a key, composed of serializable objects. | 
|  int | vsiz(byte[] key)Get the size of the value of a record. | 
|  int | vsizobj(java.lang.Object key)Get the size of the value of a record, composed of serializable objects. | 
|  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 CMPDEC
public static final int CMPLEX
public static final int CMPNUM
public static final int CMPOBJ
public static final int CPAFTER
public static final int CPBEFORE
public static final int CPCURRENT
public static final int DCAT
public static final int DDUP
public static final int DDUPR
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 JBACKWARD
public static final int JFORWARD
public static final int OCREAT
public static final int OLCKNB
public static final int ONOLCK
public static final int OREADER
public static final int OTRUNC
public static final int OWRITER
public static final int OXCOMP
public static final int OYCOMP
public static final int OZCOMP
public boolean silent
| Constructor Detail | 
|---|
public Villa(java.lang.String name)
      throws VillaException
VillaExceptionVilla(java.lang.String, int, int)
public Villa(java.lang.String name,
             int omode,
             int cmode)
      throws VillaException
name - the name of a database file.omode - the connection mode: `Villa.OWRITER' as a writer, `Villa.OREADER' as
 a reader.  If the mode is `Villa.OWRITER', the following may be added by bitwise or:
 `Villa.OCREAT', which means it creates a new database if not exist, `Villa.OTRUNC',
 which means it creates a new database regardless if one exists, `Villa.OZCOMP', which means
 leaves in the database are compressed with ZLIB, `Villa.OYCOMP', which means leaves in the
 database are compressed with LZO, `Villa.OXCOMP', which means leaves in the database are
 compressed with BZIP2.  Both of `Villa.OREADER' and `Villa.OWRITER' can be added to by
 bitwise or: `Villa.ONOLCK', which means it opens a database file without file locking, or
 `Villa.OLCKNB', which means locking is performed without blocking.cmode - the comparing function: `Villa.CMPLEX' comparing keys in lexical order,
 `Villa.CMPNUM' comparing keys as numbers of big endian, `Villa.CMPDEC' comparing keys as
 decimal strings, `Villa.CMPOBJ' comparing keys as serialized objects implementing
 `java.util.Comparable'.  The comparing function should be kept same in the life of a
 database.
VillaException| Method Detail | 
|---|
public void close()
           throws VillaException
close in interface ADBMVillaException - if an error occurs.
public boolean curfirst()
                 throws VillaException
VillaException - if an error occurs or there is no record in the database.
public boolean curjump(byte[] key)
                throws VillaException
VillaExceptioncurjump(byte[], int)
public boolean curjump(byte[] key,
                       int jmode)
                throws VillaException
key - a byte array of a key.jmode - detail adjustment: `Villa.JFORWARD', which means that the cursor is set to
 the first record of the same key and that the cursor is set to the next substitute if
 completely matching record does not exist, `Villa.JBACKWARD', which means that the cursor
 is set to the last record of the same key and that the cursor is set to the previous
 substitute if completely matching record does not exist.
VillaException - if an error occurs or there is no record corresponding the condition.
public boolean curjumpobj(java.lang.Object key,
                          int jmode)
                   throws VillaException
VillaExceptioncurjump(byte[], int)
public byte[] curkey()
              throws VillaException
VillaException - if an error occurs or no record corresponds to the cursor.
public java.lang.Object curkeyobj()
                           throws VillaException
VillaExceptioncurkey()
public boolean curlast()
                throws VillaException
VillaException - if an error occurs or there is no record in the database.
public boolean curnext()
                throws VillaException
VillaException - if an error occurs or there is no next record.
public boolean curout()
               throws VillaException
VillaException - if an error occurs or no record corresponds to the cursor.
public boolean curprev()
                throws VillaException
VillaException - if an error occurs or there is no previous record.
public boolean curput(byte[] val)
               throws VillaException
VillaExceptioncurput(byte[], int)
public boolean curput(byte[] val,
                      int cpmode)
               throws VillaException
val - a byte array of a value.cpmode - detail adjustment: `Villa.CPCURRENT', which means that the value of the
 current record is overwritten, `Villa.CPBEFORE', which means that a new record is inserted
 before the current record, `Villa.CPAFTER', which means that a new record is inserted after
 the current record.
VillaException - if an error occurs or no record corresponds to the cursor.
public boolean curputobj(java.lang.Object val,
                         int cpmode)
                  throws VillaException
VillaExceptioncurput(byte[], int)
public byte[] curval()
              throws VillaException
VillaException - if an error occurs or no record corresponds to the cursor.
public java.lang.Object curvalobj()
                           throws VillaException
VillaExceptioncurval()
public void delete(byte[] key)
            throws VillaException
delete in interface ADBMkey - a byte array of a key.
VillaException - if an error occurs or no record corresponds.public static java.lang.String errmsg(int ecode)
ecode - an error code.
public boolean error()
              throws VillaException
error in interface ADBMVillaException - if an error occurs.
public boolean fatalerror()
                   throws VillaException
VillaException - if an error occurs.
public byte[] fetch(byte[] key)
             throws VillaException
fetch in interface ADBMkey - a byte array of a key.
VillaException - if an error occurs or no record corresponds.
protected void finalize()
                 throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
public byte[] firstkey()
                throws VillaException
firstkey in interface ADBMVillaException - if an error occurs or no record corresponds.
public int fsiz()
         throws VillaException
VillaException - if an error occurs.
public byte[] get(byte[] key)
           throws VillaException
key - a byte array of a key.
VillaException - if an error occurs, no record corresponds.public int getindex()
public java.lang.Object getobj(java.lang.Object key)
                        throws VillaException
VillaExceptionget(byte[])
public int inode()
          throws VillaException
VillaException - if an error occurs.
public int lnum()
         throws VillaException
VillaException - if an error occurs.
public long mtime()
           throws VillaException
VillaException - if an error occurs.
public VillaCursor mulcuropen()
                       throws VillaException
VillaException
public java.lang.String name()
                      throws VillaException
VillaException - if an error occurs.
public byte[] nextkey()
               throws VillaException
nextkey in interface ADBMVillaException - if an error occurs or no record corresponds.
public int nnum()
         throws VillaException
VillaException - if an error occurs.
public void optimize()
              throws VillaException
VillaException - if an error occurs.
public boolean out(byte[] key)
            throws VillaException
key - a byte array of a key.
VillaException - if an error occurs or no record corresponds.
public boolean outobj(java.lang.Object key)
               throws VillaException
VillaExceptionout(byte[])
public boolean put(byte[] key,
                   byte[] val)
            throws VillaException
VillaExceptionput(byte[], byte[], int)
public boolean put(byte[] key,
                   byte[] val,
                   int dmode)
            throws VillaException
key - a byte array of a key.val - a byte array of a value.dmode - behavior when the key overlaps, by the following values: `Villa.DOVER',
 which means the specified value overwrites the existing one, `Villa.DKEEP', which means
 the existing value is kept, `Villa.DCAT', which means the specified value is concatenated
 at the end of the existing value, `Villa.DDUP', which means duplication of keys is allowed
 and the specified value is added as the last one, `Villa.DDUPR', which means duplication of
 keys is allowed and the specified value is added as the first one.
VillaException - if an error occurs or replace is cancelled.
public boolean putobj(java.lang.Object key,
                      java.lang.Object val,
                      int dmode)
               throws VillaException
VillaExceptionput(byte[], byte[], int)
public static void remove(java.lang.String name)
                   throws VillaException
name - the name of a database file.
VillaException - if an error occurs.
public int rnum()
         throws VillaException
VillaException - if an error occurs.
public void settuning(int lrecmax,
                      int nidxmax,
                      int lcnum,
                      int ncnum)
               throws VillaException
lrecmax - the max number of records in a leaf node of B+ tree.  If it is not more
 than 0, the default value is specified.nidxmax - the max number of indexes in a non-leaf node of B+ tree.  If it is not more
 than 0, the default value is specified.lcnum - the max number of caching leaf nodes.  If it is not more than 0, the default
 value is specified.ncnum - the max number of caching non-leaf nodes.  If it is not more than 0, the
 default value is specified.
VillaException - if an error occurs.
public void store(byte[] key,
                  byte[] val,
                  boolean replace)
           throws VillaException
store in interface ADBMkey - a byte array of a key.val - a byte array of a value.replace - whether the existing value is to be overwritten or not.
VillaException - if an error occurs or replace is cancelled.
public void sync()
          throws VillaException
VillaException - if an error occurs.
public void tranabort()
               throws VillaException
VillaException - if an error occurs.
public void tranbegin()
               throws VillaException
VillaException - if an error occurs.
public void trancommit()
                throws VillaException
VillaException - if an error occurs.public static java.lang.String version()
public int vnum(byte[] key)
         throws VillaException
key - a byte array of a key.
VillaException - if an error occurs.
public int vnumobj(java.lang.Object key)
            throws VillaException
VillaExceptionvnum(byte[])
public int vsiz(byte[] key)
         throws VillaException
key - a byte array of a key.
VillaException - if an error occurs.
public int vsizobj(java.lang.Object key)
            throws VillaException
VillaExceptionvnum(byte[])
public boolean writable()
                 throws VillaException
VillaException - if an error occurs.| 
 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||