Package aQute.lib.persistentmap
Class PersistentMap<V>
- java.lang.Object
-
- java.util.AbstractMap<java.lang.String,V>
-
- aQute.lib.persistentmap.PersistentMap<V>
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.util.Map<java.lang.String,V>
public class PersistentMap<V> extends java.util.AbstractMap<java.lang.String,V> implements java.io.Closeable
Implements a low performance but easy to use map that is backed on a directory. All objects are stored as JSON objects and therefore should be DTOs. Each key is a file name and the contents is the value encoded in JSON. The PersistentMap will attempt to lock the directory. This is a non-concurrent implementation so you must ensure it is only used in a single thread. It cannot of course also not share the data directory.
-
-
Constructor Summary
Constructors Constructor Description PersistentMap(java.io.File dir, java.lang.Class<V> type)
PersistentMap(java.io.File dir, java.lang.Class<V> type, java.util.Map<java.lang.String,V> map)
PersistentMap(java.io.File dir, java.lang.reflect.Type type)
PersistentMap(java.io.File dir, java.lang.reflect.Type type, java.util.Map<java.lang.String,V> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
clear(long whenOlder)
void
close()
java.util.Set<java.util.Map.Entry<java.lang.String,V>>
entrySet()
java.util.Set<java.lang.String>
keySet()
V
put(java.lang.String key, V value)
V
remove(java.lang.String key)
java.lang.String
toString()
-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, get, hashCode, isEmpty, putAll, remove, size, values
-
-
-
-
Constructor Detail
-
PersistentMap
public PersistentMap(java.io.File dir, java.lang.reflect.Type type) throws java.lang.Exception
- Throws:
java.lang.Exception
-
PersistentMap
public PersistentMap(java.io.File dir, java.lang.Class<V> type) throws java.lang.Exception
- Throws:
java.lang.Exception
-
PersistentMap
public PersistentMap(java.io.File dir, java.lang.Class<V> type, java.util.Map<java.lang.String,V> map) throws java.lang.Exception
- Throws:
java.lang.Exception
-
PersistentMap
public PersistentMap(java.io.File dir, java.lang.reflect.Type type, java.util.Map<java.lang.String,V> map) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
-
remove
public V remove(java.lang.String key)
-
clear
public void clear()
-
keySet
public java.util.Set<java.lang.String> keySet()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractMap<java.lang.String,V>
-
clear
public void clear(long whenOlder)
-
-