Package org.telegram.abilitybots.api.db
Class MapDBContext
- java.lang.Object
-
- org.telegram.abilitybots.api.db.MapDBContext
-
- All Implemented Interfaces:
Closeable,AutoCloseable,DBContext
public class MapDBContext extends Object implements DBContext
An implementation ofDBContextthat relies on aDB.- Author:
- Abbas Abou Daya
- See Also:
- MapDB project
-
-
Constructor Summary
Constructors Constructor Description MapDBContext(org.mapdb.DB db)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectbackup()Implementations of this method are free to return any object such as XML, JSON, etc...voidclear()Clears the data structures present in the database.voidclose()voidcommit()Commits the database to its persistent layer.booleancontains(String name)<T> List<T>getList(String name)<K,V>
Map<K,V>getMap(String name)<T> Set<T>getSet(String name)<T> Var<T>getVar(String name)Stringinfo(String name)static DBContextofflineInstance(String name)This DB returned by this method gets deleted on JVM shutdown.static DBContextonlineInstance(String name)This DB returned by this method does not trigger deletion on JVM shutdown.booleanrecover(Object backup)The object passed to this method need to conform to the implementation of theDBContext.backup()method.Stringsummary()
-
-
-
Method Detail
-
onlineInstance
public static DBContext onlineInstance(String name)
This DB returned by this method does not trigger deletion on JVM shutdown.- Parameters:
name- name of the DB file- Returns:
- an online instance of
MapDBContext
-
offlineInstance
public static DBContext offlineInstance(String name)
This DB returned by this method gets deleted on JVM shutdown.- Parameters:
name- name of the DB file- Returns:
- an offline instance of
MapDBContext
-
summary
public String summary()
-
backup
public Object backup()
Description copied from interface:DBContextImplementations of this method are free to return any object such as XML, JSON, etc...
-
recover
public boolean recover(Object backup)
Description copied from interface:DBContextThe object passed to this method need to conform to the implementation of theDBContext.backup()method.
-
commit
public void commit()
Description copied from interface:DBContextCommits the database to its persistent layer. Implementations are free to not implement this method as it is not compulsory.
-
clear
public void clear()
Description copied from interface:DBContextClears the data structures present in the database.This method does not delete the data-structure themselves, but leaves them empty.
-
contains
public boolean contains(String name)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-