Add isEmpty implementation.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@885269 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2009-11-29 21:22:50 +00:00
parent 40757f357b
commit 1a1cc17e5f
2 changed files with 21 additions and 0 deletions
@@ -256,6 +256,23 @@ public class CacheLineTable<K, V> implements Serializable {
nullValue = null;
}
public synchronized boolean isEmpty() {
if (fileTable != null) {
try {
return fileTable.keys().next() == null;
} catch (IOException e) {
Debug.logError(e, module);
return false;
}
} else {
if (isNullSet) {
return false;
} else {
return memoryTable.isEmpty();
}
}
}
public synchronized int size() {
if (fileTable != null) {
return this.keySet().size();
@@ -213,6 +213,10 @@ public class UtilCache<K, V> implements Serializable {
}
}
public boolean isEmpty() {
return cacheLineTable.isEmpty();
}
/** Puts or loads the passed element into the cache
* @param key The key for the element, used to reference it in the hastables and LRU linked list
* @param value The value of the element