|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.magnos.data.store.AbstractStore
public abstract class AbstractStore
An abstract Store. Implementations must adhere to the guidelines specified in the documentation of the abstract methods.
| Constructor Summary | |
|---|---|
protected |
AbstractStore(java.lang.String name)
Instantiates a new AbstractStore. |
| Method Summary | |
|---|---|
int |
capacity()
Returns the size or capacity of the store in bytes. |
int |
capacity(int newCapacity)
Sets the stores size or capacity in bytes. |
void |
close()
Closes this store if not closed already. |
StoreAccess |
create(StoreAccess initialAccess,
int initialCapacity)
Creates the store by opening it with the given access and setting the initial capacity. |
void |
delete()
Removes this store from any persisted medium. |
boolean |
equals(java.lang.Object o)
|
boolean |
exists()
Whether the store exists. |
void |
flush()
Explicitly writes the data to the store. |
void |
get(int location,
byte[] bytes)
Reads an array of bytes from the store at the given location. |
void |
get(int location,
byte[] bytes,
int offset,
int length)
Reads from the store and puts it in a section in the array of bytes. |
void |
get(int location,
java.nio.ByteBuffer buffer)
Reads a ByteBuffer to the store at the given location. |
byte[] |
get(int location,
int size)
Returns an array of bytes read from the store at the given location. |
StoreAccess |
getAccess()
Returns the current access of this store to its persisted medium if any exists. |
java.lang.String |
getName()
Returns the name of the store. |
int |
hashCode()
|
boolean |
isAutoFlush()
Whether the store automatically flushes data immediately after its written to the store. |
boolean |
isAutoLoad()
Whether the store automatically loads data immediately before its read from the store. |
boolean |
isAutoOpen()
Whether the store automatically opens with the default or last access if some action needs to be done to the store. |
boolean |
isClosed()
Whether the store is closed. |
boolean |
isOpen()
Whether the store is open. |
void |
load()
Explicitly loads the data from the store into memory. |
StoreAccess |
open(StoreAccess initialAccess)
Explicitly opens this store for reading and writing. |
void |
put(int location,
byte[] bytes)
Writes the array of bytes to the store at the given location. |
void |
put(int location,
byte[] bytes,
int offset,
int length)
Writes a section in the array of bytes to the store at the given location. |
void |
put(int location,
java.nio.ByteBuffer buffer)
Writes a ByteBuffer to the store at the given location. |
StoreAccess |
setAccess(StoreAccess newAccess)
Sets the access of this store to its persisted medium. |
void |
setAutoFlush(boolean autoFlush)
Sets whether the store automatically flushes data immediately after its written to the store. |
void |
setAutoLoad(boolean autoLoad)
Set whether the store automatically loads data immediately before its read from the store. |
void |
setAutoOpen(boolean autoOpen)
Sets whether the store automatically opens with the default or last access if some actions need to be done to the store. |
protected abstract void |
storeClose()
Should close the store. |
protected abstract void |
storeDelete()
Deletes the medium to which the store has been persisting to. |
protected abstract boolean |
storeExists()
Returns whether the store exists in its probable medium. |
protected abstract void |
storeFlush()
Should flush the contents of the store from memory to a persisted medium if the implementation supports it. |
protected abstract void |
storeGet(int location,
byte[] bytes,
int offset,
int length)
Gets data at the given location and stores it in the given byte array. |
protected abstract void |
storeGet(int location,
java.nio.ByteBuffer buffer)
Gets data at the given location and stores it in the given ByteBuffer. |
protected abstract void |
storeLoad()
Should load contents of the store into memory from a persisted medium if the implementation supports it. |
protected abstract int |
storeOpen(StoreAccess access)
Should open the store and return the capacity. |
protected abstract void |
storePut(int location,
byte[] bytes,
int offset,
int length)
Puts data at the given location from the given byte array. |
protected abstract void |
storePut(int location,
java.nio.ByteBuffer buffer)
Puts data at the given location from the given ByteBuffer. |
protected abstract int |
storeResize(int capacity)
Resizes the store to the given capacity. |
java.lang.String |
toString()
|
protected void |
validate()
Validates an action by checking if the store is closed. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractStore(java.lang.String name)
name - The unique name of this store. If this store is persisted to a
file system this may be the file name.| Method Detail |
|---|
protected abstract int storeOpen(StoreAccess access)
throws java.io.IOException
java.io.IOException - An error occurred opening the store with the given access.
protected abstract void storeLoad()
throws java.io.IOException
java.io.IOException - An error occurred loading the store.
protected abstract void storeFlush()
throws java.io.IOException
java.io.IOException - An error occurred flushing the store.
protected abstract void storeClose()
throws java.io.IOException
java.io.IOException - An error occurred closing the store.
protected abstract int storeResize(int capacity)
throws java.io.IOException
capacity - The new capacity of the store.
java.io.IOException - An error occured resizing the store.protected abstract boolean storeExists()
protected abstract void storeDelete()
protected abstract void storeGet(int location,
byte[] bytes,
int offset,
int length)
throws java.io.IOException
location - The offset to get the data, in bytes, from the beginning of the store.bytes - The array of bytes to place the data in.offset - The offset in the byte array to place the data.length - The number of bytes to copy from the store and place in the array.
java.io.IOException - An error occurred reading from the store.
protected abstract void storeGet(int location,
java.nio.ByteBuffer buffer)
throws java.io.IOException
location - The offset to get the data, in bytes, from the beginning of the store.buffer - The buffer to place the data in. The buffer will be filled with data
to its limit (so it has no remaining bytes).
java.io.IOException - An error occurred reading from the store.
protected abstract void storePut(int location,
byte[] bytes,
int offset,
int length)
throws java.io.IOException
location - The offset to put the data, in bytes, from the beginning of the store.bytes - The array of bytes to take data from.offset - The offset in the byte array to take the data.length - The number of bytes to copy from the array and place in the store.
java.io.IOException - An error occurred writing to the store.
protected abstract void storePut(int location,
java.nio.ByteBuffer buffer)
throws java.io.IOException
location - The offset to put the data, in bytes, from the beginning of the store.buffer - The buffer to take the data from. The buffer will be emptied of data
to its limit (so it has no remaining bytes).
java.io.IOException - An error occurred writing to the store.
protected final void validate()
throws StoreClosedException
StoreClosedExceptionpublic final java.lang.String getName()
getName in interface Storepublic final int capacity()
capacity in interface Storepublic final StoreAccess getAccess()
getAccess in interface Storepublic final StoreAccess setAccess(StoreAccess newAccess)
setAccess in interface StorenewAccess - The requested access to the store.
public final boolean exists()
exists in interface Storepublic final void delete()
delete in interface Storepublic final int capacity(int newCapacity)
capacity in interface StorenewCapacity - The desired capacity of the store.
public final StoreAccess create(StoreAccess initialAccess,
int initialCapacity)
throws StoreIOException
create in interface StoreinitialAccess - The requested access to the store.initialCapacity - The new capacity of the store.
StoreIOException - An error occurred in the implementation. See attached exception.
public final StoreAccess open(StoreAccess initialAccess)
throws StoreIOException
open in interface StoreinitialAccess - The requested access to the store.
StoreIOException - An error occurred in the implementation. See attached exception.
public final void load()
throws StoreIOException
load in interface StoreStoreIOException - An error occurred in the implementation. See attached exception.
public final void flush()
throws StoreIOException
flush in interface StoreStoreIOException - An error occurred in the implementation. See attached exception.
public final void close()
throws StoreIOException
close in interface StoreStoreIOException - An error occurred in the implementation. See attached exception.public final boolean isClosed()
isClosed in interface Storepublic final boolean isOpen()
isOpen in interface Store
public final void get(int location,
byte[] bytes,
int offset,
int length)
get in interface Storelocation - The location in the store, the offset of bytes from the beginning.bytes - The array of bytes to read into.offset - The offset into the array of bytes.length - The number of bytes to read starting at the offset in the array.
public final void get(int location,
java.nio.ByteBuffer buffer)
get in interface Storelocation - The location in the store, the offset of bytes from the beginning.buffer - The buffer of data to write. The bytes written to the store are the
bytes that exist between the buffers position and limit.
public final void get(int location,
byte[] bytes)
get in interface Storelocation - The location in the store, the offset of bytes from the beginning.bytes - The array of bytes to read into.
public final byte[] get(int location,
int size)
get in interface Storelocation - The location in the store, the offset of bytes from the beginning.size - The number of bytes to read and return.
public final void put(int location,
byte[] bytes,
int offset,
int length)
put in interface Storelocation - The location in the store, the offset of bytes from the beginning.bytes - The array of bytes to write.offset - The offset into the array of bytes.length - The number of bytes to write starting at the offset in the array.
public final void put(int location,
java.nio.ByteBuffer buffer)
put in interface Storelocation - The location in the store, the offset of bytes from the beginning.buffer - The buffer of data to write. The bytes written to the store are the
bytes that exist between the buffers position and limit.
public final void put(int location,
byte[] bytes)
put in interface Storelocation - The location in the store, the offset of bytes from the beginning.bytes - The array of bytes to write.public final boolean isAutoOpen()
isAutoOpen in interface Storepublic final void setAutoOpen(boolean autoOpen)
setAutoOpen in interface StoreautoOpen - True if the store should automatically open, otherwise false.public final boolean isAutoFlush()
isAutoFlush in interface Storepublic final void setAutoFlush(boolean autoFlush)
setAutoFlush in interface StoreautoFlush - True if the store should automatically flush, otherwise false.public final boolean isAutoLoad()
isAutoLoad in interface Storepublic final void setAutoLoad(boolean autoLoad)
setAutoLoad in interface StoreautoLoad - True if the store should automatically load, otherwise false.public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic final java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||