|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.backend.AbstractDatabaseBackendProxy<K,V,P>
K
- The type of keys in the backend.V
- The type of values in the backend.P
- The type of positions in the backend.public abstract class AbstractDatabaseBackendProxy<K,V,P>
This is an abstract base class that can be used as a starting point for
implementing proxy objects for DatabaseBackend
:s.
It implements methods for registering and deregistering
RecordMoveListener
:s. The listeners are registered on the proxied
backend.
Constructor Summary | |
---|---|
protected |
AbstractDatabaseBackendProxy(DatabaseBackend<K,V,P> proxied,
boolean readOnly)
|
Method Summary | |
---|---|
void |
addRecordMoveListener(RecordMoveListener<? super K,? super V,? super P> l)
Register the RecordMoveListener on the proxied backend. |
protected void |
assertNotClosed()
|
protected void |
assertNotReadOnly()
|
void |
close()
Subclasses overriding this method must call super.close() . |
boolean |
compact()
Call compact on the proxied backend. |
protected void |
finalize()
|
void |
forEachKey(ForEachKeyCallback<K,P> callback)
Call the proxied backend's forEachKey method. |
int |
getContentsVersion()
Call getContentsVersion on the proxied backend. |
P |
getFirstPosition()
Call getFirstPosition on the proxied backend. |
Set<K> |
getKeys()
Get the keys from the proxied backend. |
P |
getLastPosition()
Call getLastPosition on the proxied backend. |
P |
getNextPosition(P pos)
Call getNextPosition on the proxied backend. |
P |
getPreviousPosition(P pos)
Call getPreviousPosition on the proxied backend. |
protected DatabaseBackend<K,V,P> |
getProxied()
Get the proxied backend. |
Set<Record<K,V>> |
getRecords()
Get the records from the proxied backend. |
Collection<V> |
getValues()
Get the values from the proxied backend. |
protected boolean |
isClosed()
|
protected boolean |
isReadOnly()
|
Iterator<Record<K,V>> |
iterator()
Get an iterator from the proxied backend. |
Iterator<K> |
keyIterator()
Get a key iterator from the proxied backend. |
void |
removeRecordMoveListener(RecordMoveListener<? super K,? super V,? super P> l)
Remove the RecordMoveListener from the proxied backend. |
Iterator<V> |
valueIterator()
Get a value iterator from the proxied backend. |
long |
writeContentsTo(RandomAccess ra)
Call writeContentsTo on the proxied backend. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.helidb.backend.DatabaseBackend |
---|
clear, delete, find, find, find, getValueFor, insert, insertCheckKeyUnique, insertOrUpdate, readKeyAt, readRecordAt, readValueAt, remove, removeAt, replaceContentsWith, update, updateAt |
Constructor Detail |
---|
protected AbstractDatabaseBackendProxy(DatabaseBackend<K,V,P> proxied, boolean readOnly)
Method Detail |
---|
protected final DatabaseBackend<K,V,P> getProxied()
protected final boolean isClosed()
true
if the backend is closed.protected final boolean isReadOnly()
true
if the backend is read only.protected void assertNotClosed() throws IllegalStateException
IllegalStateException
- If the backend is closed.protected void assertNotReadOnly() throws ReadOnlyException
ReadOnlyException
- If the backend is read only.public void addRecordMoveListener(RecordMoveListener<? super K,? super V,? super P> l)
RecordMoveListener
on the proxied backend.
addRecordMoveListener
in interface DatabaseBackend<K,V,P>
l
- The listener.DatabaseBackend.removeRecordMoveListener(RecordMoveListener)
public void removeRecordMoveListener(RecordMoveListener<? super K,? super V,? super P> l)
RecordMoveListener
from the proxied backend.
removeRecordMoveListener
in interface DatabaseBackend<K,V,P>
l
- The listener to remove.DatabaseBackend.addRecordMoveListener(RecordMoveListener)
public Iterator<K> keyIterator() throws IllegalStateException
keyIterator
in interface DatabaseBackend<K,V,P>
Iterator
over the database's keys.
IllegalStateException
public Iterator<V> valueIterator() throws IllegalStateException
valueIterator
in interface DatabaseBackend<K,V,P>
Iterator
over the database's values.
IllegalStateException
public Iterator<Record<K,V>> iterator() throws IllegalStateException
iterator
in interface Iterable<Record<K,V>>
IllegalStateException
public Set<K> getKeys() throws IllegalStateException
getKeys
in interface DatabaseBackend<K,V,P>
Set
containing all keys in the database. If
the database is empty, this method returns an empty Set
.
IllegalStateException
- If the database backend has been closed.public Collection<V> getValues() throws IllegalStateException
getValues
in interface DatabaseBackend<K,V,P>
Collection
containing all values in the
database. If the database is empty, this method returns an empty Collection
.
IllegalStateException
- If the database backend has been closed.public Set<Record<K,V>> getRecords() throws IllegalStateException
getRecords
in interface DatabaseBackend<K,V,P>
Set
containing all database records. If the
database is empty, this method returns an empty Set
.
IllegalStateException
- If the database backend has been closed.public void forEachKey(ForEachKeyCallback<K,P> callback) throws IllegalStateException
forEachKey
method.
forEachKey
in interface DatabaseBackend<K,V,P>
callback
- The callback object to call for each key.
IllegalStateException
- If the database backend has been closed.public long writeContentsTo(RandomAccess ra) throws IllegalStateException
writeContentsTo
on the proxied backend.
writeContentsTo
in interface DatabaseBackend<K,V,P>
ra
- The RandomAccess
to write to. It is not closed after
writing.
IllegalStateException
- If the database backend has been closed.public int getContentsVersion() throws IllegalStateException
getContentsVersion
on the proxied backend.
getContentsVersion
in interface DatabaseBackend<K,V,P>
IllegalStateException
- If the database backend has been closed.public P getFirstPosition() throws WrappedIOException, IllegalStateException
getFirstPosition
on the proxied backend.
getFirstPosition
in interface DatabaseBackend<K,V,P>
null
if the backend is empty.
WrappedIOException
- On I/O errors.
IllegalStateException
- If the database backend has been closed.DatabaseBackend.getLastPosition()
,
DatabaseBackend.getNextPosition(Object)
,
DatabaseBackend.getPreviousPosition(Object)
public P getLastPosition() throws WrappedIOException, IllegalStateException
getLastPosition
on the proxied backend.
getLastPosition
in interface DatabaseBackend<K,V,P>
null
if the backend is empty.
WrappedIOException
- On I/O errors.
IllegalStateException
- If the database backend has been closed.DatabaseBackend.getFirstPosition()
,
DatabaseBackend.getNextPosition(Object)
,
DatabaseBackend.getPreviousPosition(Object)
public P getNextPosition(P pos) throws WrappedIOException, IllegalStateException
getNextPosition
on the proxied backend.
getNextPosition
in interface DatabaseBackend<K,V,P>
pos
- The position to search from. This must be the position of a
record in the backend. If it is not, the behavior of this method is
unspecified.
null
if the supplied position references the last record in the backend
(the position returned from DatabaseBackend.getLastPosition()
).
WrappedIOException
- On I/O errors.
IllegalStateException
- If the database backend has been closed.DatabaseBackend.getFirstPosition()
,
DatabaseBackend.getLastPosition()
,
DatabaseBackend.getPreviousPosition(Object)
public P getPreviousPosition(P pos) throws WrappedIOException, IllegalStateException, UnsupportedOperationException
getPreviousPosition
on the proxied backend.
getPreviousPosition
in interface DatabaseBackend<K,V,P>
pos
- The position to search from. This must be the position of a
record in the backend. If it is not, the behavior of this method is
unspecified.
null
if the supplied position references the first record in the
backend (the position returned from DatabaseBackend.getFirstPosition()
).
WrappedIOException
- On I/O errors.
IllegalStateException
- If the database backend has been closed.
UnsupportedOperationException
- If this method is not supported by
the backend implementation.DatabaseBackend.getFirstPosition()
,
DatabaseBackend.getLastPosition()
,
DatabaseBackend.getNextPosition(Object)
public boolean compact() throws IllegalStateException
compact
on the proxied backend.
compact
in interface DatabaseBackend<K,V,P>
true
if the backend was modified, false
if not.
IllegalStateException
- If the database backend has been closed.public void close()
super.close()
.
close
in interface DatabaseBackend<K,V,P>
protected void finalize() throws Throwable
finalize
in class Object
Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |