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(String id)
Tests whether a data exists for this ID.
|
String[] |
getIds()
Returns all IDs of the stored data.
|
InputStream |
load(String id)
Returns the data stored with a specific ID or
null if there is none. |
void |
move(String src,
String dst)
Changes the ID of a data.
|
void |
remove(String id)
Removes the data stored with an ID.
|
void |
store(String id,
InputStream stream)
Stores an input stream that will be referenced with an ID.
|
boolean exists(String id) throws IOException
id
- the storage-key to check.true
if the given ID exists, false
otherwiseIOException
- if an I/O error occurs.String[] getIds() throws IOException
IOException
- if an I/O error occurs.InputStream load(String id) throws IOException
null
if there is none.id
- the ID of the data to be returned.null
.IOException
- if an I/O error occurs.IllegalArgumentException
- if the given ID is not a valid identifier.NullPointerException
- if one of the given parameters is null
.void move(String src, String dst) throws 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.IOException
- if an I/O error occurs.IllegalArgumentException
- if one of the given IDs is not a valid identifier.IllegalArgumentException
- if there is no data stored with the old ID.NullPointerException
- if one of the given parameters is null
.void remove(String id) throws IOException
id
- the ID of the data to return.IOException
- if an I/O error occurs.IllegalArgumentException
- if the given ID is not a valid identifier.IllegalArgumentException
- if there is no data stored with the given ID.NullPointerException
- if one of the given parameters is null
.void store(String id, InputStream stream) throws 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.IOException
- if an I/O error occurs.IllegalArgumentException
- if the given ID is not a valid identifier.NullPointerException
- if one of the given parameters is null
.