⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 villa.java

📁 harvest是一个下载html网页得机器人
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   */  public int fsiz() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      int rv = vlfsiz(index);      if(rv == -1) throw new VillaException(vlecode());      return rv;    }  }  /**   * Get the number of the leaf nodes of B+ tree.   * @return the number of the leaf nodes.   * @throws VillaException if an error occures.   */  public int lnum() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      int rv = vllnum(index);      if(rv == -1) throw new VillaException(vlecode());      return rv;    }  }  /**   * Get the number of the non-leaf nodes of B+ tree.   * @return the number of the non-leaf nodes.   * @throws VillaException if an error occures.   */  public int nnum() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      int rv = vlnnum(index);      if(rv == -1) throw new VillaException(vlecode());      return rv;    }  }  /**   * Get the number of the records stored in a database.   * @return the number of the records stored in the database.   * @throws VillaException if an error occures.   */  public int rnum() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      int rv = vlrnum(index);      if(rv == -1) throw new VillaException(vlecode());      return rv;    }  }  /**   * Check whether the database handle is a writer or not.   * @return true if the handle is a writer, false if not.   * @throws VillaException if an error occures.   */  public boolean writable() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      return vlwritable(index) == 0 ? false : true;    }  }  /**   * Check whether the database has a fatal error or not.   * @return true if the database has a fatal error, false if not.   * @throws VillaException if an error occures.   */  public boolean fatalerror() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      return vlfatalerror(index) == 0 ? false : true;    }  }  /**   * Begin the transaction.   * @throws VillaException if an error occures.   * @note If a thread is already in the transaction, the other threads block until the prius   * is out of the transaction.  Only one transaction can be activated with a database handle   * at the same time.   */  public void tranbegin() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(tranmonitor){      while(tran){        try {          tranmonitor.wait();        } catch(InterruptedException e){          e.printStackTrace();          throw new VillaException();        }      }      tran = true;    }    synchronized(ADBM.class){      if(vltranbegin(index) == 0){        tran = false;        throw new VillaException(vlecode());      }    }  }  /**   * Commit the transaction.   * @throws VillaException if an error occures.   * @note Updating a database in the transaction is fixed when it is committed successfully.   * Any other thread except for the one which began the transaction should not call this method.   */  public void trancommit() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      if(vltrancommit(index) == 0){        synchronized(tranmonitor){          tran = false;          tranmonitor.notify();        }        throw new VillaException(vlecode());      }    }    synchronized(tranmonitor){      tran = false;      tranmonitor.notify();    }  }  /**   * Abort the transaction.   * @throws VillaException if an error occures.   * @note Updating a database in the transaction is discarded when it is aborted.  The state   * of the database is rollbacked to before transaction.  Any other thread except for the one   * which began the transaction should not call this method.   */  public void tranabort() throws VillaException {    if(index < 0) throw new VillaException();    synchronized(ADBM.class){      if(vltranabort(index) == 0){        synchronized(tranmonitor){          tran = false;          tranmonitor.notify();        }        throw new VillaException(vlecode());      }    }    synchronized(tranmonitor){      tran = false;      tranmonitor.notify();    }  }  /**   * Store a record.   * @param key a byte array of a key.   * @param val a byte array of a value.   * @param replace whether the existing value is to be overwritten or not.   * @throws VillaException if an error occures or replace is cancelled.   */  public void store(byte[] key, byte[] val, boolean replace) throws VillaException {    put(key, val, replace ? DOVER : DKEEP);  }  /**   * Delete a record.   * @param key a byte array of a key.   * @throws VillaException if an error occures or no record corresponds.   */  public void delete(byte[] key) throws VillaException {    out(key);  }  /**   * Fetch a record.   * @param key a byte array of a key.   * @return a byte array of the value of the corresponding record.   * @throws VillaException if an error occures or no record corresponds.   */  public byte[] fetch(byte[] key) throws VillaException {    return get(key);  }  /**   * Get the first key.   * @return a byte array of the key of the first record.   * @throws VillaException if an error occures or no record corresponds.   */  public byte[] firstkey() throws VillaException {    curfirst();    return curkey();  }  /**   * Get the next key.   * @return a byte array of the key of the next record.   * @throws VillaException if an error occures or no record corresponds.   */  public byte[] nextkey() throws VillaException {    curnext();    return curkey();  }  /**   * Check whether a fatal error occured or not.   * @return true if the database has a fatal error, false if not.   * @throws VillaException if an error occures.   */  public boolean error() throws VillaException {    return fatalerror();  }  //----------------------------------------------------------------  // private methods  //----------------------------------------------------------------  /**   * Compare keys of two records as serialized objects implementing `java.util.Comparable'.   * @param abuf serialized data of one object.   * @param bbuf serialized data of the other object.   * @return positive if the former is big, negative if the latter is big, 0 if both are   * equivalent.   */  private static final int objcompare(byte[] abuf, byte[] bbuf){    Object a = Util.deserialize(abuf);    Object b = Util.deserialize(bbuf);    if(a != null && b == null) return 1;    if(a == null && b != null) return -1;    if(a == null && b == null) return 0;    try {      return ((Comparable)a).compareTo(b);    } catch(ClassCastException e){      return 0;    }  }  //----------------------------------------------------------------  // native methods  //----------------------------------------------------------------  private static synchronized final native void vlinit();  private static synchronized final native String vlversion();  private static synchronized final native int vlecode();  private static synchronized final native String vlerrmsg(int ecode);  private static synchronized final native int vlopen(String name, int omode, int cmode);  private static synchronized final native int vlclose(int index);  private static synchronized final native int vlput(int index, byte[] key, int ksiz,                                                     byte[] val, int vsiz, int dmode);  private static synchronized final native int vlout(int index, byte[] key, int ksiz);  private static synchronized final native byte[] vlget(int index, byte[] key, int ksiz);  private static synchronized final native int vlvnum(int index, byte[] key, int ksiz);  private static synchronized final native int vlcurfirst(int index);  private static synchronized final native int vlcurlast(int index);  private static synchronized final native int vlcurprev(int index);  private static synchronized final native int vlcurnext(int index);  private static synchronized final native int vlcurjump(int index, byte[] key, int ksiz,                                                         int jmode);  private static synchronized final native byte[] vlcurkey(int index);  private static synchronized final native byte[] vlcurval(int index);  private static synchronized final native void vlsettuning(int index, int lrecmax, int nidxmax,                                                            int lcnum, int ncnum);  private static synchronized final native int vlsync(int index);  private static synchronized final native int vloptimize(int index);  private static synchronized final native String vlname(int index);  private static synchronized final native int vlfsiz(int index);  private static synchronized final native int vllnum(int index);  private static synchronized final native int vlnnum(int index);  private static synchronized final native int vlrnum(int index);  private static synchronized final native int vlwritable(int index);  private static synchronized final native int vlfatalerror(int index);  private static synchronized final native int vltranbegin(int index);  private static synchronized final native int vltrancommit(int index);  private static synchronized final native int vltranabort(int index);  private static synchronized final native int vlremove(String name);}/* END OF FILE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -