1 package com.daffodilwoods.daffodildb.server.datasystem.indexsystem; 2 3 import java.util.*; 4 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 5 import com.daffodilwoods.database.general.*; 6 import com.daffodilwoods.database.resource.DException; 7 import com.daffodilwoods.daffodildb.server.datasystem.persistentsystem.PersistentSystem; 8 9 31 public class IndexSystem implements _DataSystem { 32 33 36 37 private _DataSystem dataSystem; 38 39 43 44 private HashMap databaseMap; 45 46 49 50 51 private boolean isReadOnlyMode = false; 52 53 public IndexSystem(_DataSystem dataSystem0,boolean isReadOnlyMode0) { 54 dataSystem = dataSystem0; 55 databaseMap = new HashMap(); 56 isReadOnlyMode = isReadOnlyMode0 ; 57 } 58 59 62 63 public IndexSystem(_DataSystem dataSystem0, _MemoryManager manager0) { 64 dataSystem = dataSystem0; 65 databaseMap = new HashMap(); 66 } 67 68 69 75 76 77 public synchronized _Database getDatabase(String databaseName) throws DException { 78 _IndexDatabase indexDatabase = (_IndexDatabase)databaseMap.get(databaseName); 79 if(indexDatabase != null) 80 return indexDatabase; 81 indexDatabase = new IndexDatabase(dataSystem.getDatabase(databaseName),isReadOnlyMode); 82 databaseMap.put(databaseName,indexDatabase); 83 return indexDatabase; 84 } 85 86 92 93 94 public synchronized void dropDatabase(String databaseName) throws DException { 95 dataSystem.dropDatabase(databaseName); 96 databaseMap.remove(databaseName); 97 } 98 99 public synchronized void createDatabase(String databaseName, Properties prop) throws DException { 100 dataSystem.createDatabase(databaseName,prop); 101 } 102 103 106 107 public void removeDatabase(String databaseURL) throws DException{ 108 dataSystem.removeDatabase(databaseURL); 109 databaseMap.remove(databaseURL); 110 } 111 112 public _DataSystem getDataSystem(){ 113 return dataSystem; 114 } 115 116 119 120 public _Database createSystemDatabase(String path0, String initialSize, int incrementFactor, boolean unicodeSupport, boolean multifileSupport) throws DException{ 121 if( dataSystem instanceof PersistentSystem ) 122 return ((PersistentSystem)dataSystem).createSystemDatabase(path0,initialSize,incrementFactor,unicodeSupport,multifileSupport); 123 else 124 return null; 125 } 126 } 127 | Popular Tags |