- 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/JdbGet.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 … … 35 35 public class JdbGet 36 36 { 37 static String TNAME = "greenstone";38 39 RecordManager recman_;40 HTree hashtable_;41 42 43 public JdbGet(String db_filename)44 throws IOException45 {46 // create or open a record manager47 Properties props = new Properties();48 recman_ = RecordManagerFactory.createRecordManager(db_filename, props);49 50 // create or load table51 long recid = recman_.getNamedObject(TNAME);52 if (recid != 0) {53 hashtable_ = HTree.load(recman_, recid);54 }55 else {56 System.err.println("Failed to find database table '" + TNAME +"' ...");57 System.exit(-1);58 }59 }60 61 62 public void get(String key)63 throws IOException64 {65 FastIterator iter;66 String val;67 68 val = (String) hashtable_.get(key);69 System.out.println(val);70 71 recman_.close();72 }73 74 37 75 38 public static void print_usage() … … 91 54 try { 92 55 93 JdbGet table = new JdbGet(dbname); 94 table.get(key); 56 JdbmAPI jdbm_api = new JdbmAPI(dbname,true); 57 String val = jdbm_api.get(key); 58 System.out.println(val); 59 60 jdbm_api.close(); 95 61 } 96 62 catch (IOException e) {
Note:
See TracChangeset
for help on using the changeset viewer.