public class UserPreferences extends UserKeyValueStorage
Modifier and Type | Class and Description |
---|---|
private class |
UserPreferences.KeysCollector
Collects stored keys.
|
UserKeyValueStorage.Chunk
Modifier and Type | Field and Description |
---|---|
private java.util.prefs.Preferences |
backend
The back end key and value storage
|
private java.util.List<java.lang.String> |
collectedKeys
The collected keys
|
private static java.lang.String |
HEAD_KEY
The head key
|
private java.util.prefs.Preferences |
headPreferences
The Preferences node for the head chunk
|
private static int |
MAXIMAL_STRING_LENGTH
The maximal string length for values
|
private com.fasterxml.jackson.databind.ObjectMapper |
objectMapper
Maps an object into its json presentation and back
|
Constructor and Description |
---|
UserPreferences() |
Modifier and Type | Method and Description |
---|---|
void |
delete(java.lang.String key)
Deletes the given key and its value from this storage.
|
void |
flushChanges()
Flushes the current changes into this storage backend.
|
UserKeyValueStorage.Chunk |
getFirstChunk(java.lang.String key)
Retrieves the first chunk node.
|
java.lang.String |
getKey(int index)
Returns the key by its index number in a sequence of all storage keys.
|
int |
getMaximalValueSize()
Returns the maximal value size that can be stored into this storage backend.
|
UserKeyValueStorage.Chunk |
getNextChunk(UserKeyValueStorage.Chunk head,
java.lang.String nextChunkKey)
Retrieves the next chunk of stored data.
|
private java.util.prefs.Preferences |
getPreferencesFor(java.lang.String key)
Returns the node assigned for the given key.
|
int |
getSize()
Returns the storage size.
|
boolean |
isChunkKey(java.lang.String key)
Any string can be used as a key.
|
void |
saveHeadChunk(java.lang.String key,
UserKeyValueStorage.Chunk head)
Stores the head chunk with the given key within this storage backend.
|
void |
saveNextChunk(UserKeyValueStorage.Chunk head,
java.lang.String nextChunkKey,
UserKeyValueStorage.Chunk node)
Stores the given chunk with the given key within this storage backend.
|
collectChunks, getBoolean, getNextChunkKey, getNumber, getString, saveByChunks, setBoolean, setNumber, setString, setUniqueHeadName
private static final java.lang.String HEAD_KEY
private static final int MAXIMAL_STRING_LENGTH
private final java.util.prefs.Preferences backend
private final com.fasterxml.jackson.databind.ObjectMapper objectMapper
private final java.util.List<java.lang.String> collectedKeys
private java.util.prefs.Preferences headPreferences
public void delete(java.lang.String key)
key
- The given keypublic void saveHeadChunk(java.lang.String key, UserKeyValueStorage.Chunk head)
saveHeadChunk
in class UserKeyValueStorage
key
- The given keyhead
- The head chunkpublic void saveNextChunk(UserKeyValueStorage.Chunk head, java.lang.String nextChunkKey, UserKeyValueStorage.Chunk node)
saveNextChunk
in class UserKeyValueStorage
head
- The head chunknextChunkKey
- The given chunk keynode
- The chunkpublic void flushChanges()
flushChanges
in class UserKeyValueStorage
public int getMaximalValueSize()
getMaximalValueSize
in class UserKeyValueStorage
public UserKeyValueStorage.Chunk getFirstChunk(java.lang.String key)
getFirstChunk
in class UserKeyValueStorage
key
- The given keypublic UserKeyValueStorage.Chunk getNextChunk(UserKeyValueStorage.Chunk head, java.lang.String nextChunkKey)
getNextChunk
in class UserKeyValueStorage
head
- The first chunk of the stored data valuenextChunkKey
- The next chunk keyprivate java.util.prefs.Preferences getPreferencesFor(java.lang.String key)
key
- The given keypublic int getSize()
public java.lang.String getKey(int index)
index
- The given index number in a sequence of all storage keys.public boolean isChunkKey(java.lang.String key)
isChunkKey
in class UserKeyValueStorage
key
- The given key to test