Changeset 22973 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/SimpleCollectionDatabase.java
- Timestamp:
- 2010-09-28T10:18:57+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/SimpleCollectionDatabase.java
r22319 r22973 33 33 34 34 public SimpleCollectionDatabase(String db_type) { 35 if (db_type.equalsIgnoreCase("gdbm")) { 36 this.coll_db = new GDBMWrapper(); 37 } 38 else if (db_type.equalsIgnoreCase("jdbm")) { 39 this.coll_db = new JDBMWrapper(); 40 } 41 else { 42 logger.error("Couldn't create SimpleCollectionDatabase of type "+db_type); 43 } 44 } 45 35 36 // Access databaseWrapper through reflection (forName) so code 37 // can be more dynamic as to the database backends that are 38 // supported for this installation of Greenstone 39 40 String dbwrap_name = db_type.toUpperCase() + "Wrapper"; 41 Class dbwrap_class = null; 42 43 try { 44 String full_dbwrap_name = "org.greenstone.gsdl3.util."+dbwrap_name; 45 dbwrap_class = Class.forName(full_dbwrap_name); 46 } 47 catch(ClassNotFoundException e) { 48 try { 49 //try the dbwrap_name alone in case the package name is 50 //already specified 51 dbwrap_class = Class.forName(dbwrap_name); 52 } 53 catch(ClassNotFoundException ae) { 54 logger.error("Couldn't create SimpleCollectionDatabase of type "+db_type); 55 logger.info(ae.getMessage()); 56 } 57 } 58 59 try { 60 this.coll_db = (FlatDatabaseWrapper)dbwrap_class.newInstance(); 61 } 62 catch(Exception e) { 63 logger.error("Failed to call the constructor "+dbwrap_name+"()"); 64 } 65 66 67 } 68 69 public boolean databaseOK() { 70 // Previously failed to open database 71 // Most likely cause is that this installation of Greenstone3 has not 72 // been compiled with support for this database type 73 return coll_db != null; 74 } 75 46 76 /** open the database filename, with mode mode - uses the FlatDatabaseWrapper modes */ 47 77 public boolean openDatabase(String filename, int mode){ … … 59 89 // logger.warn("All the entries of the db are:"); 60 90 // this.coll_db.displayAllEntries(); 91 92 93 if (this.coll_db==null) { 94 // Most likely cause is that this installation of Greenstone3 has not 95 // been compiled with support for this database type 96 return null; 97 } 61 98 62 99 String key_info = this.coll_db.getValue(main_key);
Note:
See TracChangeset
for help on using the changeset viewer.