public class KVStore
extends java.util.HashMap<java.lang.String,java.lang.Object>
implements java.io.Serializable
| Constructor and Description |
|---|
KVStore()
Standard c'tor creating an empty KV store.
|
KVStore(KVStore keyValueStoreToCopy)
C'tor for making a deep copy of another KVStore.
|
KVStore(java.util.Map<java.lang.String,java.lang.Object> keyValueMap)
C'tor for creating a shallow copy of another KeyValueStore or to initialize with the provided keyValueMap.
|
KVStore(java.lang.String stringRepresentation)
C'tor creating a KV store loading the data from the provided string representation.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
void |
filter(java.util.Map<java.lang.String,IKVFilter> filterMap)
Enables filtering values of multiple keys.
|
void |
filter(java.lang.String key,
IKVFilter filter)
Allows to apply a
filter to the value of a specific key. |
java.lang.Boolean |
getAsBoolean(java.lang.String key)
Returns a value as boolean for the given key.
|
java.util.List<java.lang.Boolean> |
getAsBooleanList(java.lang.String key)
Returns a value as boolean list for the given key.
|
java.util.List<java.lang.Boolean> |
getAsBooleanList(java.lang.String key,
java.lang.String separator)
Returns a value as boolean list for the given key.
|
java.lang.Byte |
getAsByte(java.lang.String key)
Returns a value as byte for the given key.
|
java.lang.Double |
getAsDouble(java.lang.String key)
Returns a value as double for the given key.
|
java.util.List<java.lang.Double> |
getAsDoubleList(java.lang.String key)
Returns a value as double list for the given key.
|
java.util.List<java.lang.Double> |
getAsDoubleList(java.lang.String key,
java.lang.String separator)
Returns a value as double list for the given key.
|
java.io.File |
getAsFile(java.lang.String key)
Returns a value as a File object.
|
java.lang.Integer |
getAsInt(java.lang.String key)
Returns a value as integer for the given key.
|
java.util.List<java.lang.Integer> |
getAsIntList(java.lang.String key)
Returns a value as integer list for the given key.
|
java.util.List<java.lang.Integer> |
getAsIntList(java.lang.String key,
java.lang.String separator)
Returns a value as integer list for the given key.
|
java.lang.Long |
getAsLong(java.lang.String key)
Returns a value as long for the given key.
|
java.lang.Object |
getAsObject(java.lang.String key,
java.lang.Class<?> objectClass)
Returns a value as object for the given key.
|
java.lang.Short |
getAsShort(java.lang.String key)
Returns a value as short for the given key.
|
java.lang.String |
getAsString(java.lang.String key)
Returns a value as string for the given key.
|
java.util.List<java.lang.String> |
getAsStringList(java.lang.String key,
java.lang.String separator)
Returns a value as string list for the given key.
|
KVStoreCollection |
getCollection() |
java.lang.String |
getStringRepresentation(java.lang.String[] projectionFilter)
Allows to get a string representation of this KVStore incorporating only key value pairs for the named
|
int |
hashCode() |
boolean |
matches(java.util.Map<java.lang.String,java.lang.String> selection)
Checks whether particular keys have matching values according to
selection. |
void |
merge(java.lang.String[] fieldKeys,
java.lang.String separator,
java.lang.String newKey)
Merges a set of keys and concatenates the values of the respective keys.
|
void |
prefixAllKeys(java.lang.String prefix)
Updates all keys of this key value store and prepends the given prefix.
|
void |
project(java.lang.String[] filterKeys)
Reduces the key value store such that it only contains the given keys.
|
void |
readKVStoreFromDescription(java.lang.String kvDescription)
Reads a KVStore from a string description.
|
void |
removeAll(java.lang.String[] removeKeys)
Removes all the keys provided by
removeKeys. |
void |
renameKey(java.lang.String key,
java.lang.String newKeyName)
Renames a key by the new key name.
|
void |
serializeTo(java.io.File file)
Serializes the key value store to the
file with the given fileName. |
void |
serializeTo(java.lang.String fileName)
Serializes the key value store to a file with the given
fileName. |
void |
setCollection(KVStoreCollection collection)
Assigns the KVStore to a KVStoreCollection.
|
java.lang.String |
toString() |
public KVStore()
public KVStore(java.lang.String stringRepresentation)
stringRepresentation - A string formatted key value store to be restored.public KVStore(java.util.Map<java.lang.String,java.lang.Object> keyValueMap)
keyValueMap - Map of keys and values to initialize this KeyValueStore with.public KVStore(KVStore keyValueStoreToCopy)
keyValueStoreToCopy - The KVStore to make a deep copy from.public java.lang.String getAsString(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Boolean getAsBoolean(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Integer getAsInt(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Double getAsDouble(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Long getAsLong(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Short getAsShort(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Byte getAsByte(java.lang.String key)
key - Key for which the value shall be returned.public java.lang.Object getAsObject(java.lang.String key,
java.lang.Class<?> objectClass)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException
key - Key for which the value shall be returned.java.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.NoSuchMethodExceptionpublic java.util.List<java.lang.Double> getAsDoubleList(java.lang.String key)
key - Key for which the value shall be returned.public java.util.List<java.lang.Double> getAsDoubleList(java.lang.String key,
java.lang.String separator)
key - Key for which the value shall be returned.public java.util.List<java.lang.Integer> getAsIntList(java.lang.String key)
key - Key for which the value shall be returned.public java.util.List<java.lang.Integer> getAsIntList(java.lang.String key,
java.lang.String separator)
key - Key for which the value shall be returned.public java.util.List<java.lang.String> getAsStringList(java.lang.String key,
java.lang.String separator)
key - Key for which the value shall be returned.public java.util.List<java.lang.Boolean> getAsBooleanList(java.lang.String key)
key - Key for which the value shall be returned.public java.util.List<java.lang.Boolean> getAsBooleanList(java.lang.String key,
java.lang.String separator)
key - Key for which the value shall be returned.public java.io.File getAsFile(java.lang.String key)
key - Key for which the value shall be returned.public void readKVStoreFromDescription(java.lang.String kvDescription)
kvDescription - The string description of the kv store.public boolean matches(java.util.Map<java.lang.String,java.lang.String> selection)
selection.selection - Map of keys and values to match for. Values may use * as a wildcard.selection.public void project(java.lang.String[] filterKeys)
filterKeys - Keys to keep in the key value store.public void removeAll(java.lang.String[] removeKeys)
removeKeys.removeKeys - Array of keys that shall be removed from the key value store.public void filter(java.util.Map<java.lang.String,IKVFilter> filterMap)
filterMap - Map of keys and respective filters to apply.public void filter(java.lang.String key,
IKVFilter filter)
filter to the value of a specific key.key - Key to whose value the filter may be applied.filter - The filter for applying to the value of the given key.public void serializeTo(java.lang.String fileName)
throws java.io.IOException
fileName.fileName - The name of the file, the key value store shall be serialized to.java.io.IOExceptionpublic void serializeTo(java.io.File file)
throws java.io.IOException
file with the given fileName.fileName - The name of the file, the key value store shall be serialized to.java.io.IOExceptionpublic void merge(java.lang.String[] fieldKeys,
java.lang.String separator,
java.lang.String newKey)
fieldKeys - Keys of values to be concatenated.separator - Seperator to separate values of different keys.newKey - Name of the new key.public void prefixAllKeys(java.lang.String prefix)
prefix - The prefix to prepend to key names.public void renameKey(java.lang.String key,
java.lang.String newKeyName)
key - The old key name.newKeyName - The new key name.public KVStoreCollection getCollection()
public void setCollection(KVStoreCollection collection)
collection - The collection this KVStore belongs to.public java.lang.String getStringRepresentation(java.lang.String[] projectionFilter)
projectionFilter - public java.lang.String toString()
toString in class java.util.AbstractMap<java.lang.String,java.lang.Object>public int hashCode()
hashCode in interface java.util.Map<java.lang.String,java.lang.Object>hashCode in class java.util.AbstractMap<java.lang.String,java.lang.Object>public boolean equals(java.lang.Object obj)
equals in interface java.util.Map<java.lang.String,java.lang.Object>equals in class java.util.AbstractMap<java.lang.String,java.lang.Object>