Class View
- java.lang.Object
-
- com.exonum.binding.core.proxy.AbstractNativeProxy
-
- com.exonum.binding.core.storage.database.View
-
public abstract class View extends AbstractNativeProxy
Represents a view of the database.There are two sub-types:
- A snapshot, which is a read-only and immutable view.
- A fork, which is a read-write view.
As in some cases the clients need to detect any changes made to a database, a view also holds a modification counter, which any clients changing the database state must notify.
-
-
Field Summary
-
Fields inherited from class com.exonum.binding.core.proxy.AbstractNativeProxy
nativeHandle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canModify()
Returns true if this view allows modifications to the database state; false if it is immutable.Optional<StorageIndex>
findOpenIndex(IndexAddress address)
Finds an open index by the given address.Cleaner
getCleaner()
Returns the cleaner of this view.long
getViewNativeHandle()
Returns a native handle of this view.void
registerIndex(StorageIndex index)
Registers a new index created with this view.-
Methods inherited from class com.exonum.binding.core.proxy.AbstractNativeProxy
getNativeHandle, isValidHandle
-
-
-
-
Method Detail
-
canModify
public boolean canModify()
Returns true if this view allows modifications to the database state; false if it is immutable.
-
getViewNativeHandle
public long getViewNativeHandle()
Returns a native handle of this view.- Throws:
IllegalStateException
- if the view is invalid (closed or nullptr)
-
findOpenIndex
public Optional<StorageIndex> findOpenIndex(IndexAddress address)
Finds an open index by the given address.This method is for internal use. It is not designed to be used by services, rather by index factories.
- Parameters:
address
- the index address- Returns:
- an index with the given address; or
Optional.empty()
if no index with such address was open in this view
-
registerIndex
public void registerIndex(StorageIndex index)
Registers a new index created with this view.This method is for internal use. It is not designed to be used by services, rather by index factories.
- Parameters:
index
- a new index to register- Throws:
IllegalArgumentException
- if the index is already registered- See Also:
findOpenIndex(IndexAddress)
-
getCleaner
public Cleaner getCleaner()
Returns the cleaner of this view.
-
-