*** jdbm.java.orig Fri Jun 19 07:46:51 1998 --- jdbm.java Mon Jun 7 20:41:38 1999 *************** *** 724,729 **** --- 724,757 ---- bucket.add (hashval, key, value) ; } + /** Store the data for the given key in the specified + * S_ mode. + * @param key the bytes of the key. + * @param data the bytes of the key. + * @param mode the S_ mode. + * @return the data bytes stored for the key. + * @exception IOException for whatever + */ + public void store(String key, byte data[], int mode) + throws IOException + { + store(key.getBytes(), data, mode); + } + + /** Store the data for the given key in the specified + * S_ mode. + * @param key the bytes of the key. + * @param data the bytes of the key. + * @param mode the S_ mode. + * @return the data bytes stored for the key. + * @exception IOException for whatever + */ + public void store(String key, String data, int mode) + throws IOException + { + store(key.getBytes(), data.getBytes(), mode); + } + /** * Lookup the value associated with the provided key. * @param key The bits of the key to look for. *************** *** 753,761 **** // FIXME: the min is that the buffer is not allocated on each lookup byte b[] = new byte[key.length()] ; key.getBytes(0, b.length, b, 0) ; ! return lookup(b) ; } /** * Delete the association for the provided key. * @param key The key of the element to remove. --- 781,839 ---- // FIXME: the min is that the buffer is not allocated on each lookup byte b[] = new byte[key.length()] ; key.getBytes(0, b.length, b, 0) ; ! return lookup(b); } + /** Fetch the data if the given key exists in the data base + * @param key the bytes of the key. + * @return the data bytes stored for the key. + * @exception IOException for whatever + */ + public byte[] fetch(byte key[]) + throws IOException + { return lookup(key); } + + /** Fetch the data if the given key exists in the data base + * @param key the bytes of the key. + * @return the data bytes stored for the key. + * @exception IOException for whatever + */ + public String fetch(String key) + throws IOException + { + byte[] buf = lookup(key.getBytes()); + if(buf != null) + return new String(buf); + else + return null; + } + + /** Fetch the data if the given key exists in the data base + * @param key the bytes of the key. + * @return the data bytes stored for the key. + * @exception IOException for whatever + */ + public byte[] fetchBytes(String key) + throws IOException + { + return lookup(key.getBytes()); + } + + /** Fetch the data if the given key exists in the data base + * @param key the bytes of the key. + * @return the data bytes stored for the key. + * @exception IOException for whatever + */ + public String fetchString(byte key[]) + throws IOException + { + byte[] buf = lookup(key); + if(buf != null) + return new String(buf); + else + return null; + } + /** * Delete the association for the provided key. * @param key The key of the element to remove. *************** *** 822,827 **** --- 900,915 ---- // Write any modified bucket list.saveModified(this) ; } + + /** Opens a database file in the specified O_ mode. + * @param filename the database file name. + * @exception IOException if a problem with the file occurs + */ + public jdbm(String filename) + throws IOException + { + this(new File(filename)); + } public jdbm (File file) throws IOException