From 1a1cc17e5ffe006d89e080f2d3e1ecdf1f8b94de Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Sun, 29 Nov 2009 21:22:50 +0000 Subject: [PATCH] Add isEmpty implementation. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@885269 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/base/util/cache/CacheLineTable.java | 17 +++++++++++++++++ .../org/ofbiz/base/util/cache/UtilCache.java | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java index 04a0302ca7..7410cb7f62 100644 --- a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java +++ b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java @@ -256,6 +256,23 @@ public class CacheLineTable 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(); diff --git a/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java b/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java index 37936267ef..bdb161116d 100644 --- a/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java +++ b/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java @@ -213,6 +213,10 @@ public class UtilCache 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