Ignore:
Timestamp:
2010-01-01T23:35:24+13:00 (14 years ago)
Author:
davidb
Message:

Refactoring of class to use API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/src/jdbmedit/JdbGet.java

    r21395 r21402  
    66 * University of Waikato, New Zealand.
    77 *
    8  * Copyright (C) 1999  The New Zealand Digital Library Project
     8 * Copyright (C) 2009  The New Zealand Digital Library Project
    99 *
    1010 * This program is free software; you can redistribute it and/or modify
     
    3535public class JdbGet
    3636{
    37     static String TNAME = "greenstone";
    38 
    39     RecordManager  recman_;
    40     HTree          hashtable_;
    41 
    42 
    43     public JdbGet(String db_filename)
    44     throws IOException
    45     {
    46         // create or open a record manager
    47         Properties props = new Properties();
    48         recman_ = RecordManagerFactory.createRecordManager(db_filename, props);
    49 
    50         // create or load table
    51         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 IOException
    64     {
    65     FastIterator   iter;
    66     String         val;
    67 
    68     val = (String) hashtable_.get(key);
    69     System.out.println(val);
    70        
    71         recman_.close();
    72     }
    73 
    7437
    7538    public static void print_usage()
     
    9154        try {
    9255
    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();
    9561        }
    9662    catch (IOException e) {
Note: See TracChangeset for help on using the changeset viewer.