aQute.lib.persistentmap
Class PersistentMap<V>

java.lang.Object
  extended by java.util.AbstractMap<String,V>
      extended by aQute.lib.persistentmap.PersistentMap<V>
All Implemented Interfaces:
Closeable, Map<String,V>

public class PersistentMap<V>
extends AbstractMap<String,V>
implements 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.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
PersistentMap(File dir, Class<V> type)
           
PersistentMap(File dir, Class<V> type, Map<String,V> map)
           
PersistentMap(File dir, Type type)
           
PersistentMap(File dir, Type type, Map<String,V> map)
           
 
Method Summary
 void clear()
           
 void clear(long whenOlder)
           
 void close()
           
 Set<Map.Entry<String,V>> entrySet()
           
 Set<String> keySet()
           
 V put(String key, V value)
           
 V remove(String key)
           
 String toString()
           
 
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, get, hashCode, isEmpty, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistentMap

public PersistentMap(File dir,
                     Type type)
              throws Exception
Throws:
Exception

PersistentMap

public PersistentMap(File dir,
                     Class<V> type)
              throws Exception
Throws:
Exception

PersistentMap

public PersistentMap(File dir,
                     Class<V> type,
                     Map<String,V> map)
              throws Exception
Throws:
Exception

PersistentMap

public PersistentMap(File dir,
                     Type type,
                     Map<String,V> map)
              throws Exception
Throws:
Exception
Method Detail

entrySet

public Set<Map.Entry<String,V>> entrySet()
Specified by:
entrySet in interface Map<String,V>
Specified by:
entrySet in class AbstractMap<String,V>

put

public V put(String key,
             V value)
Specified by:
put in interface Map<String,V>
Overrides:
put in class AbstractMap<String,V>

remove

public V remove(String key)

clear

public void clear()
Specified by:
clear in interface Map<String,V>
Overrides:
clear in class AbstractMap<String,V>

keySet

public Set<String> keySet()
Specified by:
keySet in interface Map<String,V>
Overrides:
keySet in class AbstractMap<String,V>

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

toString

public String toString()
Overrides:
toString in class AbstractMap<String,V>

clear

public void clear(long whenOlder)


Copyright © 2014 aQute SARL. All rights reserved.