Constructor and Description |
---|
StorageHeap()
Creates a not persistent storage.
|
Modifier and Type | Method and Description |
---|---|
java.io.OutputStream |
append(java.lang.String id)
Appends some data to an entry referenced with an ID.
|
boolean |
exists(java.lang.String id)
Tests whether an entry exists for this ID.
|
java.lang.String[] |
getIds()
Returns all IDs of the stored entries.
|
long |
getSize(java.lang.String id)
Returns the size of the entry stored with an ID.
|
java.io.InputStream |
load(java.lang.String id)
Loads the data stored with a specific ID or
null if there is none. |
java.io.OutputStream |
modify(java.lang.String id,
int offset)
Modifies the entry that is referenced by an ID.
|
void |
move(java.lang.String sourceId,
java.lang.String destinationId)
Changes the ID of an entry.
|
void |
remove(java.lang.String id)
Removes the entry stored with an ID.
|
java.io.OutputStream |
store(java.lang.String id)
Stores data that will be referenced with an ID.
|
public java.io.OutputStream store(java.lang.String id) throws java.io.IOException
Storage
If an entry is already stored with this ID, its existing data is fully removed and replaced by the given data. Otherwise, a new entry is created.
This operation may block the current thread depending on the implementation.
The returned output stream must be flushed or closed to ensure that the data is available. Example of usage:
try(OutputStream outputStream = store(id)) { outputStream.write(…); outputStream.write(…); }
public java.io.OutputStream modify(java.lang.String id, int offset) throws java.io.IOException
Storage
If an entry is already stored with this ID, its existing data is not removed and only the targeted bytes will be overwritten. Otherwise, a new entry is created.
This operation may block the current thread depending on the implementation.
The returned output stream must be flushed or closed to ensure that the data is available.
public java.io.OutputStream append(java.lang.String id) throws java.io.IOException
Storage
If an entry is already stored with this ID, its existing data is not removed and the given data will be added to the existing entry. Otherwise, a new entry is created.
This operation may block the current thread depending on the implementation.
The returned output stream must be flushed or closed to ensure that the data is available. Example of usage:
try(OutputStream outputStream = append(id)) { outputStream.write(…); outputStream.write(…); }
@Nullable public java.io.InputStream load(java.lang.String id) throws java.io.IOException
Storage
null
if there is none.
The returned input stream must be closed by the caller.
This operation may block the current thread depending on the implementation.
public void move(java.lang.String sourceId, java.lang.String destinationId) throws java.io.IOException
Storage
If an entry is already stored with the destination ID, it is overwritten.
This operation may block the current thread depending on the implementation.
public void remove(java.lang.String id) throws java.io.IOException
Storage
This operation may block the current thread depending on the implementation.
public long getSize(java.lang.String id) throws java.io.IOException
Storage
public boolean exists(java.lang.String id) throws java.io.IOException
Storage