org.helidb.impl.simple
Class SimpleDatabase<K,V,P>

java.lang.Object
  extended by org.helidb.impl.AbstractDatabase<K,V,P>
      extended by org.helidb.impl.simple.SimpleDatabase<K,V,P>
Type Parameters:
K - The type of the keys in the database.
V - The type of the values in the database.
P - The type of positions used by the DatabaseBackend to locate records.
All Implemented Interfaces:
Iterable<Record<K,V>>, Map<K,V>, Database<K,V>

public class SimpleDatabase<K,V,P>
extends AbstractDatabase<K,V,P>

This is a simple implementation of Database. It does not support transactions.

This database implementation is not thread safe. If it is to be used concurrently from several threads, the client must use external synchronization.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
helidb-core

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
SimpleDatabase(DatabaseBackend<K,V,P> b, LogAdapterHolder lah)
          Create a new database frontend.
 
Method Summary
protected  void closeBackend()
          Subclasses implement this to call close on the backend.
protected  DatabaseBackend<K,V,P> getBackendForReading()
          Subclasses implement this to return a backend object that can be used for reading data.
protected  DatabaseBackend<K,V,P> getBackendForWriting()
          Subclasses implement this to return a backend object that can be used for writing data to.
 
Methods inherited from class org.helidb.impl.AbstractDatabase
assertNotClosed, clear, close, compact, containsKey, containsValue, delete, entrySet, equals, fasterInsert, find, find, find, firstRecord, get, getLogAdapterHolder, hashCode, insert, insertOrUpdate, isClosed, isEmpty, iterator, keyIterator, keySet, lastRecord, put, putAll, remove, size, update, valueIterator, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDatabase

public SimpleDatabase(DatabaseBackend<K,V,P> b,
                      LogAdapterHolder lah)
Create a new database frontend.

Parameters:
b - The backend.
lah - A log adapter holder.
Method Detail

getBackendForReading

protected DatabaseBackend<K,V,P> getBackendForReading()
Description copied from class: AbstractDatabase
Subclasses implement this to return a backend object that can be used for reading data. Transactional database implementations make sure to join the current transaction, if the database has not already joined.

Specified by:
getBackendForReading in class AbstractDatabase<K,V,P>
Returns:
A backend object for reading data from.

getBackendForWriting

protected DatabaseBackend<K,V,P> getBackendForWriting()
Description copied from class: AbstractDatabase
Subclasses implement this to return a backend object that can be used for writing data to. Transactional database implementations make sure to join the current transaction, if the database has not already joined.

Specified by:
getBackendForWriting in class AbstractDatabase<K,V,P>
Returns:
A backend object for writing data to.

closeBackend

protected void closeBackend()
Description copied from class: AbstractDatabase
Subclasses implement this to call close on the backend. This is called by AbstractDatabase.close().

Specified by:
closeBackend in class AbstractDatabase<K,V,P>