public interface Storage
The storage use an identifier to store, retrieve or remove a data. An identifier is an unlimited-length sequence (greater than 0) of letters, digits and special characters, the first of which must be a letter. The "letters" includes lowercase(a-z), uppercase(A-Z) ASCII latin characters and ASCII underscore(_). The "digits" includes the ASCII digit(0-9). The special characters includes ASCII hyphen(-) and ASCII dot(.).
Modifier and Type | Method and Description |
---|---|
boolean |
exists(java.lang.String id)
Tests whether a data exists for this ID.
|
java.lang.String[] |
getIds()
Returns all IDs of the stored data.
|
java.io.InputStream |
load(java.lang.String id)
Returns the data stored with a specific ID or
null if there is none. |
void |
move(java.lang.String src,
java.lang.String dst)
Changes the ID of a data.
|
void |
remove(java.lang.String id)
Removes the data stored with an ID.
|
void |
store(java.lang.String id,
java.io.InputStream stream)
Stores an input stream that will be referenced with an ID.
|
void store(java.lang.String id, java.io.InputStream stream) throws java.io.IOException
If a data is already stored with this ID, it is overwritten.
id
- the ID of the stored data.stream
- the data to be stored.java.io.IOException
- if an I/O error occurs.java.lang.IllegalArgumentException
- if the given ID is not a valid identifier.java.lang.NullPointerException
- if one of the given parameters is null
.java.io.InputStream load(java.lang.String id) throws java.io.IOException
null
if there is none.id
- the ID of the data to be returned.null
.java.io.IOException
- if an I/O error occurs.java.lang.IllegalArgumentException
- if the given ID is not a valid identifier.java.lang.NullPointerException
- if one of the given parameters is null
.void move(java.lang.String src, java.lang.String dst) throws java.io.IOException
If a data is already stored with the new ID, it is overwritten.
src
- the old ID of the data.dst
- the new ID of the data.java.io.IOException
- if an I/O error occurs.java.lang.IllegalArgumentException
- if one of the given IDs is not a valid identifier.java.lang.IllegalArgumentException
- if there is no data stored with the old ID.java.lang.NullPointerException
- if one of the given parameters is null
.void remove(java.lang.String id) throws java.io.IOException
id
- the ID of the data to return.java.io.IOException
- if an I/O error occurs.java.lang.IllegalArgumentException
- if the given ID is not a valid identifier.java.lang.IllegalArgumentException
- if there is no data stored with the given ID.java.lang.NullPointerException
- if one of the given parameters is null
.boolean exists(java.lang.String id) throws java.io.IOException
id
- the storage-key to check.true
if the given ID exists, false
otherwisejava.io.IOException
- if an I/O error occurs.java.lang.String[] getIds() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.