- Timestamp:
- 2010-01-01T23:35:24+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/common-src/src/jdbmedit/JdbDel.java
r21395 r21402 6 6 * University of Waikato, New Zealand. 7 7 * 8 * Copyright (C) 1999 The New Zealand Digital Library Project8 * Copyright (C) 2009 The New Zealand Digital Library Project 9 9 * 10 10 * This program is free software; you can redistribute it and/or modify … … 38 38 public class JdbDel 39 39 { 40 static String TNAME = "greenstone";41 42 RecordManager recman_;43 HTree hashtable_;44 45 public JdbDel(String db_filename)46 throws IOException47 {48 // create or open a record manager49 Properties props = new Properties();50 recman_ = RecordManagerFactory.createRecordManager(db_filename, props);51 52 // load existing table (if exists) otherwise report error53 long recid = recman_.getNamedObject(TNAME);54 55 if (recid != 0) {56 System.out.println("Loading existing database table '" + TNAME +"' ...");57 hashtable_ = HTree.load(recman_, recid);58 }59 else {60 recman_.close();61 System.out.println("No database table '" + TNAME +"' to delete key from.");62 System.exit(-1);63 }64 }65 66 67 public void del(String key)68 throws IOException69 {70 hashtable_.remove(key);71 recman_.close();72 }73 74 75 40 public static void print_usage() 76 41 { … … 91 56 try { 92 57 String dbname = args[0]; 93 Jdb Del table = new JdbDel(dbname);58 JdbmAPI jdbm_api = new JdbmAPI(dbname,true); 94 59 95 60 String key = args[1]; 96 table.del(key); 61 62 jdbm_api.delete(key); 63 jdbm_api.close(); 97 64 } 98 65
Note:
See TracChangeset
for help on using the changeset viewer.