strangedb/src/main/java/org/warp/jcwdb/ann/JCWDatabase.java

36 lines
819 B
Java

package org.warp.jcwdb.ann;
import java.io.IOException;
import java.nio.file.Path;
public class JCWDatabase {
private final DatabaseManager database;
public JCWDatabase(Path dataFile, Path metadataFile, boolean registrationRequired) throws IOException {
this.database = new DatabaseManager(this, dataFile, metadataFile, registrationRequired);
}
public <T extends DBObject> T loadRoot(Class<T> rootClass) {
try {
return database.loadRoot(rootClass);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
DatabaseManager getDatabaseManager() {
return database;
}
public void registerClass(Class<?> clazz, int id) {
if (id < 0) {
throw new IllegalArgumentException();
}
database.registerClass(clazz, id);
}
public void close() throws IOException {
database.close();
}
}