summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-25 12:15:09 (EDT)
committerEike Stepper2007-08-25 12:15:09 (EDT)
commit283c4e2688d255b4be62168e785555fab71c022f (patch)
tree47f4a08c1c0807c87bd602182530f54730deb333
parent8fceba9c446e35ac16848787a36ae6f8e68cb784 (diff)
downloadcdo-283c4e2688d255b4be62168e785555fab71c022f.zip
cdo-283c4e2688d255b4be62168e785555fab71c022f.tar.gz
cdo-283c4e2688d255b4be62168e785555fab71c022f.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java
new file mode 100644
index 0000000..496f48c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/CachedFileMap.java
@@ -0,0 +1,38 @@
+package org.eclipse.net4j.util.io;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class CachedFileMap<K extends Comparable, V> extends SortedFileMap<K, V>
+{
+ private Map<K, V> cache = new HashMap();
+
+ public CachedFileMap(File file, String mode)
+ {
+ super(file, mode);
+ }
+
+ @Override
+ public V get(K key)
+ {
+ V value = cache.get(key);
+ if (value == null)
+ {
+ value = super.get(key);
+ cache.put(key, value);
+ }
+
+ return value;
+ }
+
+ @Override
+ public V put(K key, V value)
+ {
+ cache.put(key, value);
+ return super.put(key, value);
+ }
+}