Ignore:
Timestamp:
2015-09-28T10:44:07+13:00 (9 years ago)
Author:
jmt12
Message:

Added a function to allow databases to register themselves (and their file extension) with the DBHelper. Such registration should be done in a static block in the database wrapper. Also removed the hardcoded entries for gdbm and jdbm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DBHelper.java

    r24393 r30261  
    2323public class DBHelper
    2424{
    25     protected static final HashMap<String, String> _extMap;
    26     static
    27     {
    28         HashMap<String, String> extMap = new HashMap<String, String>();
    29         extMap.put("jdbm", ".jdb");
    30         extMap.put("gdbm", ".gdb");
    31         _extMap = extMap;
    32     }
    33    
    34     public static String getDBExtFromDBType(String dbtype)
    35     {
    36         return _extMap.get(dbtype);
    37     }
     25    protected static final HashMap<String, String> _extMap = new HashMap<String, String>();
     26
     27    public static String getDBExtFromDBType(String dbtype)
     28    {
     29    String lc_dbtype = dbtype.toLowerCase();
     30    return _extMap.get(lc_dbtype);
     31    }
     32
     33    /** @function registerDBTypeExt(String, String)
     34     *
     35     *  Given a database type name and the matching extension, register in
     36     *  the static hashmap of mappings.
     37     *
     38     *  @param dbtype a String containing the database type's name
     39     *  @param dbext a String containing the database type's extension
     40     *
     41     */
     42    public static void registerDBTypeExt(String dbtype, String dbext)
     43    {
     44    _extMap.put(dbtype, dbext);
     45    }
     46    /** registerDBTypeExt(String, String) **/
    3847}
Note: See TracChangeset for help on using the changeset viewer.