Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
replaced _all_ size() == 0 with isEmpty() and all size() > 0 with !isEmpty(). The isEmpty() method is much faster in some cases, especially when used to access badly balanced hashtables where an size() operation becomes a large iteration.
orbiter4a5100789faf
diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.javaindex 1af2066bd..7d101b96b 100644--- a/htroot/BlacklistCleaner_p.java+++ b/htroot/BlacklistCleaner_p.java@@ -113,8 +113,8 @@ public class BlacklistCleaner_p {prop.put(RESULTS + "blList", blacklistToUse);prop.put(RESULTS + "entries", illegalEntries.size());prop.putHTML(RESULTS + "blEngine", Switchboard.urlBlacklist.getEngineInfo());- prop.put(RESULTS + "disabled", (illegalEntries.size() == 0) ? "1" : "0");- if (illegalEntries.size() > 0) {+ prop.put(RESULTS + "disabled", (illegalEntries.isEmpty()) ? "1" : "0");+ if (!illegalEntries.isEmpty()) {prop.put(RESULTS + DISABLED + "entries", illegalEntries.size());int i = 0;String key;@@ -148,7 +148,7 @@ public class BlacklistCleaner_p {}if (supported) {- if (lists.size() > 0) {+ if (!lists.isEmpty()) {prop.put("disabled", "0");prop.put(DISABLED + "blacklists", lists.size());int count = 0;diff --git a/htroot/BlacklistImpExp_p.java b/htroot/BlacklistImpExp_p.javaindex 1a61dae32..8f32fadc2 100644--- a/htroot/BlacklistImpExp_p.java+++ b/htroot/BlacklistImpExp_p.java@@ -61,7 +61,7 @@ public class BlacklistImpExp_p {prop.putHTML("blacklistEngine", Switchboard.urlBlacklist.getEngineInfo());// if we have not chosen a blacklist until yet we use the first file- if (blacklistToUse == null && dirlist != null && dirlist.size() > 0) {+ if (blacklistToUse == null && dirlist != null && !dirlist.isEmpty()) {blacklistToUse = dirlist.get(0);}diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.javaindex 46e4a05b8..a6a168383 100644--- a/htroot/Blacklist_p.java+++ b/htroot/Blacklist_p.java@@ -354,7 +354,7 @@ public class Blacklist_p {}// if we have not chosen a blacklist until yet we use the first file- if (blacklistToUse == null && dirlist != null && dirlist.size() > 0) {+ if (blacklistToUse == null && dirlist != null && !dirlist.isEmpty()) {blacklistToUse = dirlist.get(0);}diff --git a/htroot/ConfigUpdate_p.java b/htroot/ConfigUpdate_p.javaindex 30de5d53a..c63a43d6c 100644--- a/htroot/ConfigUpdate_p.java+++ b/htroot/ConfigUpdate_p.java@@ -177,7 +177,7 @@ public class ConfigUpdate_p {}}// latest downloaded release- yacyVersion dflt = (downloadedReleases.size() == 0) ? null : downloadedReleases.last();+ yacyVersion dflt = (downloadedReleases.isEmpty()) ? null : downloadedReleases.last();int relcount = 0;for(yacyRelease release : downloadedReleases) {prop.put("candeploy_downloadedreleases_" + relcount + "_name", ((release.isMainRelease()) ? "main" : "dev") + " " + release.getReleaseNr() + "/" + release.getSvn());@@ -204,7 +204,7 @@ public class ConfigUpdate_p {}// dev- dflt = (releasess.dev.size() == 0) ? null : releasess.dev.last();+ dflt = (releasess.dev.isEmpty()) ? null : releasess.dev.last();final TreeSet<yacyRelease> remoteDevReleases = releasess.dev;remoteDevReleases.removeAll(downloadedReleases);for(yacyRelease release : remoteDevReleases) {diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.javaindex 4422ace8a..b24e2028c 100644--- a/htroot/IndexControlRWIs_p.java+++ b/htroot/IndexControlRWIs_p.java@@ -390,7 +390,7 @@ public class IndexControlRWIs_p {URIMetadataRow entry;String us;long rn = -1;- while ((ranked.size() > 0) && ((entry = ranked.takeURL(false, 60000)) != null)) {+ while (!ranked.isEmpty() && (entry = ranked.takeURL(false, 60000)) != null) {if ((entry == null) || (entry.metadata() == null)) continue;url = entry.metadata().url();if (url == null) continue;diff --git a/htroot/News.java b/htroot/News.javaindex f9b65997b..be6045f39 100644--- a/htroot/News.java+++ b/htroot/News.java@@ -126,7 +126,7 @@ public class News {final Map<String, String> attributeMap = record.attributes();prop.putHTML("table_list_" + i + "_att", attributeMap.toString());int j = 0;- if (attributeMap.size() > 0) {+ if (!attributeMap.isEmpty()) {for (Entry<String, String> attribute: attributeMap.entrySet()) {prop.put("table_list_" + i + "_attributes_" + j + "_name", attribute.getKey());prop.putHTML("table_list_" + i + "_attributes_" + j + "_value", attribute.getValue());diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.javaindex 40bd1ae79..c3a7bbc3f 100644--- a/htroot/Threaddump_p.java+++ b/htroot/Threaddump_p.java@@ -134,7 +134,7 @@ public class Threaddump_p {HashMap<String, Integer> dumps = dumpStatistic(rootPath, traces, plain, stateIn);// write dumps- while (dumps.size() > 0) {+ while (!dumps.isEmpty()) {Entry<String, Integer> e = removeMax(dumps);bufferappend(buffer, plain, "Occurrences: " + e.getValue());bufferappend(buffer, plain, e.getKey());diff --git a/htroot/api/feed.java b/htroot/api/feed.javaindex 76dc1f20b..227ea6592 100755--- a/htroot/api/feed.java+++ b/htroot/api/feed.java@@ -54,7 +54,7 @@ public class feed {// read the channelfeed = RSSFeed.channels(channels[channelIndex]);- if ((feed == null) || (feed.size() == 0)) continue channelIteration;+ if (feed == null || feed.isEmpty()) continue channelIteration;RSSMessage message = feed.getChannel();if (message != null) {@@ -62,7 +62,7 @@ public class feed {prop.putXML("channel_description", message.getDescription());prop.put("channel_pubDate", message.getPubDate());}- while ((messageMaxCount > 0) && (feed.size() > 0)) {+ while (messageMaxCount > 0 && !feed.isEmpty()) {message = feed.pollMessage();if (message == null) continue;diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.javaindex 308047d65..fd2bacca8 100644--- a/htroot/yacy/transferRWI.java+++ b/htroot/yacy/transferRWI.java@@ -212,7 +212,7 @@ public final class transferRWI {unknownURLs.append(",").append(it.next());}if (unknownURLs.length() > 0) { unknownURLs.delete(0, 1); }- if ((wordhashes.size() == 0) || (received == 0)) {+ if (wordhashes.isEmpty() || received == 0) {sb.getLog().logInfo("Received 0 RWIs from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs, blocked " + blocked + " RWIs");} else {String firstHash = wordhashes.get(0);diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 8c74602b7..e98ab2345 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -377,7 +377,7 @@ public class yacysearch {// filter out stopwordsfinal TreeSet<String> filtered = SetTools.joinConstructive(query[0], Switchboard.stopwords);- if (filtered.size() > 0) {+ if (!filtered.isEmpty()) {SetTools.excludeDestructive(query[0], Switchboard.stopwords);}@@ -543,7 +543,7 @@ public class yacysearch {// find geographic infoSet<Location> coordinates = LibraryProvider.geoDB.find(originalquerystring);- if (coordinates == null || coordinates.size() == 0 || offset > 0) {+ if (coordinates == null || coordinates.isEmpty() || offset > 0) {prop.put("geoinfo", "0");} else {int i = 0;@@ -628,14 +628,14 @@ public class yacysearch {prop.put("eventID", theQuery.id(false)); // for bottomline// process result of search- if (filtered.size() > 0) {+ if (!filtered.isEmpty()) {prop.put("excluded", "1");prop.putHTML("excluded_stopwords", filtered.toString());} else {prop.put("excluded", "0");}- if (prop == null || prop.size() == 0) {+ if (prop == null || prop.isEmpty()) {if (post == null || post.get("query", post.get("search", "")).length() < 3) {prop.put("num-results", "2"); // no results - at least 3 chars} else {diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.javaindex e98e03388..b1bc066e6 100644--- a/htroot/yacysearchtrailer.java+++ b/htroot/yacysearchtrailer.java@@ -61,7 +61,7 @@ public class yacysearchtrailer {// host navigatorsArrayList<NavigatorEntry> hostNavigator = theSearch.getHostNavigator(10);- if (hostNavigator == null || hostNavigator.size() == 0) {+ if (hostNavigator == null || hostNavigator.isEmpty()) {prop.put("nav-domains", 0);} else {prop.put("nav-domains", 1);@@ -83,7 +83,7 @@ public class yacysearchtrailer {// author navigatorsArrayList<NavigatorEntry> authorNavigator = theSearch.getAuthorNavigator(10);- if (authorNavigator == null || authorNavigator.size() == 0) {+ if (authorNavigator == null || authorNavigator.isEmpty()) {prop.put("nav-authors", 0);} else {prop.put("nav-authors", 1);@@ -107,7 +107,7 @@ public class yacysearchtrailer {// topics navigatorArrayList<NavigatorEntry> topicNavigator = theSearch.getTopicNavigator(10);- if (topicNavigator == null || topicNavigator.size() == 0) {+ if (topicNavigator == null || topicNavigator.isEmpty()) {topicNavigator = new ArrayList<NavigatorEntry>();prop.put("nav-topics", "0");} else {diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.javaindex 6209a0617..277ed5073 100644--- a/source/de/anomic/crawler/Balancer.java+++ b/source/de/anomic/crawler/Balancer.java@@ -194,7 +194,7 @@ public class Balancer {while (i.hasNext()) {if (urlHashes.contains(i.next())) i.remove();}- if (stack.size() == 0) q.remove();+ if (stack.isEmpty()) q.remove();}return removedCounter;@@ -214,12 +214,16 @@ public class Balancer {return urlFileIndex.size();}+ public boolean isEmpty() {+ return urlFileIndex.isEmpty();+ }+private boolean domainStacksNotEmpty() {if (domainStacks == null) return false;synchronized (domainStacks) {final Iterator<LinkedList<String>> i = domainStacks.values().iterator();while (i.hasNext()) {- if (i.next().size() > 0) return true;+ if (!i.next().isEmpty()) return true;}}return false;@@ -275,7 +279,7 @@ public class Balancer {}private String nextFromDelayed() {- if (this.delayed.size() == 0) return null;+ if (this.delayed.isEmpty()) return null;Long first = this.delayed.firstKey();if (first.longValue() < System.currentTimeMillis()) {return this.delayed.remove(first);@@ -284,7 +288,7 @@ public class Balancer {}private String anyFromDelayed() {- if (this.delayed.size() == 0) return null;+ if (this.delayed.isEmpty()) return null;Long first = this.delayed.firstKey();return this.delayed.remove(first);}@@ -325,11 +329,11 @@ public class Balancer {Request crawlEntry = null;synchronized (this) {String failhash = null;- while (this.urlFileIndex.size() > 0) {+ while (!this.urlFileIndex.isEmpty()) {// first simply take one of the entries in the top list, that should be one without any delayString nexthash = nextFromDelayed();//System.out.println("*** nextFromDelayed=" + nexthash);- if (nexthash == null && this.top.size() > 0) {+ if (nexthash == null && !this.top.isEmpty()) {nexthash = top.remove();//System.out.println("*** top.remove()=" + nexthash);}@@ -418,7 +422,7 @@ public class Balancer {}private void filltop(boolean delay, long maximumwaiting, boolean acceptonebest) {- if (this.top.size() > 0) return;+ if (!this.top.isEmpty()) return;//System.out.println("*** DEBUG started filltop delay=" + ((delay) ? "true":"false") + ", maximumwaiting=" + maximumwaiting + ", acceptonebest=" + ((acceptonebest) ? "true":"false"));@@ -438,7 +442,7 @@ public class Balancer {entry = i.next();// clean up empty entries- if (entry.getValue().size() == 0) {+ if (entry.getValue().isEmpty()) {i.remove();continue;}@@ -457,18 +461,18 @@ public class Balancer {}n = entry.getValue().removeFirst();this.top.add(n);- if (entry.getValue().size() == 0) i.remove();+ if (entry.getValue().isEmpty()) i.remove();}// if we could not find any entry, then take the best we have seen so far- if (acceptonebest && this.top.size() > 0 && besthash != null) {+ if (acceptonebest && !this.top.isEmpty() && besthash != null) {removeHashFromDomainStacks(besthash);this.top.add(besthash);}}private void fillDomainStacks(int maxdomstacksize) throws IOException {- if (this.domainStacks.size() > 0 && System.currentTimeMillis() - lastDomainStackFill < 120000L) return;+ if (!this.domainStacks.isEmpty() && System.currentTimeMillis() - lastDomainStackFill < 120000L) return;this.domainStacks.clear();//synchronized (this.delayed) { delayed.clear(); }this.lastDomainStackFill = System.currentTimeMillis();diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.javaindex cb25ab1a8..8a5268613 100644--- a/source/de/anomic/crawler/CrawlProfile.java+++ b/source/de/anomic/crawler/CrawlProfile.java@@ -501,7 +501,6 @@ public class CrawlProfile {} else {// increase counterdp.inc();- doms.put(domain, dp);}domsCache.put(this.mem.get(HANDLE), doms);}diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.javaindex af026bfd3..c028807bc 100644--- a/source/de/anomic/crawler/CrawlQueues.java+++ b/source/de/anomic/crawler/CrawlQueues.java@@ -380,7 +380,7 @@ public class CrawlQueues {// check if we have an entry in the provider list, otherwise fill the listyacySeed seed;- if (remoteCrawlProviderHashes.size() == 0) {+ if (remoteCrawlProviderHashes.isEmpty()) {if (sb.peers != null && sb.peers.sizeConnected() > 0) {final Iterator<yacySeed> e = PeerSelection.getProvidesRemoteCrawlURLs(sb.peers);while (e.hasNext()) {@@ -391,12 +391,12 @@ public class CrawlQueues {}}}- if (remoteCrawlProviderHashes.size() == 0) return false;+ if (remoteCrawlProviderHashes.isEmpty()) return false;// take one entry from the provider list and load the entries from the remote peerseed = null;String hash = null;- while ((seed == null) && (remoteCrawlProviderHashes.size() > 0)) {+ while ((seed == null) && (!remoteCrawlProviderHashes.isEmpty())) {hash = remoteCrawlProviderHashes.remove(remoteCrawlProviderHashes.size() - 1);if (hash == null) continue;seed = sb.peers.get(hash);@@ -411,7 +411,7 @@ public class CrawlQueues {// we know a peer which should provide remote crawl entries. load them now.final RSSFeed feed = yacyClient.queryRemoteCrawlURLs(sb.peers, seed, 30, 60000);- if (feed == null || feed.size() == 0) {+ if (feed == null || feed.isEmpty()) {// something is wrong with this provider. To prevent that we get not stuck with this peer// we remove it from the peer listsb.peers.peerActions.peerDeparture(seed, "no results from provided remote crawls");diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.javaindex 6db4c2a8f..61c68a172 100644--- a/source/de/anomic/crawler/CrawlStacker.java+++ b/source/de/anomic/crawler/CrawlStacker.java@@ -82,6 +82,11 @@ public final class CrawlStacker {public int size() {return this.fastQueue.queueSize() + this.slowQueue.queueSize();}+ public boolean isEmpty() {+ if (!this.fastQueue.queueIsEmpty()) return false;+ if (!this.slowQueue.queueIsEmpty()) return false;+ return true;+ }public void clear() {this.fastQueue.clear();diff --git a/source/de/anomic/crawler/ExternalIndexImporter.java b/source/de/anomic/crawler/ExternalIndexImporter.javaindex 1f1cb2133..c59245d7f 100644--- a/source/de/anomic/crawler/ExternalIndexImporter.java+++ b/source/de/anomic/crawler/ExternalIndexImporter.java@@ -170,7 +170,7 @@ public class ExternalIndexImporter extends AbstractImporter implements Importerif (isAborted()) break;// importing entity container to home db- if (newContainer.size() > 0) { homeWordIndex.termIndex().add(newContainer); }+ if (!newContainer.isEmpty()) { homeWordIndex.termIndex().add(newContainer); }// delete complete index entity filethis.importWordIndex.termIndex().delete(this.wordHash);diff --git a/source/de/anomic/crawler/NoticedURL.java b/source/de/anomic/crawler/NoticedURL.javaindex 537736acb..5f077c94e 100755--- a/source/de/anomic/crawler/NoticedURL.java+++ b/source/de/anomic/crawler/NoticedURL.java@@ -121,6 +121,14 @@ public class NoticedURL {return ((coreStack == null) ? 0 : coreStack.size()) + ((limitStack == null) ? 0 : limitStack.size()) + ((remoteStack == null) ? 0 : remoteStack.size());}+ public boolean isEmpty() {+ if (coreStack == null) return true;+ if (!coreStack.isEmpty()) return false;+ if (!limitStack.isEmpty()) return false;+ if (!remoteStack.isEmpty()) return false;+ return true;+ }+public int stackSize(final int stackType) {switch (stackType) {case STACK_TYPE_CORE: return (coreStack == null) ? 0 : coreStack.size();diff --git a/source/de/anomic/crawler/RobotsEntry.java b/source/de/anomic/crawler/RobotsEntry.javaindex c30bcd431..421fe8d20 100644--- a/source/de/anomic/crawler/RobotsEntry.java+++ b/source/de/anomic/crawler/RobotsEntry.java@@ -187,7 +187,7 @@ public class RobotsEntry {}public boolean isDisallowed(String path) {- if ((this.mem == null) || (this.denyPathList.size() == 0)) return false;+ if ((this.mem == null) || (this.denyPathList.isEmpty())) return false;// if the path is null or empty we set it to /if ((path == null) || (path.length() == 0)) path = "/";diff --git a/source/de/anomic/data/DidYouMean.java b/source/de/anomic/data/DidYouMean.javaindex f855d7ed3..6734e4c86 100644--- a/source/de/anomic/data/DidYouMean.java+++ b/source/de/anomic/data/DidYouMean.java@@ -73,7 +73,7 @@ public class DidYouMean {*/public String getSuggestion(final String word, long timeout) {Set<String> s = getSuggestions(word, timeout);- if (s == null || s.size() == 0) return null;+ if (s == null || s.isEmpty()) return null;return s.iterator().next();}@@ -85,7 +85,7 @@ public class DidYouMean {*/public String getSuggestion(final String word, long timeout, int preSortSelection) {Set<String> s = getSuggestions(word, timeout, preSortSelection);- if (s == null || s.size() == 0) return null;+ if (s == null || s.isEmpty()) return null;return s.iterator().next();}@@ -133,7 +133,7 @@ public class DidYouMean {SortedSet<String> result = new TreeSet<String>();StringBuilder sb;for (int i = 0; i < words.length; i++) {- if (s[i].size() == 0) continue;+ if (s[i].isEmpty()) continue;sb = new StringBuilder(20);for (int j = 0; j < words.length; j++) {if (j > 0) sb.append(' ');diff --git a/source/de/anomic/data/MimeTable.java b/source/de/anomic/data/MimeTable.javaindex 10350eeb3..c3a76911f 100644--- a/source/de/anomic/data/MimeTable.java+++ b/source/de/anomic/data/MimeTable.java@@ -12,7 +12,7 @@ public class MimeTable {private static final Properties mimeTable = new Properties();public static void init(File mimeFile) {- if (mimeTable.size() == 0) {+ if (mimeTable.isEmpty()) {// load the mime tableBufferedInputStream mimeTableInputStream = null;try {@@ -30,6 +30,10 @@ public class MimeTable {return mimeTable.size();}+ public static boolean isEmpty() {+ return mimeTable.isEmpty();+ }+public static String ext2mime(String ext) {return mimeTable.getProperty(ext, "application/" + ext);}diff --git a/source/de/anomic/data/listManager.java b/source/de/anomic/data/listManager.javaindex e97cdf297..c77af1872 100644--- a/source/de/anomic/data/listManager.java+++ b/source/de/anomic/data/listManager.java@@ -71,7 +71,7 @@ public class listManager {public static void removeFromListSet(final String setName, final String listName) {final Set<String> listSet = getListSet(setName);- if (listSet.size() > 0) {+ if (!listSet.isEmpty()) {listSet.remove(listName);switchboard.setConfig(setName, collection2string(listSet));}@@ -127,7 +127,7 @@ public class listManager {public static String collection2string(final Collection<String> col){final StringBuilder str = new StringBuilder();- if (col != null && (col.size() > 0)) {+ if (col != null && !col.isEmpty()) {final Iterator<String> it = col.iterator();str.append(it.next());while(it.hasNext()) {diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.javaindex 8942d2cb7..c5d255760 100644--- a/source/de/anomic/http/server/HTTPDFileHandler.java+++ b/source/de/anomic/http/server/HTTPDFileHandler.java@@ -142,7 +142,7 @@ public final class HTTPDFileHandler {if (switchboard == null) {switchboard = theSwitchboard;- if (MimeTable.size() == 0) {+ if (MimeTable.isEmpty()) {// load the mime tablefinal String mimeTablePath = theSwitchboard.getConfig("mimeTable","");Log.logConfig("HTTPDFiles", "Loading mime mapping file " + mimeTablePath);@@ -174,7 +174,7 @@ public final class HTTPDFileHandler {if (!(htTemplatePath.exists())) htTemplatePath.mkdir();}//This is now handles by #%env/templates/foo%#- //if (templates.size() == 0) templates.putAll(httpTemplate.loadTemplates(htTemplatePath));+ //if (templates.isEmpty()) templates.putAll(httpTemplate.loadTemplates(htTemplatePath));// create htLocaleDefault, htLocalePathif (htDefaultPath == null) htDefaultPath = theSwitchboard.getConfigPath("htDefaultPath", "htroot");diff --git a/source/de/anomic/http/server/HTTPDProxyHandler.java b/source/de/anomic/http/server/HTTPDProxyHandler.javaindex 3857d1fc8..c0acce0ca 100644--- a/source/de/anomic/http/server/HTTPDProxyHandler.java+++ b/source/de/anomic/http/server/HTTPDProxyHandler.java@@ -485,7 +485,7 @@ public final class HTTPDProxyHandler {final ResponseHeader responseHeader = res.getResponseHeader();// determine if it's an internal error of the httpc- if (responseHeader.size() == 0) {+ if (responseHeader.isEmpty()) {throw new Exception(res.getStatusLine());}@@ -570,7 +570,7 @@ public final class HTTPDProxyHandler {FileUtils.copy(res.getDataAsStream(), toClientAndMemory);// cached bytesbyte[] cacheArray;- if(byteStream.size() > 0) {+ if (byteStream.size() > 0) {cacheArray = byteStream.toByteArray();} else {cacheArray = null;@@ -821,7 +821,7 @@ public final class HTTPDProxyHandler {// determine if it's an internal error of the httpcfinal ResponseHeader responseHeader = res.getResponseHeader();- if (responseHeader.size() == 0) {+ if (responseHeader.isEmpty()) {throw new Exception(res.getStatusLine());}@@ -937,7 +937,7 @@ public final class HTTPDProxyHandler {final ResponseHeader responseHeader = res.getResponseHeader();// determine if it's an internal error of the httpc- if (responseHeader.size() == 0) {+ if (responseHeader.isEmpty()) {throw new Exception(res.getStatusLine());}diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.javaindex 166db7030..a8cbc55ce 100644--- a/source/de/anomic/http/server/HTTPDemon.java+++ b/source/de/anomic/http/server/HTTPDemon.java@@ -1167,9 +1167,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {switch (errorcase) {case ERRORCASE_FILE:tp.put("errorMessageType_file", (detailedErrorMsgFile == null) ? "" : detailedErrorMsgFile.toString());- if ((detailedErrorMsgValues != null) && (detailedErrorMsgValues.size() > 0)) {+ if ((detailedErrorMsgValues != null) && !detailedErrorMsgValues.isEmpty()) {// rewriting the value-names and add the proper name prefix:- for(Entry<String, String> entry: detailedErrorMsgValues.entrySet()) {+ for (Entry<String, String> entry: detailedErrorMsgValues.entrySet()) {tp.put("errorMessageType_" + entry.getKey(), entry.getValue());}}diff --git a/source/de/anomic/search/MediaSnippet.java b/source/de/anomic/search/MediaSnippet.javaindex 04aa0b388..734bf9158 100644--- a/source/de/anomic/search/MediaSnippet.java+++ b/source/de/anomic/search/MediaSnippet.java@@ -109,7 +109,7 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaS}public static ArrayList<MediaSnippet> retrieveMediaSnippets(final DigestURI url, final TreeSet<byte[]> queryhashes, final ContentDomain mediatype, final boolean fetchOnline, final int timeout, final boolean reindexing) {- if (queryhashes.size() == 0) {+ if (queryhashes.isEmpty()) {Log.logFine("snippet fetch", "no query hashes given for url " + url);return new ArrayList<MediaSnippet>();}@@ -194,12 +194,12 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaSurl = entry.getKey();desc = entry.getValue();s = removeAppearanceHashes(url.toNormalform(false, false), queryhashes);- if (s.size() == 0) {+ if (isEmpty()) {result += "<br /><a href=\"" + url + "\">" + ((desc.length() == 0) ? url : desc) + "</a>";continue;}s = removeAppearanceHashes(desc, s);- if (s.size() == 0) {+ if (isEmpty()) {result += "<br /><a href=\"" + url + "\">" + ((desc.length() == 0) ? url : desc) + "</a>";continue;}diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.javaindex 8d7bb944a..4d72ef06b 100644--- a/source/de/anomic/search/RankingProcess.java+++ b/source/de/anomic/search/RankingProcess.java@@ -131,7 +131,7 @@ public final class RankingProcess extends Thread {this.localSearchInclusion = search.inclusion();final ReferenceContainer<WordReference> index = search.joined();MemoryTracker.update("SEARCH", new ProfilingGraph.searchEvent(query.id(true), SearchEvent.JOIN, index.size(), System.currentTimeMillis() - timer), false);- if (index.size() == 0) {+ if (index.isEmpty()) {return;}@@ -147,7 +147,7 @@ public final class RankingProcess extends Thread {// attention: if minEntries is too high, this method will not terminate within the maxTimeassert (index != null);- if (index.size() == 0) return;+ if (index.isEmpty()) return;if (local) {this.local_resourceSize += fullResource;} else {@@ -306,7 +306,7 @@ public final class RankingProcess extends Thread {// returns from the current RWI list the best entry and removes this entry from the listSortStack<WordReferenceVars> m;SortStack<WordReferenceVars>.stackElement rwi;- while (stack.size() > 0) {+ while (!stack.isEmpty()) {rwi = stack.pop();if (rwi == null) continue; // in case that a synchronization problem occurred just go lazy over itif (!skipDoubleDom) return rwi;@@ -336,7 +336,7 @@ public final class RankingProcess extends Thread {break; // not the best solution...}if (m == null) continue;- if (m.size() == 0) continue;+ if (m.isEmpty()) continue;if (bestEntry == null) {bestEntry = m.top();continue;@@ -461,6 +461,14 @@ public final class RankingProcess extends Thread {return c;}+ public boolean isEmpty() {+ if (!stack.isEmpty()) return false;+ for (SortStack<WordReferenceVars> s: this.doubleDomCache.values()) {+ if (!s.isEmpty()) return false;+ }+ return true;+ }+public int[] flagCount() {return flagcount;}@@ -705,3 +713,12 @@ public final class RankingProcess extends Thread {}}+/*+Thread= Thread-937 id=4224 BLOCKED+Thread= Thread-919 id=4206 BLOCKED+Thread= Thread-936 id=4223 BLOCKED+at net.yacy.kelondro.util.SortStack.pop(SortStack.java:118)+at de.anomic.search.RankingProcess.takeRWI(RankingProcess.java:310)+at de.anomic.search.RankingProcess.takeURL(RankingProcess.java:371)+at de.anomic.search.ResultFetcher$Worker.run(ResultFetcher.java:161)+*/diff --git a/source/de/anomic/search/ReferenceOrder.java b/source/de/anomic/search/ReferenceOrder.javaindex 9b499bed0..341190afe 100644--- a/source/de/anomic/search/ReferenceOrder.java+++ b/source/de/anomic/search/ReferenceOrder.java@@ -107,7 +107,7 @@ public class ReferenceOrder {entry = di.next();doms.addScore(entry.getKey(), (entry.getValue()).intValue());}- if (doms.size() > 0) maxdomcount = doms.getMaxScore();+ if (!doms.isEmpty()) maxdomcount = doms.getMaxScore();} catch (InterruptedException e) {Log.logException(e);} catch (Exception e) {diff --git a/source/de/anomic/search/ResultEntry.java b/source/de/anomic/search/ResultEntry.javaindex ebc59e522..95f8a5bf5 100644--- a/source/de/anomic/search/ResultEntry.java+++ b/source/de/anomic/search/ResultEntry.java@@ -161,7 +161,7 @@ public class ResultEntry implements Comparable<ResultEntry>, Comparator<ResultEnreturn (this.textSnippet != null) && (this.textSnippet.getErrorCode() < 11);}public boolean hasMediaSnippets() {- return (this.mediaSnippets != null) && (this.mediaSnippets.size() > 0);+ return (this.mediaSnippets != null) && (!this.mediaSnippets.isEmpty());}public String resource() {// generate transport resourcediff --git a/source/de/anomic/search/ResultFetcher.java b/source/de/anomic/search/ResultFetcher.javaindex cad90cd7c..9b7eb813b 100644--- a/source/de/anomic/search/ResultFetcher.java+++ b/source/de/anomic/search/ResultFetcher.java@@ -88,7 +88,7 @@ public class ResultFetcher {// only with the query minus the stopwords which had not been used for the searchfinal TreeSet<byte[]> filtered = SetTools.joinConstructive(query.queryHashes, Switchboard.stopwordHashes);this.snippetFetchWordHashes = (TreeSet<byte[]>) query.queryHashes.clone();- if ((filtered != null) && (filtered.size() > 0)) {+ if (filtered != null && !filtered.isEmpty()) {SetTools.excludeDestructive(this.snippetFetchWordHashes, Switchboard.stopwordHashes);}@@ -241,7 +241,7 @@ public class ResultFetcher {final long snippetComputationTime = System.currentTimeMillis() - startTime;Log.logInfo("SEARCH_EVENT", "media snippet load time for " + metadata.url() + ": " + snippetComputationTime);- if ((mediaSnippets != null) && (mediaSnippets.size() > 0)) {+ if (mediaSnippets != null && !mediaSnippets.isEmpty()) {// found media snippets, return entryreturn new ResultEntry(page, query.getSegment(), peers, null, mediaSnippets, dbRetrievalTime, snippetComputationTime);} else if (snippetMode == 1) {diff --git a/source/de/anomic/search/SearchEvent.java b/source/de/anomic/search/SearchEvent.javaindex eb1c86e88..971294cd9 100644--- a/source/de/anomic/search/SearchEvent.java+++ b/source/de/anomic/search/SearchEvent.java@@ -114,7 +114,7 @@ public final class SearchEvent {// start global searchesfinal long timer = System.currentTimeMillis();Log.logFine("SEARCH_EVENT", "STARTING " + fetchpeers + " THREADS TO CATCH EACH " + query.displayResults() + " URLs");- this.primarySearchThreads = (query.queryHashes.size() == 0) ? null : yacySearch.primaryRemoteSearches(+ this.primarySearchThreads = (query.queryHashes.isEmpty()) ? null : yacySearch.primaryRemoteSearches(QueryParams.hashSet2hashString(query.queryHashes),QueryParams.hashSet2hashString(query.excludeHashes),"",diff --git a/source/de/anomic/search/SearchEventCache.java b/source/de/anomic/search/SearchEventCache.javaindex e3ae76287..a567f0c22 100644--- a/source/de/anomic/search/SearchEventCache.java+++ b/source/de/anomic/search/SearchEventCache.java@@ -73,7 +73,7 @@ public class SearchEventCache {String id = query.id(false);SearchEvent event = SearchEventCache.lastEvents.get(id);- if (Switchboard.getSwitchboard() != null && Switchboard.getSwitchboard().crawlQueues.noticeURL.size() > 0 && event != null && System.currentTimeMillis() - event.getEventTime() > 60000) {+ if (Switchboard.getSwitchboard() != null && !Switchboard.getSwitchboard().crawlQueues.noticeURL.isEmpty() && event != null && System.currentTimeMillis() - event.getEventTime() > 60000) {// if a local crawl is ongoing, don't use the result from the cache to use possibly more results that come from the current crawl// to prevent that this happens during a person switches between the different result pages, a re-search happens no more than// once a minutediff --git a/source/de/anomic/search/Segment.java b/source/de/anomic/search/Segment.javaindex e0952a8a8..1f67b5f13 100644--- a/source/de/anomic/search/Segment.java+++ b/source/de/anomic/search/Segment.java@@ -468,7 +468,7 @@ public class Segment {}}}- if (urlHashs.size() > 0) try {+ if (!urlHashs.isEmpty()) try {final int removed = termIndex.remove(container.getTermHash(), urlHashs);Log.logFine("INDEXCLEANER", container.getTermHashAsString() + ": " + removed + " of " + container.size() + " URL-entries deleted");lastWordHash = container.getTermHash();diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.javaindex e0432952f..e4c4cbadf 100644--- a/source/de/anomic/search/Switchboard.java+++ b/source/de/anomic/search/Switchboard.java@@ -433,7 +433,7 @@ public final class Switchboard extends serverSwitch {listManager.reloadBlacklists();// load badwords (to filter the topwords)- if (badwords == null || badwords.size() == 0) {+ if (badwords == null || badwords.isEmpty()) {final File badwordsFile = new File(rootPath, SwitchboardConstants.LIST_BADWORDS_DEFAULT);badwords = SetTools.loadList(badwordsFile, NaturalOrder.naturalComparator);badwordHashes = Word.words2hashes(badwords);@@ -443,7 +443,7 @@ public final class Switchboard extends serverSwitch {}// load stopwords- if (stopwords == null || stopwords.size() == 0) {+ if (stopwords == null || stopwords.isEmpty()) {final File stopwordsFile = new File(rootPath, SwitchboardConstants.LIST_STOPWORDS_DEFAULT);stopwords = SetTools.loadList(stopwordsFile, NaturalOrder.naturalComparator);stopwordHashes = Word.words2hashes(stopwords);@@ -1092,7 +1092,7 @@ public final class Switchboard extends serverSwitch {crawlQueues.coreCrawlJobSize() > 0 ||crawlQueues.limitCrawlJobSize() > 0 ||crawlQueues.remoteTriggeredCrawlJobSize() > 0 ||- (crawlStacker != null && crawlStacker.size() > 0) ||+ (crawlStacker != null && !crawlStacker.isEmpty()) ||crawlQueues.noticeURL.notEmpty())return false;return this.crawler.cleanProfiles();diff --git a/source/de/anomic/search/TextSnippet.java b/source/de/anomic/search/TextSnippet.javaindex 01ce68b0e..1201243ad 100644--- a/source/de/anomic/search/TextSnippet.java+++ b/source/de/anomic/search/TextSnippet.java@@ -197,7 +197,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip}public String getLineMarked(final TreeSet<byte[]> queryHashes) {if (line == null) return "";- if ((queryHashes == null) || (queryHashes.size() == 0)) return line.trim();+ if ((queryHashes == null) || (queryHashes.isEmpty())) return line.trim();if (line.endsWith(".")) line = line.substring(0, line.length() - 1);final Iterator<byte[]> i = queryHashes.iterator();byte[] h;@@ -310,7 +310,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnippublic static TextSnippet retrieveTextSnippet(final URIMetadataRow.Components comp, final TreeSet<byte[]> queryhashes, final boolean fetchOnline, final boolean pre, final int snippetMaxLength, final int maxDocLen, final boolean reindexing) {// heise = "0OQUNU3JSs05"final DigestURI url = comp.url();- if (queryhashes.size() == 0) {+ if (queryhashes.isEmpty()) {//System.out.println("found no queryhashes for URL retrieve " + url);return new TextSnippet(url, null, ERROR_NO_HASH_GIVEN, queryhashes, "no query hashes given");}@@ -427,7 +427,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip//if (hrefline != null) line += (line.length() == 0) ? hrefline : "<br />" + hrefline;if (textline != null) line += (line.length() == 0) ? textline : "<br />" + textline;- if ((line == null) || (remainingHashes.size() > 0)) return new TextSnippet(url, null, ERROR_NO_MATCH, remainingHashes, "no matching snippet found",resFavicon);+ if (line == null || !remainingHashes.isEmpty()) return new TextSnippet(url, null, ERROR_NO_MATCH, remainingHashes, "no matching snippet found",resFavicon);if (line.length() > snippetMaxLength) line = line.substring(0, snippetMaxLength);// finally store this snippet in our own cache@@ -451,7 +451,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnipcomputeTextSnippet(final Iterator<StringBuilder> sentences, final TreeSet<byte[]> queryhashes, int maxLength) {try {if (sentences == null) return null;- if ((queryhashes == null) || (queryhashes.size() == 0)) return null;+ if ((queryhashes == null) || (queryhashes.isEmpty())) return null;Iterator<byte[]> j;TreeMap<byte[], Integer> hs;StringBuilder sentence;@@ -471,14 +471,14 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnipString result;TreeSet<byte[]> remaininghashes;- while (os.size() > 0) {+ while (!os.isEmpty()) {sentence = os.remove(os.lastKey()); // sentence with the biggest scoreObject[] tsr = computeTextSnippet(sentence.toString(), queryhashes, maxLength);if (tsr == null) continue;result = (String) tsr[0];if ((result != null) && (result.length() > 0)) {remaininghashes = (TreeSet<byte[]>) tsr[1];- if (remaininghashes.size() == 0) {+ if (remaininghashes.isEmpty()) {// we have found the snippetreturn new Object[]{result, remaininghashes};} else if (remaininghashes.size() < queryhashes.size()) {@@ -510,7 +510,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnipcomputeTextSnippet(String sentence, final TreeSet<byte[]> queryhashes, final int maxLength) {try {if (sentence == null) return null;- if ((queryhashes == null) || (queryhashes.size() == 0)) return null;+ if ((queryhashes == null) || (queryhashes.isEmpty())) return null;byte[] hash;// find all hashes that appear in the sentencediff --git a/source/de/anomic/server/serverAccessTracker.java b/source/de/anomic/server/serverAccessTracker.javaindex 8097dcd54..2cc447bf0 100644--- a/source/de/anomic/server/serverAccessTracker.java+++ b/source/de/anomic/server/serverAccessTracker.java@@ -58,7 +58,7 @@ public class serverAccessTracker {SortedMap<Long, String> track;while (i.hasNext()) {track = i.next().getValue();- if (track.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime)).size() == 0) {+ if (track.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime)).isEmpty()) {// all entries are too old. delete the whole tracki.remove();} else {@@ -116,7 +116,7 @@ public class serverAccessTracker {synchronized (access) {if ((access = clearTooOldAccess(access)).size() != access.size()) {// write back to tracker- if (access.size() == 0) {+ if (access.isEmpty()) {accessTracker.remove(host);} else {accessTracker.put(host, access);diff --git a/source/de/anomic/tools/disorderHeap.java b/source/de/anomic/tools/disorderHeap.javaindex 8f5c386c2..7615426e2 100644--- a/source/de/anomic/tools/disorderHeap.java+++ b/source/de/anomic/tools/disorderHeap.java@@ -50,7 +50,7 @@ public class disorderHeap implements Serializable {}public synchronized String remove() {- if (list.size() == 0) return null;+ if (list.isEmpty()) return null;final int pos = (int) ((System.currentTimeMillis() / 13) % list.size());return list.remove(pos);}@@ -69,6 +69,9 @@ public class disorderHeap implements Serializable {return list.size();}+ public synchronized boolean isEmpty() {+ return list.isEmpty();+ }public static void main(final String[] args) {final disorderHeap ul = new disorderHeap();diff --git a/source/de/anomic/tools/disorderSet.java b/source/de/anomic/tools/disorderSet.javaindex 8af16cb79..b5e028d34 100644--- a/source/de/anomic/tools/disorderSet.java+++ b/source/de/anomic/tools/disorderSet.java@@ -28,7 +28,7 @@ import java.util.Set;public class disorderSet extends HashSet<String> implements Set<String> {private static final long serialVersionUID = 1L;- disorderHeap dh;+ private disorderHeap dh;public disorderSet() {super();@@ -36,13 +36,13 @@ public class disorderSet extends HashSet<String> implements Set<String> {}public boolean hasAny() {- return (this.size() > 0);+ return !this.isEmpty();}public String any() {// return just any element- if ((dh == null) || (dh.size() == 0)) {- if (this.size() == 0) return null;+ if (dh == null || dh.isEmpty()) {+ if (this.isEmpty()) return null;// fill up the queuedh = new disorderHeap();final Iterator<String> elements = this.iterator();diff --git a/source/de/anomic/tools/enumerateFiles.java b/source/de/anomic/tools/enumerateFiles.javaindex 4833d5353..1c5f45c84 100644--- a/source/de/anomic/tools/enumerateFiles.java+++ b/source/de/anomic/tools/enumerateFiles.java@@ -65,14 +65,14 @@ public class enumerateFiles implements Enumeration<File> {do {// System.out.println("D " + hierarchy.toString());t = null;- while ((t == null) && (hierarchy.size() > 0)) {+ while ((t == null) && (!hierarchy.isEmpty())) {t = hierarchy.get(hierarchy.size() - 1);- if (t.size() == 0) {+ if (t.isEmpty()) {hierarchy.remove(hierarchy.size() - 1); // we step up one hierarchyt = null;}}- if ((hierarchy.size() == 0) || (t == null || t.size() == 0)) return null; // this is the end+ if (hierarchy.isEmpty() || (t == null || t.isEmpty())) return null; // this is the end// fetch valueif (incOrder) f = t.first(); else f = t.last();t.remove(f);diff --git a/source/de/anomic/tools/loaderCore.java b/source/de/anomic/tools/loaderCore.javaindex f0d1c7a00..f86e93bfd 100644--- a/source/de/anomic/tools/loaderCore.java+++ b/source/de/anomic/tools/loaderCore.java@@ -68,7 +68,7 @@ public abstract class loaderCore implements loaderProcess {public boolean available() {// true if it is ok to feed with feed()return (status() == STATUS_READY) ||- ((status() == STATUS_COMPLETED) && ((result == null) || (result.size() == 0)));+ (status() == STATUS_COMPLETED && (result == null || result.isEmpty()));}public Exception error() {diff --git a/source/de/anomic/tools/nxTools.java b/source/de/anomic/tools/nxTools.javaindex b9dc6391a..5b7881bc5 100644--- a/source/de/anomic/tools/nxTools.java+++ b/source/de/anomic/tools/nxTools.java@@ -91,14 +91,14 @@ public class nxTools {}public static String tail1(final Vector<String> list) {- if ((list == null) || (list.size() == 0)) return "";+ if (list == null || list.isEmpty()) return "";return list.lastElement();}public static String tail1(final ArrayList<String> list) {- if ((list == null) || (list.size() == 0)) return "";+ if (list == null || list.isEmpty()) return "";return list.get(list.size()-1);- }+ }public static String awk(String sentence, final String separator, int count) {// returns the nth word of sentence, where count is the counter and the first word has the number 1diff --git a/source/de/anomic/yacy/dht/Dispatcher.java b/source/de/anomic/yacy/dht/Dispatcher.javaindex 9999cbd82..cc9e26dc0 100755--- a/source/de/anomic/yacy/dht/Dispatcher.java+++ b/source/de/anomic/yacy/dht/Dispatcher.java@@ -154,7 +154,7 @@ public class Dispatcher {ArrayList<ReferenceContainer<WordReference>> containers = selectContainers(hash, limitHash, maxContainerCount, maxReferenceCount, maxtime, false);// if ram does not provide any result, take from file- //if (containers.size() == 0) containers = selectContainers(hash, limitHash, maxContainerCount, maxtime, false);+ //if (containers.isEmpty()) containers = selectContainers(hash, limitHash, maxContainerCount, maxtime, false);return containers;}@@ -180,11 +180,11 @@ public class Dispatcher {(indexContainerIterator.hasNext()) &&(System.currentTimeMillis() < timeout) &&((container = indexContainerIterator.next()) != null) &&- ((containers.size() == 0) ||+ ((containers.isEmpty()) ||(Base64Order.enhancedCoder.compare(container.getTermHash(), limitHash) < 0))) {- if (container.size() == 0) continue;+ if (container.isEmpty()) continue;refcount += container.size();containers.add(container);}@@ -201,7 +201,7 @@ public class Dispatcher {urlHashes.add(it.next().metadataHash());}if (this.log.isFine()) this.log.logFine("selected " + urlHashes.size() + " urls for word '" + c.getTermHashAsString() + "'");- if (urlHashes.size() > 0) this.segment.termIndex().remove(c.getTermHash(), urlHashes);+ if (!urlHashes.isEmpty()) this.segment.termIndex().remove(c.getTermHash(), urlHashes);}rc = containers;} else {@@ -321,7 +321,7 @@ public class Dispatcher {ArrayList<ReferenceContainer<WordReference>> selectedContainerCache = selectContainers(hash, limitHash, maxContainerCount, maxReferenceCount, maxtime);this.log.logInfo("selectContainersToCache: selectedContainerCache was filled with " + selectedContainerCache.size() + " entries");- if (selectedContainerCache == null || selectedContainerCache.size() == 0) {+ if (selectedContainerCache == null || selectedContainerCache.isEmpty()) {this.log.logInfo("splitContainersFromCache: selectedContainerCache is empty, cannot do anything here.");return false;}diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.javaindex dfe91f848..20a099969 100644--- a/source/de/anomic/yacy/dht/Transmission.java+++ b/source/de/anomic/yacy/dht/Transmission.java@@ -184,7 +184,7 @@ public class Transmission {}public boolean transmit() {- if (this.targets.size() == 0) return false;+ if (this.targets.isEmpty()) return false;yacySeed target = this.targets.remove(0);// transferring selected words to remote peerif (target == seeds.mySeed() || target.hash.equals(seeds.mySeed().hash)) {diff --git a/source/de/anomic/yacy/graphics/WebStructureGraph.java b/source/de/anomic/yacy/graphics/WebStructureGraph.javaindex 0da5c688f..aa3d9d2e4 100644--- a/source/de/anomic/yacy/graphics/WebStructureGraph.java+++ b/source/de/anomic/yacy/graphics/WebStructureGraph.java@@ -257,7 +257,7 @@ public class WebStructureGraph {}}}- if (h.size() == 0) return null;+ if (h.isEmpty()) return null;return new structureEntry(domhash, domain, date, h);}diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex a5221f6d3..a5b57d760 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -319,7 +319,7 @@ public final class yacyClient {final byte[] content = postToFile(target, "query.html", post, 10000);final HashMap<String, String> result = FileUtils.table(content);- if (result == null || result.size() == 0) { return null; }+ if (result == null || result.isEmpty()) { return null; }//final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote timereturn yacySeed.genRemoteSeed(result.get("response"), salt, false);} catch (final Exception e) {@@ -341,7 +341,7 @@ public final class yacyClient {final byte[] content = postToFile(target, "query.html", post, 5000);final HashMap<String, String> result = FileUtils.table(content);- if (result == null || result.size() == 0) { return -1; }+ if (result == null || result.isEmpty()) { return -1; }return Integer.parseInt(result.get("response"));} catch (final Exception e) {yacyCore.log.logSevere("yacyClient.queryRWICount error:" + e.getMessage());@@ -364,7 +364,7 @@ public final class yacyClient {final byte[] content = postToFile(target, "query.html", post, 5000);final HashMap<String, String> result = FileUtils.table(content);- if ((result == null) || (result.size() == 0)) return -1;+ if (result == null || result.isEmpty()) return -1;final String resp = result.get("response");if (resp == null) {return -1;@@ -493,7 +493,7 @@ public final class yacyClient {return null;}- if ((result == null) || (result.size() == 0)) {+ if (result == null || result.isEmpty()) {if (yacyCore.log.isFine()) yacyCore.log.logFine("SEARCH failed FROM "+ target.hash+ ":"diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex d065cdec9..c90239353 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -338,7 +338,7 @@ public class yacyCore {seeds = PeerSelection.seedsByAge(sb.peers, false, attempts); // best for seed list maintenance/cleaning}- if ((seeds == null) || seeds.size() == 0) { return 0; }+ if (seeds == null || seeds.isEmpty()) { return 0; }if (seeds.size() < attempts) { attempts = seeds.size(); }// This will try to get Peers that are not currently in amIAccessibleDBdiff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.javaindex 8ea29dd6b..9e4e1b762 100644--- a/source/de/anomic/yacy/yacyNewsPool.java+++ b/source/de/anomic/yacy/yacyNewsPool.java@@ -308,7 +308,7 @@ public class yacyNewsPool {public yacyNewsRecord myPublication() throws IOException {// generate a record for next peer-ping- if (outgoingNews.size() == 0) return null;+ if (outgoingNews.isEmpty()) return null;final yacyNewsRecord record = outgoingNews.topInc();if ((record != null) && (record.distributed() >= maxDistribution)) {// move record to its final position. This is only for historydiff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.javaindex c81356ec8..810aa718b 100644--- a/source/de/anomic/yacy/yacyNewsQueue.java+++ b/source/de/anomic/yacy/yacyNewsQueue.java@@ -99,23 +99,27 @@ public class yacyNewsQueue {public int size() {return queueStack.size();}++ public boolean isEmpty() {+ return queueStack.isEmpty();+ }public synchronized void push(final yacyNewsRecord entry) throws IOException {queueStack.push(r2b(entry, true));}public synchronized yacyNewsRecord pop() throws IOException {- if (queueStack.size() == 0) return null;+ if (queueStack.isEmpty()) return null;return b2r(queueStack.pop());}public synchronized yacyNewsRecord top() throws IOException {- if (queueStack.size() == 0) return null;+ if (queueStack.isEmpty()) return null;return b2r(queueStack.top());}public synchronized yacyNewsRecord topInc() throws IOException {- if (queueStack.size() == 0) return null;+ if (queueStack.isEmpty()) return null;final yacyNewsRecord entry = pop();if (entry != null) {entry.incDistribution();diff --git a/source/de/anomic/yacy/yacyRelease.java b/source/de/anomic/yacy/yacyRelease.javaindex 072d39bd4..77c051a72 100644--- a/source/de/anomic/yacy/yacyRelease.java+++ b/source/de/anomic/yacy/yacyRelease.java@@ -127,8 +127,8 @@ public final class yacyRelease extends yacyVersion {// check if we know that there is a release that is more recent than that which we are usingfinal DevAndMainVersions releases = yacyRelease.allReleases(true, sb.getConfig("update.onlySignedFiles", "1").equals("1"));- final yacyRelease latestmain = (releases.main.size() == 0) ? null : releases.main.last();- final yacyRelease latestdev = (releases.dev.size() == 0) ? null : releases.dev.last();+ final yacyRelease latestmain = (releases.main.isEmpty()) ? null : releases.main.last();+ final yacyRelease latestdev = (releases.dev.isEmpty()) ? null : releases.dev.last();final String concept = sb.getConfig("update.concept", "any");String blacklist = sb.getConfig("update.blacklist", "...[123]");if (blacklist.equals("....[123]")) {@@ -213,10 +213,10 @@ public final class yacyRelease extends yacyVersion {DevAndMainVersions locLatestRelease = latestReleases.get(location);if (force ||(locLatestRelease == null) /*||- ((latestRelease[0].size() == 0) &&- (latestRelease[1].size() == 0) &&- (latestRelease[2].size() == 0) &&- (latestRelease[3].size() == 0) )*/) {+ ((latestRelease[0].isEmpty()) &&+ (latestRelease[1].isEmpty()) &&+ (latestRelease[2].isEmpty()) &&+ (latestRelease[3].isEmpty()) )*/) {locLatestRelease = allReleaseFrom(location);latestReleases.put(location, locLatestRelease);}@@ -607,7 +607,7 @@ public final class yacyRelease extends yacyVersion {}// if we have some files- if(downloadedreleases.size() > 0) {+ if (!downloadedreleases.isEmpty()) {Log.logFine("STARTUP", "deleting downloaded releases older than "+ deleteAfterDays +" days");// keep latest versiondiff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex c76dc2c9f..6eba6d00d 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -677,7 +677,7 @@ public class yacySeed implements Cloneable {// take one gap; prefer biggest but take also another smaller by chanceString interval = null;final Random r = new Random();- while (gaps.size() > 0) {+ while (!gaps.isEmpty()) {interval = gaps.remove(gaps.lastKey());if (r.nextBoolean()) break;}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 5ec6f5825..1db61ee9f 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -215,7 +215,7 @@ public final class yacySeedDB implements AlternativeDomainNames {}public synchronized void removeMySeed() {- if ((seedActiveDB.size() == 0) && (seedPassiveDB.size() == 0) && (seedPotentialDB.size() == 0)) return; // avoid that the own seed is initialized too early+ if (seedActiveDB.isEmpty() && seedPassiveDB.isEmpty() && seedPotentialDB.isEmpty()) return; // avoid that the own seed is initialized too earlyif (this.mySeed == null) initMySeed();try {seedActiveDB.remove(mySeed.hash);diff --git a/source/net/yacy/dbtest.java b/source/net/yacy/dbtest.javaindex c7d1c5a45..342710ea9 100644--- a/source/net/yacy/dbtest.java+++ b/source/net/yacy/dbtest.java@@ -436,7 +436,7 @@ public class dbtest {for (int j = 0; j < readCount; j++) {InstantBusyThread.oneTimeJob(new ReadJob(table_test, table_reference, random.nextLong() % writeCount), random.nextLong() % 1000, 20);}- if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {+ if (!ra.isEmpty() && random.nextLong() % 7 == 0) {rc++;p = Math.abs(random.nextInt() % ra.size());R = ra.get(p);@@ -477,7 +477,7 @@ public class dbtest {for (int j = 0; j < readCount; j++) {new ReadJob(table_test, table_reference, random.nextLong() % writeCount).run();}- if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {+ if (!ra.isEmpty() && random.nextLong() % 7 == 0) {rc++;p = Math.abs(random.nextInt() % ra.size());R = ra.get(p);diff --git a/source/net/yacy/document/Condenser.java b/source/net/yacy/document/Condenser.javaindex a59c73552..9eb892c11 100644--- a/source/net/yacy/document/Condenser.java+++ b/source/net/yacy/document/Condenser.java@@ -117,10 +117,10 @@ public final class Condenser {this.RESULT_FLAGS = new Bitfield(4);// construct flag set for document- if (document.getImages().size() > 0) RESULT_FLAGS.set(flag_cat_hasimage, true);- if (document.getAudiolinks().size() > 0) RESULT_FLAGS.set(flag_cat_hasaudio, true);- if (document.getVideolinks().size() > 0) RESULT_FLAGS.set(flag_cat_hasvideo, true);- if (document.getApplinks().size() > 0) RESULT_FLAGS.set(flag_cat_hasapp, true);+ if (!document.getImages().isEmpty()) RESULT_FLAGS.set(flag_cat_hasimage, true);+ if (!document.getAudiolinks().isEmpty()) RESULT_FLAGS.set(flag_cat_hasaudio, true);+ if (!document.getVideolinks().isEmpty()) RESULT_FLAGS.set(flag_cat_hasvideo, true);+ if (!document.getApplinks().isEmpty()) RESULT_FLAGS.set(flag_cat_hasapp, true);this.languageIdentificator = new Identificator();@@ -566,7 +566,7 @@ public final class Condenser {sIndex = 0;s.clear();}- while (s.size() == 0) {+ while (s.isEmpty()) {if (!e.hasNext()) return null;r = e.next();if (r == null) return null;diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.javaindex c5fedc7f6..8444d6765 100644--- a/source/net/yacy/document/Document.java+++ b/source/net/yacy/document/Document.java@@ -152,7 +152,7 @@ public class Document {*/public String dc_language() {if (this.languages == null) return null;- if (this.languages.size() == 0) return null;+ if (this.languages.isEmpty()) return null;if (this.languages.size() == 1) return languages.iterator().next();if (this.languages.contains(this.source.language())) return this.source.language();// now we are confused: the declared languages differ all from the TLD@@ -203,7 +203,7 @@ dc_rightss = (this.keywords.get(i)).trim();if (s.length() > 0) hs.add(s.toLowerCase());}- if (hs.size() == 0) return "";+ if (hs.isEmpty()) return "";// generate a new listfinal StringBuilder sb = new StringBuilder(this.keywords.size() * 6);final Iterator<String> i = hs.iterator();diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.javaindex 721a67ed7..8c3b06dc1 100644--- a/source/net/yacy/document/TextParser.java+++ b/source/net/yacy/document/TextParser.java@@ -212,7 +212,7 @@ public final class TextParser {final String documentCharset = htmlParser.patchCharsetEncoding(charset);List<Idiom> idioms = idiomParser(location, mimeType);- if (idioms.size() == 0) {+ if (idioms.isEmpty()) {final String errorMsg = "No parser available to parse extension '" + location.getFileExtension() + "' or mimetype '" + mimeType + "'";log.logInfo("Unable to parse '" + location + "'. " + errorMsg);throw new ParserException(errorMsg, location);@@ -249,7 +249,7 @@ public final class TextParser {try {// try to get a parser. If this works, we don't need the parser itself, we just return null to show that everything is ok.List<Idiom> idioms = idiomParser(url, mimeType);- return (idioms == null || idioms.size() == 0) ? "no parser found" : null;+ return (idioms == null || idioms.isEmpty()) ? "no parser found" : null;} catch (ParserException e) {// in case that a parser is not available, return a error string describing the problem.return e.getMessage();diff --git a/source/net/yacy/document/language/Identificator.java b/source/net/yacy/document/language/Identificator.javaindex dddb6517f..e7fef8c43 100644--- a/source/net/yacy/document/language/Identificator.java+++ b/source/net/yacy/document/language/Identificator.java@@ -130,7 +130,7 @@ public final class Identificator {}}- if (relevantLanguages.size() == 0) return null;+ if (relevantLanguages.isEmpty()) return null;// compare characters in text with characters in statisticsfinal float[] offsetList = new float[relevantLanguages.size()];diff --git a/source/net/yacy/document/parser/csvParser.java b/source/net/yacy/document/parser/csvParser.javaindex 57208dea9..8e8598195 100644--- a/source/net/yacy/document/parser/csvParser.java+++ b/source/net/yacy/document/parser/csvParser.java@@ -78,7 +78,7 @@ public class csvParser extends AbstractParser implements Idiom {// the first row is used as headline// all lines are artificially terminated by a '.' to separate them as sentence for the condenser.List<String[]> table = getTable(location, mimeType, charset, source);- if (table.size() == 0) throw new ParserException("document has no lines", location);+ if (table.isEmpty()) throw new ParserException("document has no lines", location);StringBuilder sb = new StringBuilder();for (String[] row: table) sb.append(concatRow(row)).append(' ');try {diff --git a/source/net/yacy/document/parser/html/ContentScraper.java b/source/net/yacy/document/parser/html/ContentScraper.javaindex e0fe109d1..2d5e6faf3 100644--- a/source/net/yacy/document/parser/html/ContentScraper.java+++ b/source/net/yacy/document/parser/html/ContentScraper.java@@ -290,7 +290,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {// otherwise take any headlinefor (int i = 0; i < 4; i++) {- if (headlines[i].size() > 0) return headlines[i].get(0);+ if (!headlines[i].isEmpty()) return headlines[i].get(0);}// take description tag@@ -393,7 +393,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {if (p > 0) cl[i] = cl[i].substring(0, p);if (ISO639.exists(cl[i])) hs.add(cl[i]);}- if (hs.size() == 0) return null;+ if (hs.isEmpty()) return null;return hs;}diff --git a/source/net/yacy/document/parser/html/ContentTransformer.java b/source/net/yacy/document/parser/html/ContentTransformer.javaindex c8720c8f4..c2d1979e4 100644--- a/source/net/yacy/document/parser/html/ContentTransformer.java+++ b/source/net/yacy/document/parser/html/ContentTransformer.java@@ -77,13 +77,13 @@ public class ContentTransformer extends AbstractTransformer implements Transformr.close();} catch (final IOException e) {}- // if (bluelist.size() == 0) System.out.println("BLUELIST is empty");+ // if (bluelist.isEmpty()) System.out.println("BLUELIST is empty");}}}public boolean isIdentityTransformer() {- return (bluelist.size() == 0);+ return bluelist.isEmpty();}private static char[] genBlueLetters(int length) {diff --git a/source/net/yacy/document/parser/html/TransformerWriter.java b/source/net/yacy/document/parser/html/TransformerWriter.javaindex 45c38bf6d..5564bb2ad 100644--- a/source/net/yacy/document/parser/html/TransformerWriter.java+++ b/source/net/yacy/document/parser/html/TransformerWriter.java@@ -144,7 +144,7 @@ public final class TransformerWriter extends Writer {}public static char[] genTag0(final String tagname, final Properties tagopts, final char quotechar) {- final char[] tagoptsx = (tagopts.size() == 0) ? null : genOpts(tagopts, quotechar);+ final char[] tagoptsx = (tagopts.isEmpty()) ? null : genOpts(tagopts, quotechar);final CharBuffer bb = new CharBuffer(tagname.length() + ((tagoptsx == null) ? 0 : (tagoptsx.length + 1)) + tagname.length() + 2);bb.append((int)'<').append(tagname);if (tagoptsx != null) {diff --git a/source/net/yacy/document/parser/rssParser.java b/source/net/yacy/document/parser/rssParser.javaindex 23d808dcf..b282c39c5 100644--- a/source/net/yacy/document/parser/rssParser.java+++ b/source/net/yacy/document/parser/rssParser.java@@ -133,17 +133,17 @@ public class rssParser extends AbstractParser implements Idiom {FileUtils.copy(new ByteArrayInputStream(itemContent.getBytes("UTF-8")), writer, Charset.forName("UTF-8"));final String itemHeadline = scraper.getTitle();- if ((itemHeadline != null) && (itemHeadline.length() > 0)) {+ if (itemHeadline != null && !itemHeadline.isEmpty()) {feedSections.add(itemHeadline);}final Map<DigestURI, String> itemLinks = scraper.getAnchors();- if ((itemLinks != null) && (itemLinks.size() > 0)) {+ if (itemLinks != null && !itemLinks.isEmpty()) {anchors.putAll(itemLinks);}final HashMap<String, ImageEntry> itemImages = scraper.getImages();- if ((itemImages != null) && (itemImages.size() > 0)) {+ if (itemImages != null && !itemImages.isEmpty()) {ContentScraper.addAllImages(images, itemImages);}diff --git a/source/net/yacy/document/parser/xml/RSSFeed.java b/source/net/yacy/document/parser/xml/RSSFeed.javaindex 341e0c0c1..ec0f9610f 100644--- a/source/net/yacy/document/parser/xml/RSSFeed.java+++ b/source/net/yacy/document/parser/xml/RSSFeed.java@@ -111,6 +111,10 @@ public class RSSFeed implements Iterable<RSSMessage> {return messages.get(guid);}+ public boolean isEmpty() {+ return messages.isEmpty();+ }+public int size() {return messages.size();}@@ -121,7 +125,7 @@ public class RSSFeed implements Iterable<RSSMessage> {public RSSMessage pollMessage() {// retrieve and delete item- if (messageQueue.size() == 0) return null;+ if (messageQueue.isEmpty()) return null;final String nextGUID = messageQueue.poll();if (nextGUID == null) return null;return messages.remove(nextGUID);diff --git a/source/net/yacy/kelondro/blob/ArrayStack.java b/source/net/yacy/kelondro/blob/ArrayStack.javaindex ceaeab382..18b69d99b 100755--- a/source/net/yacy/kelondro/blob/ArrayStack.java+++ b/source/net/yacy/kelondro/blob/ArrayStack.java@@ -287,7 +287,7 @@ public class ArrayStack implements BLOB {}public synchronized File smallestBLOB(File excluding, long maxsize) {- if (this.blobs.size() == 0) return null;+ if (this.blobs.isEmpty()) return null;File bestFile = null;long smallest = Long.MAX_VALUE;File f = null;@@ -305,7 +305,7 @@ public class ArrayStack implements BLOB {}public synchronized File unmountOldestBLOB(boolean smallestFromFirst2) {- if (this.blobs.size() == 0) return null;+ if (this.blobs.isEmpty()) return null;int idx = 0;if (smallestFromFirst2 && this.blobs.get(1).location.length() < this.blobs.get(0).location.length()) idx = 1;return unmount(idx);@@ -313,7 +313,7 @@ public class ArrayStack implements BLOB {/*public synchronized File unmountSimilarSizeBLOB(long otherSize) {- if (this.blobs.size() == 0 || otherSize == 0) return null;+ if (this.blobs.isEmpty() || otherSize == 0) return null;blobItem b;double delta, bestDelta = Double.MAX_VALUE;int bestIndex = -1;@@ -365,10 +365,10 @@ public class ArrayStack implements BLOB {private void executeLimits() {// check if storage limits are reached and execute consequences- if (blobs.size() == 0) return;+ if (blobs.isEmpty()) return;// age limit:- while (blobs.size() > 0 && System.currentTimeMillis() - blobs.get(0).creation.getTime() - this.fileAgeLimit > this.repositoryAgeMax) {+ while (!blobs.isEmpty() && System.currentTimeMillis() - blobs.get(0).creation.getTime() - this.fileAgeLimit > this.repositoryAgeMax) {// too oldblobItem oldestBLOB = blobs.remove(0);oldestBLOB.blob.close(false);@@ -377,7 +377,7 @@ public class ArrayStack implements BLOB {}// size limit- while (blobs.size() > 0 && length() > this.repositorySizeMax) {+ while (!blobs.isEmpty() && length() > this.repositorySizeMax) {// too largeblobItem oldestBLOB = blobs.remove(0);oldestBLOB.blob.close(false);@@ -446,6 +446,11 @@ public class ArrayStack implements BLOB {return s;}+ public synchronized boolean isEmpty() {+ for (blobItem bi: blobs) if (!bi.blob.isEmpty()) return false;+ return true;+ }+/*** ask for the number of blob entries in each blob of the blob array* @return the number of entries in each blob@@ -676,7 +681,7 @@ public class ArrayStack implements BLOB {* @throws IOException*/public synchronized void put(byte[] key, byte[] b) throws IOException {- blobItem bi = (blobs.size() == 0) ? null : blobs.get(blobs.size() - 1);+ blobItem bi = (blobs.isEmpty()) ? null : blobs.get(blobs.size() - 1);if (bi == null)System.out.println("bi == null");else if (System.currentTimeMillis() - bi.creation.getTime() > this.fileAgeLimit)diff --git a/source/net/yacy/kelondro/blob/BLOB.java b/source/net/yacy/kelondro/blob/BLOB.javaindex 8dd3cf2b6..5b37f0c1c 100644--- a/source/net/yacy/kelondro/blob/BLOB.java+++ b/source/net/yacy/kelondro/blob/BLOB.java@@ -64,6 +64,12 @@ public interface BLOB {*/public int size();+ /**+ * ask if the BLOB is empty+ * @return true iff size() == 0+ */+ public boolean isEmpty();+/*** iterator over all keys* @param updiff --git a/source/net/yacy/kelondro/blob/Compressor.java b/source/net/yacy/kelondro/blob/Compressor.javaindex 0feaf9ad7..33e823eda 100644--- a/source/net/yacy/kelondro/blob/Compressor.java+++ b/source/net/yacy/kelondro/blob/Compressor.java@@ -221,7 +221,7 @@ public class Compressor implements BLOB {// check if the buffer is full or could be full after this writeif (this.bufferlength + b.length * 2 > this.maxbufferlength) {// in case that we compress, just compress as much as is necessary to get enough room- while (this.bufferlength + b.length * 2 > this.maxbufferlength && this.buffer.size() > 0) {+ while (this.bufferlength + b.length * 2 > this.maxbufferlength && !this.buffer.isEmpty()) {flushOne();}// in case that this was not enough, just flush all@@ -245,6 +245,12 @@ public class Compressor implements BLOB {return this.backend.size() + this.buffer.size();}+ public synchronized boolean isEmpty() {+ if (!this.backend.isEmpty()) return false;+ if (!this.buffer.isEmpty()) return false;+ return true;+ }+public synchronized CloneableIterator<byte[]> keys(boolean up, boolean rotating) throws IOException {flushAll();return this.backend.keys(up, rotating);@@ -256,7 +262,7 @@ public class Compressor implements BLOB {}private boolean flushOne() throws IOException {- if (this.buffer.size() == 0) return false;+ if (this.buffer.isEmpty()) return false;// depending on process case, write it to the file or compress it to the other queueMap.Entry<String, byte[]> entry = this.buffer.entrySet().iterator().next();this.buffer.remove(entry.getKey());@@ -268,7 +274,7 @@ public class Compressor implements BLOB {}private void flushAll() throws IOException {- while (this.buffer.size() > 0) {+ while (!this.buffer.isEmpty()) {if (!flushOne()) break;}assert this.bufferlength == 0;diff --git a/source/net/yacy/kelondro/blob/Heap.java b/source/net/yacy/kelondro/blob/Heap.javaindex c72b8ff98..712c9735e 100755--- a/source/net/yacy/kelondro/blob/Heap.java+++ b/source/net/yacy/kelondro/blob/Heap.java@@ -314,7 +314,7 @@ public final class Heap extends HeapModifier implements BLOB {if (b.length == 0) return true;// then look if we can use a free entry- if (this.free.size() == 0) return false;+ if (this.free.isEmpty()) return false;// find the largest entrylong lseek = -1;diff --git a/source/net/yacy/kelondro/blob/HeapModifier.java b/source/net/yacy/kelondro/blob/HeapModifier.javaindex 714309fda..03c0e2344 100644--- a/source/net/yacy/kelondro/blob/HeapModifier.java+++ b/source/net/yacy/kelondro/blob/HeapModifier.java@@ -56,8 +56,6 @@ public class HeapModifier extends HeapReader implements BLOB {super(heapFile, keylength, ordering);}--/*** clears the content of the database* @throws IOException@@ -137,7 +135,7 @@ public class HeapModifier extends HeapReader implements BLOB {// first find the gap entry for the closest gap in front of the give gapSortedMap<Long, Integer> head = this.free.headMap(thisSeek);- if (head.size() == 0) return;+ if (head.isEmpty()) return;long previousSeek = head.lastKey().longValue();int previousSize = head.get(previousSeek).intValue();@@ -214,7 +212,7 @@ public class HeapModifier extends HeapReader implements BLOB {// find gaps at the end of the file and shrink the file by these gapsif (this.free == null) return;try {- while (this.free.size() > 0) {+ while (!this.free.isEmpty()) {Long seek = this.free.lastKey();int size = this.free.get(seek).intValue();if (seek.longValue() + size + 4 != this.file.length()) return;diff --git a/source/net/yacy/kelondro/blob/HeapReader.java b/source/net/yacy/kelondro/blob/HeapReader.javaindex 09f451225..7f9d53cb8 100644--- a/source/net/yacy/kelondro/blob/HeapReader.java+++ b/source/net/yacy/kelondro/blob/HeapReader.java@@ -154,7 +154,7 @@ public class HeapReader {FileUtils.deletedelete(fgf);// everything is fine now- return this.index.size() > 0;+ return !this.index.isEmpty();}private void initIndexReadFromHeap() throws IOException {@@ -260,6 +260,11 @@ public class HeapReader {return (this.index == null) ? 0 : this.index.size();}+ public synchronized boolean isEmpty() {+ if (this.index == null) return true;+ return this.index.isEmpty();+ }+/*** test if a key is in the heap file. This does not need any IO, because it uses only the ram index* @param keydiff --git a/source/net/yacy/kelondro/blob/MapDataMining.java b/source/net/yacy/kelondro/blob/MapDataMining.javaindex 329a5f4fc..5648562b1 100644--- a/source/net/yacy/kelondro/blob/MapDataMining.java+++ b/source/net/yacy/kelondro/blob/MapDataMining.java@@ -330,6 +330,10 @@ public class MapDataMining extends MapView {return super.size();}+ public synchronized boolean isEmpty() {+ return super.isEmpty();+ }+public synchronized void close() {// close clusterif (sortClusterMap != null) {diff --git a/source/net/yacy/kelondro/blob/MapView.java b/source/net/yacy/kelondro/blob/MapView.javaindex 4ae58c080..14347760a 100644--- a/source/net/yacy/kelondro/blob/MapView.java+++ b/source/net/yacy/kelondro/blob/MapView.java@@ -294,6 +294,10 @@ public class MapView {return (blob == null) ? 0 : blob.size();}+ public synchronized boolean isEmpty() {+ return (blob == null) ? true : blob.isEmpty();+ }+/*** close the Map table*/diff --git a/source/net/yacy/kelondro/index/Cache.java b/source/net/yacy/kelondro/index/Cache.javaindex 88e783eb4..3f4cb9a07 100644--- a/source/net/yacy/kelondro/index/Cache.java+++ b/source/net/yacy/kelondro/index/Cache.java@@ -482,6 +482,10 @@ public final class Cache implements ObjectIndex, Iterable<Row.Entry> {return index.size();}+ public final boolean isEmpty() {+ return index.isEmpty();+ }+public final String filename() {return index.filename();}diff --git a/source/net/yacy/kelondro/index/HandleMap.java b/source/net/yacy/kelondro/index/HandleMap.javaindex abc167ac2..a42743ad3 100644--- a/source/net/yacy/kelondro/index/HandleMap.java+++ b/source/net/yacy/kelondro/index/HandleMap.java@@ -262,6 +262,10 @@ public final class HandleMap implements Iterable<Row.Entry> {return index.size();}+ public final synchronized boolean isEmpty() {+ return index.isEmpty();+ }+public final synchronized CloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) {return index.keys(up, firstKey);}diff --git a/source/net/yacy/kelondro/index/ObjectArrayCache.java b/source/net/yacy/kelondro/index/ObjectArrayCache.javaindex 2a00e284c..bc2c98e07 100644--- a/source/net/yacy/kelondro/index/ObjectArrayCache.java+++ b/source/net/yacy/kelondro/index/ObjectArrayCache.java@@ -143,7 +143,7 @@ public final class ObjectArrayCache {}// at this point index1 cannot be nullassert (index1 != null);- if (index1.size() == 0) return null;+ if (index1.isEmpty()) return null;final Row.Entry indexentry = index1.remove(key);if (indexentry == null) return null;return indexentry.getColBytes(1);@@ -226,7 +226,7 @@ public final class ObjectArrayCache {jcontrol.add(Long.valueOf(r));kcontrol.putb((int) r, "x".getBytes());if (random.nextLong() % 5 == 0) ra.add(Long.valueOf(r));- if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {+ if (!ra.isEmpty() && random.nextLong() % 7 == 0) {rc++;p = Math.abs(random.nextInt() % ra.size());R = ra.get(p);diff --git a/source/net/yacy/kelondro/index/ObjectIndex.java b/source/net/yacy/kelondro/index/ObjectIndex.javaindex 664874f4c..d2bc5c685 100644--- a/source/net/yacy/kelondro/index/ObjectIndex.java+++ b/source/net/yacy/kelondro/index/ObjectIndex.java@@ -42,6 +42,7 @@ public interface ObjectIndex {public String filename(); // returns a unique identified for this index; can be a real or artificial file namepublic int size();+ public boolean isEmpty();public Row row();public boolean has(byte[] key); // use this only if there is no get in case that has returns truepublic Row.Entry get(byte[] key) throws IOException;diff --git a/source/net/yacy/kelondro/index/ObjectIndexCache.java b/source/net/yacy/kelondro/index/ObjectIndexCache.javaindex 051aaeef5..2fddb8364 100644--- a/source/net/yacy/kelondro/index/ObjectIndexCache.java+++ b/source/net/yacy/kelondro/index/ObjectIndexCache.java@@ -210,6 +210,20 @@ public final class ObjectIndexCache implements ObjectIndex, Iterable<Row.Entry>return index0.size() + index1.size();}+ public final synchronized boolean isEmpty() {+ if ((index0 != null) && (index1 == null)) {+ return index0.isEmpty();+ }+ if ((index0 == null) && (index1 != null)) {+ return index1.isEmpty();+ }+ assert ((index0 != null) && (index1 != null));+ if (!index0.isEmpty()) return false;+ if (!index1.isEmpty()) return false;+ return true;+ }++public final synchronized CloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) {// returns the key-iterator of the underlying kelondroIndexif (index1 == null) {diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.javaindex 4006f6c5c..7b03cf022 100644--- a/source/net/yacy/kelondro/index/RowCollection.java+++ b/source/net/yacy/kelondro/index/RowCollection.java@@ -452,6 +452,10 @@ public class RowCollection implements Iterable<Row.Entry> {return this.chunkcount;}+ public boolean isEmpty() {+ return this.chunkcount == 0;+ }+public int sorted() {return this.sortBound;}@@ -853,7 +857,7 @@ public class RowCollection implements Iterable<Row.Entry> {removeRow(i + 1, false);d++;if (i + 1 < chunkcount - 1) u = false;- } else if (collection.size() > 0) {+ } else if (!collection.isEmpty()) {// finish collection of double occurrencescollection.addUnique(get(i + 1, false));removeRow(i + 1, false);diff --git a/source/net/yacy/kelondro/index/RowSetArray.java b/source/net/yacy/kelondro/index/RowSetArray.javaindex 8c9a4a2d7..da7c78ae8 100644--- a/source/net/yacy/kelondro/index/RowSetArray.java+++ b/source/net/yacy/kelondro/index/RowSetArray.java@@ -143,7 +143,7 @@ public final class RowSetArray implements ObjectIndex, Iterable<Row.Entry> {for (int i = 0; i < this.array.length; i++) {if (this.array[i] != null) {col.addAll(this.array[i].removeDoubles());- if (this.array[i].size() == 0) this.array[i] = null;+ if (this.array[i].isEmpty()) this.array[i] = null;}}}@@ -155,7 +155,7 @@ public final class RowSetArray implements ObjectIndex, Iterable<Row.Entry> {for (int i = 0; i < this.array.length; i++) {if (this.array[i] != null) {Entry entry = this.array[i].removeOne();- if (this.array[i].size() == 0) this.array[i] = null;+ if (this.array[i].isEmpty()) this.array[i] = null;return entry;}}@@ -202,6 +202,17 @@ public final class RowSetArray implements ObjectIndex, Iterable<Row.Entry> {return c;}+ public final boolean isEmpty() {+ synchronized (this.array) {+ for (int i = 0; i < this.array.length; i++) {+ if (this.array[i] != null) {+ if (!this.array[i].isEmpty()) return false;+ }+ }+ }+ return true;+ }+public final Iterator<Entry> iterator() {return this.rows(true, null);}diff --git a/source/net/yacy/kelondro/order/MergeIterator.java b/source/net/yacy/kelondro/order/MergeIterator.javaindex ef10120ca..1893d132d 100644--- a/source/net/yacy/kelondro/order/MergeIterator.java+++ b/source/net/yacy/kelondro/order/MergeIterator.java@@ -136,7 +136,7 @@ public class MergeIterator<E> implements CloneableIterator<E> {// this extends the ability to combine two iterators// to the ability of combining a set of iteratorsif (iterators == null) return null;- if (iterators.size() == 0) return null;+ if (iterators.isEmpty()) return null;return cascade(iterators.iterator(), c, merger, up);}diff --git a/source/net/yacy/kelondro/order/StackIterator.java b/source/net/yacy/kelondro/order/StackIterator.javaindex ef75c7364..4ef50cda5 100644--- a/source/net/yacy/kelondro/order/StackIterator.java+++ b/source/net/yacy/kelondro/order/StackIterator.java@@ -91,7 +91,7 @@ public class StackIterator<E> implements CloneableIterator<E> {// this extends the ability to combine two iterators// to the ability of combining a set of iteratorsif (iterators == null) return null;- if (iterators.size() == 0) return null;+ if (iterators.isEmpty()) return null;return stack(iterators.iterator());}diff --git a/source/net/yacy/kelondro/rwi/AbstractBufferedIndex.java b/source/net/yacy/kelondro/rwi/AbstractBufferedIndex.javaindex 0e31459e6..b5ee47a62 100644--- a/source/net/yacy/kelondro/rwi/AbstractBufferedIndex.java+++ b/source/net/yacy/kelondro/rwi/AbstractBufferedIndex.java@@ -58,7 +58,7 @@ public abstract class AbstractBufferedIndex<ReferenceType extends Reference> ext// It must also be ensured that the counter is in/decreased every loopwhile ((count > 0) && (i.hasNext())) {container = i.next();- if ((container != null) && (container.size() > 0)) {+ if (container != null && !container.isEmpty()) {containers.add(container);}count--; // decrease counter even if the container was null or empty to ensure terminationdiff --git a/source/net/yacy/kelondro/rwi/AbstractIndex.java b/source/net/yacy/kelondro/rwi/AbstractIndex.javaindex db8de14fb..428ade6a1 100644--- a/source/net/yacy/kelondro/rwi/AbstractIndex.java+++ b/source/net/yacy/kelondro/rwi/AbstractIndex.java@@ -71,7 +71,7 @@ public abstract class AbstractIndex <ReferenceType extends Reference> implements// It must also be ensured that the counter is in/decreased every loopwhile ((count > 0) && (i.hasNext())) {container = i.next();- if ((container != null) && (container.size() > 0)) {+ if (container != null && !container.isEmpty()) {containers.add(container);}count--; // decrease counter even if the container was null or empty to ensure termination@@ -117,7 +117,7 @@ public abstract class AbstractIndex <ReferenceType extends Reference> implements}// check result- if ((singleContainer == null || singleContainer.size() == 0)) return new HashMap<byte[], ReferenceContainer<ReferenceType>>(0);+ if ((singleContainer == null || singleContainer.isEmpty())) return new HashMap<byte[], ReferenceContainer<ReferenceType>>(0);containers.put(singleHash, singleContainer);}@@ -154,13 +154,13 @@ public abstract class AbstractIndex <ReferenceType extends Reference> implements}// check result- if ((singleContainer == null || singleContainer.size() == 0)) return ReferenceContainer.emptyContainer(factory, null, 0);+ if ((singleContainer == null || singleContainer.isEmpty())) return ReferenceContainer.emptyContainer(factory, null, 0);if (resultContainer == null) resultContainer = singleContainer; else {resultContainer = ReferenceContainer.joinConstructive(factory, resultContainer, singleContainer, maxDistance);}// finish if the result is empty- if (resultContainer.size() == 0) return resultContainer;+ if (resultContainer.isEmpty()) return resultContainer;}return resultContainer;}diff --git a/source/net/yacy/kelondro/rwi/AbstractReference.java b/source/net/yacy/kelondro/rwi/AbstractReference.javaindex 8d9e77495..70b601a11 100644--- a/source/net/yacy/kelondro/rwi/AbstractReference.java+++ b/source/net/yacy/kelondro/rwi/AbstractReference.java@@ -37,7 +37,7 @@ public abstract class AbstractReference implements Reference {return l;}protected static int max(ArrayList<Integer> a) {- assert a.size() > 0;+ assert !a.isEmpty();if (a.size() == 1) return a.get(0);if (a.size() == 2) return Math.max(a.get(0), a.get(1));int r = a.get(0);@@ -45,7 +45,7 @@ public abstract class AbstractReference implements Reference {return r;}protected static int min(ArrayList<Integer> a) {- assert a.size() > 0;+ assert !a.isEmpty();if (a.size() == 1) return a.get(0);if (a.size() == 2) return Math.min(a.get(0), a.get(1));int r = a.get(0);diff --git a/source/net/yacy/kelondro/rwi/IODispatcher.java b/source/net/yacy/kelondro/rwi/IODispatcher.javaindex 882f75613..c6a3bc621 100644--- a/source/net/yacy/kelondro/rwi/IODispatcher.java+++ b/source/net/yacy/kelondro/rwi/IODispatcher.java@@ -83,7 +83,7 @@ public class IODispatcher extends Thread {public synchronized void dump(ReferenceContainerCache<? extends Reference> cache, File file, ReferenceContainerArray<? extends Reference> array) {if (dumpQueue == null || controlQueue == null || !this.isAlive()) {Log.logWarning("IODispatcher", "emergency dump of file " + file.getName());- if (cache.size() > 0) cache.dump(file, (int) Math.min(MemoryControl.available() / 3, writeBufferSize));+ if (!cache.isEmpty()) cache.dump(file, (int) Math.min(MemoryControl.available() / 3, writeBufferSize));} else {DumpJob<? extends Reference> job = (DumpJob<? extends Reference>)new DumpJob(cache, file, array);try {@@ -145,7 +145,7 @@ public class IODispatcher extends Thread {controlQueue.acquire();// prefer dump actions to flush memory to disc- if (dumpQueue.size() > 0) {+ if (!dumpQueue.isEmpty()) {File f = null;try {dumpJob = dumpQueue.take();@@ -162,7 +162,7 @@ public class IODispatcher extends Thread {}// otherwise do a merge operation- if (mergeQueue.size() > 0) {+ if (!mergeQueue.isEmpty()) {File f = null, f1 = null, f2 = null;try {mergeJob = mergeQueue.take();@@ -216,7 +216,7 @@ public class IODispatcher extends Thread {}public void dump() {try {- if (cache.size() > 0) cache.dump(file, (int) Math.min(MemoryControl.available() / 3, writeBufferSize));+ if (!cache.isEmpty()) cache.dump(file, (int) Math.min(MemoryControl.available() / 3, writeBufferSize));array.mountBLOBFile(file);} catch (IOException e) {Log.logException(e);diff --git a/source/net/yacy/kelondro/rwi/IndexCell.java b/source/net/yacy/kelondro/rwi/IndexCell.javaindex 57296e6d5..cc11b24c1 100644--- a/source/net/yacy/kelondro/rwi/IndexCell.java+++ b/source/net/yacy/kelondro/rwi/IndexCell.java@@ -286,7 +286,7 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu* and is composed of the current date and the cell salt*/public synchronized void close() {- if (this.ram.size() > 0) this.ram.dump(this.array.newContainerBLOBFile(), (int) Math.min(MemoryControl.available() / 3, writeBufferSize));+ if (!this.ram.isEmpty()) this.ram.dump(this.array.newContainerBLOBFile(), (int) Math.min(MemoryControl.available() / 3, writeBufferSize));// close allthis.ram.close();this.array.close();diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainer.java b/source/net/yacy/kelondro/rwi/ReferenceContainer.javaindex 3744ccc83..5c6b05c8d 100644--- a/source/net/yacy/kelondro/rwi/ReferenceContainer.java+++ b/source/net/yacy/kelondro/rwi/ReferenceContainer.java@@ -262,7 +262,7 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSetsingleContainer = i.next();// check result- if ((singleContainer == null) || (singleContainer.size() == 0)) return null; // as this is a cunjunction of searches, we have no result if any word is not known+ if (singleContainer == null || singleContainer.isEmpty()) return null; // as this is a cunjunction of searches, we have no result if any word is not known// store result in order of result sizemap.put(Long.valueOf(singleContainer.size() * 1000 + count), singleContainer);@@ -270,13 +270,13 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet}// check if there is any result- if (map.size() == 0) return null; // no result, nothing found+ if (map.isEmpty()) return null; // no result, nothing found// the map now holds the search results in order of number of hits per word// we now must pairwise build up a conjunction of these setsLong k = map.firstKey(); // the smallest, which means, the one with the least entriesReferenceContainer<ReferenceType> searchA, searchB, searchResult = map.remove(k);- while ((map.size() > 0) && (searchResult.size() > 0)) {+ while (!map.isEmpty() && !searchResult.isEmpty()) {// take the first element of map which is a result and combine it with resultk = map.firstKey(); // the next smallest...searchA = searchResult;@@ -288,7 +288,7 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet}// in 'searchResult' is now the combined search result- if (searchResult.size() == 0) return null;+ if (searchResult.isEmpty()) return null;return searchResult;}@@ -298,12 +298,12 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSetfinal Collection<ReferenceContainer<ReferenceType>> containers) {// check if there is any result- if ((containers == null) || (containers.size() == 0)) return pivot; // no result, nothing found+ if (containers == null || containers.isEmpty()) return pivot; // no result, nothing foundfinal Iterator<ReferenceContainer<ReferenceType>> i = containers.iterator();while (i.hasNext()) {pivot = excludeDestructive(factory, pivot, i.next());- if ((pivot == null) || (pivot.size() == 0)) return null;+ if (pivot == null || pivot.isEmpty()) return null;}return pivot;@@ -322,7 +322,7 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSetfinal ReferenceContainer<ReferenceType> i2,final int maxDistance) {if ((i1 == null) || (i2 == null)) return null;- if ((i1.size() == 0) || (i2.size() == 0)) return null;+ if (i1.isEmpty() || i2.isEmpty()) return null;// decide which method to usefinal int high = ((i1.size() > i2.size()) ? i1.size() : i2.size());@@ -418,8 +418,8 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSetfinal ReferenceContainer<ReferenceType> excl) {if (pivot == null) return null;if (excl == null) return pivot;- if (pivot.size() == 0) return null;- if (excl.size() == 0) return pivot;+ if (pivot.isEmpty()) return null;+ if (excl.isEmpty()) return pivot;// decide which method to usefinal int high = ((pivot.size() > excl.size()) ? pivot.size() : excl.size());diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.javaindex 3b33ac0e2..788fc0b90 100644--- a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java+++ b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java@@ -146,7 +146,10 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> extereturn (this.cache == null) ? 0 : this.cache.size();}-+ public boolean isEmpty() {+ if (this.cache == null) return true;+ return this.cache.isEmpty();+ }public int maxReferences() {// iterate to find the max score@@ -298,7 +301,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> extefinal ReferenceContainer<ReferenceType> c = cache.get(tha);if ((c != null) && (c.remove(urlHash) != null)) {// removal successful- if (c.size() == 0) {+ if (c.isEmpty()) {delete(termHash);} else {cache.put(tha, c);@@ -311,14 +314,14 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> extepublic int remove(final byte[] termHash, final Set<String> urlHashes) {assert this.cache != null;- if (urlHashes.size() == 0) return 0;+ if (urlHashes.isEmpty()) return 0;ByteArray tha = new ByteArray(termHash);int count;synchronized (cache) {final ReferenceContainer<ReferenceType> c = cache.get(tha);if ((c != null) && ((count = c.removeEntries(urlHashes)) > 0)) {// removal successful- if (c.size() == 0) {+ if (c.isEmpty()) {delete(termHash);} else {cache.put(tha, c);@@ -332,7 +335,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> extepublic void add(final ReferenceContainer<ReferenceType> container) {// this puts the entries into the cacheassert this.cache != null;- if (this.cache == null || container == null || container.size() == 0) return;+ if (this.cache == null || container == null || container.isEmpty()) return;// put new words into cacheByteArray tha = new ByteArray(container.getTermHash());diff --git a/source/net/yacy/kelondro/rwi/TermSearch.java b/source/net/yacy/kelondro/rwi/TermSearch.javaindex 3adaccb8b..4b0740e53 100644--- a/source/net/yacy/kelondro/rwi/TermSearch.java+++ b/source/net/yacy/kelondro/rwi/TermSearch.java@@ -46,7 +46,7 @@ public class TermSearch <ReferenceType extends Reference> {int maxDistance) {this.inclusionContainers =- (queryHashes.size() == 0) ?+ (queryHashes.isEmpty()) ?new HashMap<byte[], ReferenceContainer<ReferenceType>>(0) :base.searchConjunction(queryHashes, urlselection);@@ -55,7 +55,7 @@ public class TermSearch <ReferenceType extends Reference> {inclusionContainers = new HashMap<byte[], ReferenceContainer<ReferenceType>>(0); // prevent that only a subset is returnedHashMap<byte[], ReferenceContainer<ReferenceType>> exclusionContainers =- (inclusionContainers.size() == 0) ?+ (inclusionContainers.isEmpty()) ?new HashMap<byte[], ReferenceContainer<ReferenceType>>(0) :base.searchConjunction(excludeHashes, urlselection);diff --git a/source/net/yacy/kelondro/table/RecordStack.java b/source/net/yacy/kelondro/table/RecordStack.javaindex b202f3a7a..0beb8e24f 100644--- a/source/net/yacy/kelondro/table/RecordStack.java+++ b/source/net/yacy/kelondro/table/RecordStack.java@@ -237,7 +237,7 @@ public final class RecordStack extends Records {private Node topNode() throws IOException {// return node ontop of the stack- if (size() == 0) return null;+ if (isEmpty()) return null;final Records.Handle h = getHandle(toor);if (h == null) return null;return new Node(h);@@ -245,7 +245,7 @@ public final class RecordStack extends Records {private Node botNode() throws IOException {// return node on bottom of the stack- if (size() == 0) {+ if (isEmpty()) {Log.logInfo("Stack", "size() == 0");return null;}diff --git a/source/net/yacy/kelondro/table/SQLTable.java b/source/net/yacy/kelondro/table/SQLTable.javaindex 1f93d78fa..e103bc303 100644--- a/source/net/yacy/kelondro/table/SQLTable.java+++ b/source/net/yacy/kelondro/table/SQLTable.java@@ -138,6 +138,10 @@ public class SQLTable implements ObjectIndex, Iterable<Row.Entry> {}}+ public boolean isEmpty() {+ return size() == 0;+ }+public Row row() {return this.rowdef;}diff --git a/source/net/yacy/kelondro/table/SplitTable.java b/source/net/yacy/kelondro/table/SplitTable.javaindex f21aa151b..fe0b42be0 100644--- a/source/net/yacy/kelondro/table/SplitTable.java+++ b/source/net/yacy/kelondro/table/SplitTable.java@@ -186,7 +186,7 @@ public class SplitTable implements ObjectIndex, Iterable<Row.Entry> {String maxf;long maxram;ObjectIndex table;- while (t.size() > 0) {+ while (!t.isEmpty()) {// find maximum tablemaxram = 0;maxf = null;@@ -260,6 +260,12 @@ public class SplitTable implements ObjectIndex, Iterable<Row.Entry> {return s;}+ public boolean isEmpty() {+ final Iterator<ObjectIndex> i = tables.values().iterator();+ while (i.hasNext()) if (!i.next().isEmpty()) return false;+ return true;+ }+public int writeBufferSize() {int s = 0;for (final ObjectIndex index : tables.values()) {diff --git a/source/net/yacy/kelondro/table/Table.java b/source/net/yacy/kelondro/table/Table.javaindex 5577969ef..cecc19e4d 100644--- a/source/net/yacy/kelondro/table/Table.java+++ b/source/net/yacy/kelondro/table/Table.java@@ -200,7 +200,7 @@ public class Table implements ObjectIndex, Iterable<Row.Entry> {final ArrayList<Long[]> doubles = index.removeDoubles();//assert index.size() + doubles.size() + fail == i;//System.out.println(" -removed " + doubles.size() + " doubles- done.");- if (doubles.size() > 0) {+ if (!doubles.isEmpty()) {Log.logInfo("TABLE", tablefile + ": WARNING - TABLE " + tablefile + " has " + doubles.size() + " doubles");// from all the doubles take one, put it back to the index and remove the others from the file// first put back one element each@@ -219,7 +219,7 @@ public class Table implements ObjectIndex, Iterable<Row.Entry> {}// now remove the entries in a sorted way (top-down)Long top;- while (delpos.size() > 0) {+ while (!delpos.isEmpty()) {top = delpos.last();delpos.remove(top);removeInFile(top.intValue());@@ -337,7 +337,7 @@ public class Table implements ObjectIndex, Iterable<Row.Entry> {}// finally delete the affected rows, but start with largest id first, otherwise we overwrite wrong entriesLong s;- while (d.size() > 0) {+ while (!d.isEmpty()) {s = d.last();d.remove(s);this.removeInFile(s.intValue());@@ -629,6 +629,10 @@ public class Table implements ObjectIndex, Iterable<Row.Entry> {return index.size();}+ public synchronized boolean isEmpty() {+ return index.isEmpty();+ }+public Iterator<Entry> iterator() {try {return rows();diff --git a/source/net/yacy/kelondro/util/MemoryTracker.java b/source/net/yacy/kelondro/util/MemoryTracker.javaindex b0ad7f9fc..8a0808eab 100644--- a/source/net/yacy/kelondro/util/MemoryTracker.java+++ b/source/net/yacy/kelondro/util/MemoryTracker.java@@ -98,7 +98,7 @@ public class MemoryTracker extends Thread {if (history.size() % 10 == 0) { // reduce number of System.currentTimeMillis() callsEvent e;final long now = System.currentTimeMillis();- while (history.size() > 0) {+ while (!history.isEmpty()) {e = history.get(0);if (now - e.time < 600000) break;history.remove(0);diff --git a/source/net/yacy/kelondro/util/ObjectSpace.java b/source/net/yacy/kelondro/util/ObjectSpace.javaindex 1616d5986..6a83f1775 100644--- a/source/net/yacy/kelondro/util/ObjectSpace.java+++ b/source/net/yacy/kelondro/util/ObjectSpace.java@@ -58,7 +58,7 @@ public class ObjectSpace {incAlive(len);synchronized (objHeap) {final ArrayList<byte[]> buf = objHeap.get(Integer.valueOf(len));- if ((buf == null) || (buf.size() == 0)) return new byte[len];+ if (buf == null || buf.isEmpty()) return new byte[len];return buf.remove(buf.size() - 1);}}diff --git a/source/net/yacy/kelondro/util/ScoreCluster.java b/source/net/yacy/kelondro/util/ScoreCluster.javaindex a57d50c98..dde06a561 100644--- a/source/net/yacy/kelondro/util/ScoreCluster.java+++ b/source/net/yacy/kelondro/util/ScoreCluster.java@@ -176,6 +176,10 @@ public final class ScoreCluster<E> {return refkeyDB.size();}+ public synchronized boolean isEmpty() {+ return refkeyDB.isEmpty();+ }+public synchronized void incScore(final E[] objs) {for (int i = 0; i < objs.length; i++) addScore(objs[i], 1);}@@ -293,22 +297,22 @@ public final class ScoreCluster<E> {}public synchronized int getMaxScore() {- if (refkeyDB.size() == 0) return -1;+ if (refkeyDB.isEmpty()) return -1;return (int) ((keyrefDB.lastKey().longValue() & 0xFFFFFFFF00000000L) >> 32);}public synchronized int getMinScore() {- if (refkeyDB.size() == 0) return -1;+ if (refkeyDB.isEmpty()) return -1;return (int) ((keyrefDB.firstKey().longValue() & 0xFFFFFFFF00000000L) >> 32);}public synchronized E getMaxObject() {- if (refkeyDB.size() == 0) return null;+ if (refkeyDB.isEmpty()) return null;return keyrefDB.get(keyrefDB.lastKey());}public synchronized E getMinObject() {- if (refkeyDB.size() == 0) return null;+ if (refkeyDB.isEmpty()) return null;return keyrefDB.get(keyrefDB.firstKey());}@@ -368,7 +372,7 @@ public final class ScoreCluster<E> {private void internalNext() {Long key;int score = (max + min) / 2;- while (keyrefDBcopy.size() > 0) {+ while (!keyrefDBcopy.isEmpty()) {key = ((up) ? keyrefDBcopy.firstKey() : keyrefDBcopy.lastKey());n = keyrefDBcopy.remove(key);score = (int) ((key.longValue() & 0xFFFFFFFF00000000L) >> 32);@@ -404,7 +408,7 @@ public final class ScoreCluster<E> {}public boolean hasNext() {- return view.size() > 0;+ return !view.isEmpty();}public E next() {diff --git a/source/net/yacy/kelondro/util/SetTools.java b/source/net/yacy/kelondro/util/SetTools.javaindex 56e39f141..0125aa1a4 100644--- a/source/net/yacy/kelondro/util/SetTools.java+++ b/source/net/yacy/kelondro/util/SetTools.java@@ -78,7 +78,7 @@ public class SetTools {singleMap = i.next();// check result- if ((singleMap == null) || (singleMap.size() == 0)) return new TreeMap<A, B>();+ if ((singleMap == null) || (singleMap.isEmpty())) return new TreeMap<A, B>();// store result in order of result sizeorderMap.put(Long.valueOf(singleMap.size() * 1000 + count), singleMap);@@ -86,12 +86,12 @@ public class SetTools {}// check if there is any result- if (orderMap.size() == 0) return new TreeMap<A, B>();+ if (orderMap.isEmpty()) return new TreeMap<A, B>();// we now must pairwise build up a conjunction of these mapsLong k = orderMap.firstKey(); // the smallest, which means, the one with the least entriesTreeMap<A, B> mapA, mapB, joinResult = orderMap.remove(k);- while ((orderMap.size() > 0) && (joinResult.size() > 0)) {+ while (!orderMap.isEmpty() && !joinResult.isEmpty()) {// take the first element of map which is a result and combine it with resultk = orderMap.firstKey(); // the next smallest...mapA = joinResult;@@ -103,7 +103,7 @@ public class SetTools {}// in 'searchResult' is now the combined search result- if (joinResult.size() == 0) return new TreeMap<A, B>();+ if (joinResult.isEmpty()) return new TreeMap<A, B>();return joinResult;}@@ -111,7 +111,7 @@ public class SetTools {// comparators must be equalif ((map1 == null) || (map2 == null)) return null;if (map1.comparator() != map2.comparator()) return null;- if ((map1.size() == 0) || (map2.size() == 0)) return new TreeMap<A, B>(map1.comparator());+ if (map1.isEmpty() || map2.isEmpty()) return new TreeMap<A, B>(map1.comparator());// decide which method to usefinal int high = ((map1.size() > map2.size()) ? map1.size() : map2.size());@@ -183,7 +183,7 @@ public class SetTools {// comparators must be equalif ((set1 == null) || (set2 == null)) return null;if (set1.comparator() != set2.comparator()) return null;- if ((set1.size() == 0) || (set2.size() == 0)) return new TreeSet<A>(set1.comparator());+ if (set1.isEmpty() || set2.isEmpty()) return new TreeSet<A>(set1.comparator());// decide which method to usefinal int high = ((set1.size() > set2.size()) ? set1.size() : set2.size());@@ -241,7 +241,7 @@ public class SetTools {// comparators must be equalif ((set1 == null) || (set2 == null)) return false;if (set1.comparator() != set2.comparator()) return false;- if ((set1.size() == 0) || (set2.size() == 0)) return false;+ if (set1.isEmpty() || set2.isEmpty()) return false;// decide which method to usefinal int high = ((set1.size() > set2.size()) ? set1.size() : set2.size());@@ -297,7 +297,7 @@ public class SetTools {public static <A, B> TreeMap<A, B> excludeConstructive(final TreeMap<A, B> map, final Set<A> set) {if (map == null) return null;if (set == null) return map;- if ((map.size() == 0) || (set.size() == 0)) return map;+ if (map.isEmpty() || set.isEmpty()) return map;assert !(set instanceof TreeSet) || map.comparator() == ((TreeSet<A>) set).comparator();// if (map.comparator() != set.comparator()) return excludeConstructiveByTestMapInSet(map, set);return excludeConstructiveByTestMapInSet(map, set);@@ -320,7 +320,7 @@ public class SetTools {if (map == null) return;if (set == null) return;assert !(map instanceof TreeMap && set instanceof TreeSet) || ((TreeMap<A, B>) map).comparator() == ((TreeSet<A>) set).comparator();- if ((map.size() == 0) || (set.size() == 0)) return;+ if (map.isEmpty() || set.isEmpty()) return;if (map.size() < set.size())excludeDestructiveByTestMapInSet(map, set);@@ -343,7 +343,7 @@ public class SetTools {if (set1 == null) return;if (set2 == null) return;assert !(set1 instanceof TreeSet && set2 instanceof TreeSet) || ((TreeSet<A>) set1).comparator() == ((TreeSet<A>) set2).comparator();- if ((set1.size() == 0) || (set2.size() == 0)) return;+ if (set1.isEmpty() || set2.isEmpty()) return;if (set1.size() < set2.size())excludeDestructiveByTestSmallInLarge(set1, set2);diff --git a/source/net/yacy/kelondro/util/SortStack.java b/source/net/yacy/kelondro/util/SortStack.javaindex 2428db8f4..3ffdd464e 100644--- a/source/net/yacy/kelondro/util/SortStack.java+++ b/source/net/yacy/kelondro/util/SortStack.java@@ -56,6 +56,11 @@ public class SortStack<E> {this.maxsize = maxsize;}++ public boolean isEmpty() {+ return this.instack.isEmpty();+ }+public int size() {return this.instack.size();}@@ -82,8 +87,8 @@ public class SortStack<E> {// check maximum size of the stack an remove elements if the stack gets too largeif (this.maxsize <= 0) return;- while ((this.onstack.size() > 0) && (this.onstack.size() > this.maxsize)) synchronized (this.onstack) {- if ((this.onstack.size() > 0) && (this.onstack.size() > this.maxsize)) {+ while (!this.onstack.isEmpty() && this.onstack.size() > this.maxsize) synchronized (this.onstack) {+ if (!this.onstack.isEmpty() && this.onstack.size() > this.maxsize) {this.onstack.remove(this.onstack.lastKey());}}@@ -121,7 +126,7 @@ public class SortStack<E> {final List<E> l = this.onstack.get(w);element = l.remove(0);this.instack.remove(element);- if (l.size() == 0) this.onstack.remove(w);+ if (l.isEmpty()) this.onstack.remove(w);}return new stackElement(element, w);}@@ -140,7 +145,7 @@ public class SortStack<E> {while (i.hasNext()) {if (i.next().equals(element)) {i.remove();- if (entry.getValue().size() == 0) {+ if (entry.getValue().isEmpty()) {this.onstack.remove(entry.getKey());}return;@@ -152,7 +157,7 @@ public class SortStack<E> {public boolean bottom(final long weight) {// returns true if the element with that weight would be on the bottom of the stack after inserting- if (this.onstack.size() == 0) return true;+ if (this.onstack.isEmpty()) return true;Long l;synchronized (this.onstack) {l = this.onstack.lastKey();diff --git a/source/net/yacy/kelondro/util/SortStore.java b/source/net/yacy/kelondro/util/SortStore.javaindex 8328691db..6f8d7f3fa 100644--- a/source/net/yacy/kelondro/util/SortStore.java+++ b/source/net/yacy/kelondro/util/SortStore.java@@ -54,6 +54,11 @@ public class SortStore<E> extends SortStack<E> {this.offset = new ConcurrentHashMap<E, Object>();}+ public boolean isEmpty() {+ if (!super.isEmpty()) return false;+ return this.offstack.isEmpty();+ }+public int size() {return super.size() + this.offstack.size();}@@ -68,7 +73,7 @@ public class SortStore<E> extends SortStack<E> {super.push(element, weight);this.largest = Math.max(this.largest, weight.longValue());if (this.maxsize <= 0) return;- while ((super.size() > 0) && (this.size() > this.maxsize)) {+ while (!super.isEmpty() && this.size() > this.maxsize) {this.pop();}}@@ -120,7 +125,7 @@ public class SortStore<E> extends SortStack<E> {public ArrayList<stackElement> list(final int count) {if (count < 0) {// shift all elements- while (super.size() > 0) this.pop();+ while (!super.isEmpty()) this.pop();return this.offstack;}if (count > super.size() + this.offstack.size()) throw new RuntimeException("list(" + count + ") exceeded avaiable number of elements (" + size() + ")");diff --git a/source/net/yacy/kelondro/workflow/WorkflowProcessor.java b/source/net/yacy/kelondro/workflow/WorkflowProcessor.javaindex 67d66e2ee..87bb9a275 100644--- a/source/net/yacy/kelondro/workflow/WorkflowProcessor.java+++ b/source/net/yacy/kelondro/workflow/WorkflowProcessor.java@@ -85,6 +85,10 @@ public class WorkflowProcessor<J extends WorkflowJob> {return this.input.size();}+ public boolean queueIsEmpty() {+ return this.input.isEmpty();+ }+public int queueSizeMax() {return this.input.size() + this.input.remainingCapacity();}@@ -116,11 +120,11 @@ public class WorkflowProcessor<J extends WorkflowJob> {}public synchronized void relaxCapacity() {- if (this.input.size() == 0) return;+ if (this.input.isEmpty()) return;if (this.input.remainingCapacity() > 1000) return;BlockingQueue<J> i = new LinkedBlockingQueue<J>();J e;- while (this.input.size() > 0) {+ while (!this.input.isEmpty()) {e = this.input.poll();if (e == null) break;i.add(e);diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.javaindex 28a7f65cd..c2d4ef03f 100644--- a/source/net/yacy/repository/Blacklist.java+++ b/source/net/yacy/repository/Blacklist.java@@ -219,14 +219,14 @@ public class Blacklist {ArrayList<String> hostList = blacklistMap.get(host);if(hostList != null) {hostList.remove(path);- if (hostList.size() == 0)+ if (hostList.isEmpty())blacklistMap.remove(host);}final HashMap<String, ArrayList<String>> blacklistMapNotMatch = getBlacklistMap(blacklistType,false);hostList = blacklistMapNotMatch.get(host);if (hostList != null) {hostList.remove(path);- if (hostList.size() == 0)+ if (hostList.isEmpty())blacklistMapNotMatch.remove(host);}}@@ -462,7 +462,7 @@ public class Blacklist {public static final String defaultBlacklist(final File listsPath) {List<String> dirlist = FileUtils.getDirListing(listsPath, Blacklist.BLACKLIST_FILENAME_FILTER);- if (dirlist.size() == 0) return null;+ if (dirlist.isEmpty()) return null;return dirlist.get(0);}diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.javaindex a68268d54..c4bfacf2e 100644--- a/source/net/yacy/yacy.java+++ b/source/net/yacy/yacy.java@@ -787,7 +787,7 @@ public final class yacy {if (wordset.size() != count) {count = count - wordset.size();final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(wordlist)));- while (wordset.size() > 0) {+ while (!wordset.isEmpty()) {word = wordset.first();bw.write(word + "\n");wordset.remove(word);