Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

- replaced all length() == 0 and size() == 0 with isEmpty() - replaced some length() > 0 and size() > 0 with !isEmpty() - cannot be done automatically - implemented some isEmpty() methods

orbiter0cbda0b2b8f6
diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.java
index 6f69c1af6..f00b33135 100644
--- a/htroot/BlacklistCleaner_p.java
+++ b/htroot/BlacklistCleaner_p.java
@@ -86,7 +86,7 @@ public class BlacklistCleaner_p {
if (post.containsKey("listNames")) {
blacklistToUse = post.get("listNames");
- if (blacklistToUse.length() == 0 || !ListManager.listSetContains("listManager.listsPath", blacklistToUse)) {
+ if (blacklistToUse.isEmpty() || !ListManager.listSetContains("listManager.listsPath", blacklistToUse)) {
prop.put("results", "2");
}
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index 8d2d130ad..77b7db5f9 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -119,7 +119,7 @@ public class Blacklist_p {
}
if (post.containsKey("selectList")) {
blacklistToUse = post.get("selectedListName");
- if (blacklistToUse != null && blacklistToUse.length() == 0) {
+ if (blacklistToUse != null && blacklistToUse.isEmpty()) {
blacklistToUse = null;
}
}
@@ -129,7 +129,7 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = post.get("newListName", "").trim();
- if (blacklistToUse.length() == 0) {
+ if (blacklistToUse.isEmpty()) {
prop.put("LOCATION","");
return prop;
}
@@ -176,7 +176,7 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = post.get("selectedListName");
- if (blacklistToUse == null || blacklistToUse.length() == 0) {
+ if (blacklistToUse == null || blacklistToUse.isEmpty()) {
prop.put("LOCATION","");
return prop;
}
@@ -204,7 +204,7 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = post.get("selectedListName", "").trim();
- if (blacklistToUse == null || blacklistToUse.length() == 0) {
+ if (blacklistToUse == null || blacklistToUse.isEmpty()) {
prop.put("LOCATION", "");
return prop;
}
@@ -227,7 +227,7 @@ public class Blacklist_p {
* =========================================================== */
blacklistToUse = post.get("selectedListName", "").trim();
- if (blacklistToUse == null || blacklistToUse.length() == 0) {
+ if (blacklistToUse == null || blacklistToUse.isEmpty()) {
prop.put("LOCATION", "");
return prop;
}
@@ -411,7 +411,7 @@ public class Blacklist_p {
for (int j = offset; j < to; ++j){
final String nextEntry = sortedlist[j];
- if (nextEntry.length() == 0) continue;
+ if (nextEntry.isEmpty()) continue;
if (nextEntry.charAt(0) == '#') continue;
prop.put(DISABLED + EDIT + "Itemlist_" + entryCount + "_dark", dark ? "1" : "0");
dark = !dark;
@@ -535,11 +535,11 @@ public class Blacklist_p {
final RequestHeader header,
final BlacklistType[] supportedBlacklistTypes) {
- if (blacklistToUse == null || blacklistToUse.length() == 0) {
+ if (blacklistToUse == null || blacklistToUse.isEmpty()) {
return "";
}
- if (newEntry == null || newEntry.length() == 0) {
+ if (newEntry == null || newEntry.isEmpty()) {
return header.get(HeaderFramework.CONNECTION_PROP_PATH) + "?selectList=&selectedListName=" + blacklistToUse;
}
@@ -563,11 +563,11 @@ public class Blacklist_p {
final RequestHeader header,
final BlacklistType[] supportedBlacklistTypes) {
- if (blacklistToUse == null || blacklistToUse.length() == 0) {
+ if (blacklistToUse == null || blacklistToUse.isEmpty()) {
return "";
}
- if (oldEntry == null || oldEntry.length() == 0) {
+ if (oldEntry == null || oldEntry.isEmpty()) {
return header.get(HeaderFramework.CONNECTION_PROP_PATH) + "?selectList=&selectedListName=" + blacklistToUse;
}
diff --git a/htroot/Blog.java b/htroot/Blog.java
index bb8777dee..1951c80ec 100644
--- a/htroot/Blog.java
+++ b/htroot/Blog.java
@@ -108,7 +108,7 @@ public class Blog {
if ("anonymous".equals(strAuthor)) {
strAuthor = sb.blogDB.guessAuthor(ip);
- if (strAuthor == null || strAuthor.length() == 0) {
+ if (strAuthor == null || strAuthor.isEmpty()) {
if (sb.peers.mySeed() == null) {
strAuthor = "anonymous";
} else {
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index 2a54b49af..778c11aff 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -91,7 +91,7 @@ public class BlogComments {
if ("anonymous".equals(strAuthor)) {
strAuthor = sb.blogDB.guessAuthor(ip);
- if (strAuthor == null || strAuthor.length() == 0) {
+ if (strAuthor == null || strAuthor.isEmpty()) {
if (sb.peers.mySeed() == null) {
strAuthor = "anonymous";
} else {
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index 50b86248b..e4b84a1cf 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -181,7 +181,7 @@ public class Bookmarks {
prop.put("mode", "2");
prop.put("display", "1");
display = 1;
- if (urlHash.length() == 0) {
+ if (urlHash.isEmpty()) {
prop.put("mode_edit", "0"); // create mode
prop.putHTML("mode_title", post.get("title"));
prop.putHTML("mode_description", post.get("description"));
diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java
index c34c68c40..ea552e2a3 100644
--- a/htroot/ConfigAccounts_p.java
+++ b/htroot/ConfigAccounts_p.java
@@ -74,7 +74,7 @@ public class ConfigAccounts_p {
sb.setConfig("adminAccountForLocalhost", true);
// if an localhost access is configured, check if a local password is given
// if not, set a random password
- if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
+ if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty()) {
// make a 'random' password
env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "0000" + sb.genRandomPassword());
env.setConfig("adminAccount", "");
@@ -88,7 +88,7 @@ public class ConfigAccounts_p {
}
}
- if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").length() == 0 && !env.getConfigBool("adminAccountForLocalhost", false)) {
+ if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty() && !env.getConfigBool("adminAccountForLocalhost", false)) {
prop.put("passwordNotSetWarning", 1);
}
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index 91822f525..9046a33fc 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -279,7 +279,7 @@ public class ConfigNetwork_p
output.append(",").append(element);
}
}
- if ( input.length() == 0 ) {
+ if ( input.isEmpty() ) {
return input;
}
return output.delete(0, 1).toString();
diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.java
index de66ff41e..ee0582325 100644
--- a/htroot/CrawlResults.java
+++ b/htroot/CrawlResults.java
@@ -232,7 +232,7 @@ public class CrawlResults {
prop.put("table_indexed_" + cnt + "_showTitle", (showTitle) ? "1" : "0");
prop.put("table_indexed_" + cnt + "_showTitle_available", "1");
- if (urle.dc_title() == null || urle.dc_title().trim().length() == 0)
+ if (urle.dc_title() == null || urle.dc_title().trim().isEmpty())
prop.put("table_indexed_" + cnt + "_showTitle_available_nodescr", "0");
else {
prop.put("table_indexed_" + cnt + "_showTitle_available_nodescr", "1");
diff --git a/htroot/CrawlStartScanner_p.java b/htroot/CrawlStartScanner_p.java
index 504ed43d5..8ab084a18 100644
--- a/htroot/CrawlStartScanner_p.java
+++ b/htroot/CrawlStartScanner_p.java
@@ -69,7 +69,7 @@ public class CrawlStartScanner_p
final Set<InetAddress> ips = Domains.myIntranetIPs();
prop.put("intranethosts", ips.toString());
prop.put("intranetHint", sb.isIntranetMode() ? 0 : 1);
- if ( hosts.length() == 0 ) {
+ if ( hosts.isEmpty() ) {
InetAddress ip;
if ( sb.isIntranetMode() ) {
if ( ips.size() > 0 ) {
diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java
index fb5e91070..f0f6b9d7b 100644
--- a/htroot/Crawler_p.java
+++ b/htroot/Crawler_p.java
@@ -147,7 +147,7 @@ public class Crawler_p {
// remove crawlingFileContent before we record the call
String crawlingFileName = post.get("crawlingFile");
final File crawlingFile;
- if (crawlingFileName == null || crawlingFileName.length() == 0) {
+ if (crawlingFileName == null || crawlingFileName.isEmpty()) {
crawlingFile = null;
} else {
if (crawlingFileName.startsWith("file://")) crawlingFileName = crawlingFileName.substring(7);
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index e71f8714e..40b9246b8 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -143,7 +143,7 @@ public class IndexControlRWIs_p {
}
if ( post.containsKey("keyhashsearch") ) {
- if ( keystring.length() == 0 || !ByteBuffer.equals(Word.word2hash(keystring), keyhash) ) {
+ if ( keystring.isEmpty() || !ByteBuffer.equals(Word.word2hash(keystring), keyhash) ) {
prop.put("keystring", "&lt;" + errmsg + "&gt;");
}
final RWIProcess ranking = genSearchresult(prop, sb, segment, keyhash, null);
@@ -270,7 +270,7 @@ public class IndexControlRWIs_p {
}
if ( post.containsKey("urllist") ) {
- if ( keystring.length() == 0 || !ByteBuffer.equals(Word.word2hash(keystring), keyhash) ) {
+ if ( keystring.isEmpty() || !ByteBuffer.equals(Word.word2hash(keystring), keyhash) ) {
prop.put("keystring", "&lt;" + errmsg + "&gt;");
}
final Bitfield flags = compileFlags(post);
@@ -282,7 +282,7 @@ public class IndexControlRWIs_p {
// transfer to other peer
if ( post.containsKey("keyhashtransfer") ) {
try {
- if ( keystring.length() == 0 || !ByteBuffer.equals(Word.word2hash(keystring), keyhash) ) {
+ if ( keystring.isEmpty() || !ByteBuffer.equals(Word.word2hash(keystring), keyhash) ) {
prop.put("keystring", "&lt;" + errmsg + "&gt;");
}
@@ -645,7 +645,7 @@ public class IndexControlRWIs_p {
return null;
}
if ( post.get("flags") != null ) {
- if ( post.get("flags", "").length() == 0 ) {
+ if ( post.get("flags", "").isEmpty() ) {
return null;
}
return new Bitfield(4, post.get("flags"));
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index e2f2b73a0..4527ca016 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -107,7 +107,7 @@ public class IndexControlURLs_p {
// post values that are set on numerous input fields with same name
String urlstring = post.get("urlstring", "").trim();
String urlhash = post.get("urlhash", "").trim();
- if (urlhash.length() == 0 && urlstring.length() > 0) {
+ if (urlhash.isEmpty() && urlstring.length() > 0) {
try {
urlhash = ASCII.String(new DigestURI(urlstring).hash());
} catch (final MalformedURLException e) {
diff --git a/htroot/Load_RSS_p.java b/htroot/Load_RSS_p.java
index a48111e66..4f2a6b58a 100644
--- a/htroot/Load_RSS_p.java
+++ b/htroot/Load_RSS_p.java
@@ -81,7 +81,7 @@ public class Load_RSS_p {
row = plainIterator.next();
if (row == null) continue;
messageurl = row.get("url", "");
- if (messageurl.length() == 0) continue;
+ if (messageurl.isEmpty()) continue;
final byte[] api_pk = row.get("api_pk");
final Row r = api_pk == null ? null : sb.tables.select("api", api_pk);
if (r == null || !r.get("comment", "").matches(".*" + Pattern.quote(messageurl) + ".*")) {
@@ -123,7 +123,7 @@ public class Load_RSS_p {
row = plainIterator.next();
if (row == null) continue;
messageurl = row.get("url", "");
- if (messageurl.length() == 0) continue;
+ if (messageurl.isEmpty()) continue;
final byte[] api_pk = row.get("api_pk");
final Row r = api_pk == null ? null : sb.tables.select("api", api_pk);
if (r != null && r.get("comment", "").matches(".*" + Pattern.quote(messageurl) + ".*")) {
@@ -189,7 +189,7 @@ public class Load_RSS_p {
row = plainIterator.next();
if (row == null) continue;
messageurl = row.get("url", "");
- if (messageurl.length() == 0) continue;
+ if (messageurl.isEmpty()) continue;
// get referrer
final DigestURI referrer = sb.getURL(row.get("referrer", "").getBytes());
// check if feed is registered in scheduler
@@ -300,7 +300,7 @@ public class Load_RSS_p {
final RSSMessage channel = feed.getChannel();
prop.putHTML("showitems_title", channel == null ? "" : channel.getTitle());
String author = channel == null ? "" : channel.getAuthor();
- if (author == null || author.length() == 0) author = channel == null ? "" : channel.getCopyright();
+ if (author == null || author.isEmpty()) author = channel == null ? "" : channel.getCopyright();
Date pubDate = channel == null ? null : channel.getPubDate();
prop.putHTML("showitems_author", author == null ? "" : author);
prop.putHTML("showitems_description", channel == null ? "" : channel.getDescription());
diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.java
index c95be81cf..26862b260 100644
--- a/htroot/MessageSend_p.java
+++ b/htroot/MessageSend_p.java
@@ -59,7 +59,7 @@ public class MessageSend_p {
String subject = post.get("subject", "");
String message = post.get("message", "");
- if ((message.length() == 0) || (post.containsKey("preview"))) {
+ if ((message.isEmpty()) || (post.containsKey("preview"))) {
if (post.containsKey("preview")) {
prop.put("mode", "1");
} else {
diff --git a/htroot/Network.java b/htroot/Network.java
index e3645cbad..87fe56bcb 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -429,7 +429,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", "");
} else {
final String peertags = MapTools.set2string(seed.getPeerTags(), ",", false);
- prop.putHTML(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", ((peertags == null) || (peertags.length() == 0)) ? "no tags given" : ("tags = " + peertags));
+ prop.putHTML(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", ((peertags == null) || (peertags.isEmpty())) ? "no tags given" : ("tags = " + peertags));
}
String[] yv = yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname);
prop.putHTML(STR_TABLE_LIST + conCount + "_version", yv[0] + "/" + yv[1]);
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 65d897eaa..9c874c91e 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -83,7 +83,7 @@ public class SettingsAck_p {
prop.put("info", "1");//error with submitted information
return prop;
}
- if (user.length() == 0) {
+ if (user.isEmpty()) {
prop.put("info", "2");//username must be given
return prop;
}
@@ -137,7 +137,7 @@ public class SettingsAck_p {
return prop;
}
- if (filter.length() == 0) filter = "*";
+ if (filter.isEmpty()) filter = "*";
else if (!filter.equals("*")){
// testing proxy filter
int patternCount = 0;
@@ -212,7 +212,7 @@ public class SettingsAck_p {
if (staticIP.indexOf(':',0) > 0) {
staticIP = staticIP.substring(0, staticIP.indexOf(':',0));
}
- if (staticIP.length() == 0) {
+ if (staticIP.isEmpty()) {
serverCore.useStaticIP = false;
} else {
serverCore.useStaticIP = true;
@@ -231,7 +231,7 @@ public class SettingsAck_p {
prop.put("info", "1");//error with submitted information
return prop;
}
- /* if (user.length() == 0) {
+ /* if (user.isEmpty()) {
prop.put("info", 2);//username must be given
return prop;
}
@@ -239,7 +239,7 @@ public class SettingsAck_p {
prop.put("info", 3);//pw check failed
return prop;
}*/
- if (filter.length() == 0) filter = "*";
+ if (filter.isEmpty()) filter = "*";
else if (!filter.equals("*")){
// testing proxy filter
int patternCount = 0;
diff --git a/htroot/Status.java b/htroot/Status.java
index f672939be..7c6ed1e43 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -129,7 +129,7 @@ public class Status
}
// password protection
- if ( (sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").length() == 0)
+ if ( (sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty())
&& (!sb.getConfigBool("adminAccountForLocalhost", false)) ) {
prop.put("protection", "0"); // not protected
prop.put("urgentSetPassword", "1");
@@ -194,7 +194,7 @@ public class Status
prop.put("host", hostIP != null ? hostIP.getHostAddress() : "Unkown IP");
// ssl support
- prop.put("sslSupport", sb.getConfig("keyStore", "").length() == 0 ? "0" : "1");
+ prop.put("sslSupport", sb.getConfig("keyStore", "").isEmpty() ? "0" : "1");
if ( sb.getConfigBool("remoteProxyUse", false) ) {
prop.put("remoteProxy", "1");
diff --git a/htroot/Surftips.java b/htroot/Surftips.java
index 5dbfb1725..297aaaec3 100644
--- a/htroot/Surftips.java
+++ b/htroot/Surftips.java
@@ -229,7 +229,7 @@ public class Surftips {
if (url.length() < 12) continue;
entry = rowdef.newEntry(new byte[][]{
url.getBytes(),
- (((intention.length() == 0) || intention.equals("simple web crawl") || intention.equals("Automatic ReCrawl!")) ? record.attribute("startURL", "") : intention).getBytes(),
+ (((intention.isEmpty()) || intention.equals("simple web crawl") || intention.equals("Automatic ReCrawl!")) ? record.attribute("startURL", "") : intention).getBytes(),
intention.equals("Automatic ReCrawl!") ? UTF8.getBytes("Automatic ReCrawl") : UTF8.getBytes("Crawl Start Point"),
record.id().getBytes()
});
diff --git a/htroot/Table_API_p.java b/htroot/Table_API_p.java
index 0ed0e1649..062408a84 100644
--- a/htroot/Table_API_p.java
+++ b/htroot/Table_API_p.java
@@ -254,7 +254,7 @@ public class Table_API_p {
prop.put("showtable_list_" + count + "_dateNextExec", date_next_exec == null ? "-" : DateFormat.getDateTimeInstance().format(date_next_exec));
prop.put("showtable_list_" + count + "_selectedMinutes", unit.equals("minutes") ? 1 : 0);
prop.put("showtable_list_" + count + "_selectedHours", unit.equals("hours") ? 1 : 0);
- prop.put("showtable_list_" + count + "_selectedDays", (unit.length() == 0 || unit.equals("days")) ? 1 : 0);
+ prop.put("showtable_list_" + count + "_selectedDays", (unit.isEmpty() || unit.equals("days")) ? 1 : 0);
prop.put("showtable_list_" + count + "_repeatTime", time);
prop.put("showtable_list_" + count + "_type", row.get(WorkTables.TABLE_API_COL_TYPE));
prop.put("showtable_list_" + count + "_comment", row.get(WorkTables.TABLE_API_COL_COMMENT));
diff --git a/htroot/Tables_p.java b/htroot/Tables_p.java
index cf7d69130..1f323ac7a 100644
--- a/htroot/Tables_p.java
+++ b/htroot/Tables_p.java
@@ -66,7 +66,7 @@ public class Tables_p {
final String counts = post.get("count", null);
int maxcount = (counts == null || counts.equals("all")) ? Integer.MAX_VALUE : post.getInt("count", 10);
final String pattern = post.get("search", "");
- final Pattern matcher = (pattern.length() == 0 || pattern.equals(".*")) ? null : Pattern.compile(".*" + pattern + ".*");
+ final Pattern matcher = (pattern.isEmpty() || pattern.equals(".*")) ? null : Pattern.compile(".*" + pattern + ".*");
prop.put("pattern", pattern);
// apply deletion requests
diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java
index de83d2568..1e6ce3271 100644
--- a/htroot/ViewFile.java
+++ b/htroot/ViewFile.java
@@ -348,7 +348,7 @@ public class ViewFile {
private static final String[] wordArray(String words) {
String[] w = new String[0];
- if (words == null || words.length() == 0) return w;
+ if (words == null || words.isEmpty()) return w;
if (words.length() > 1 && words.charAt(0) == '[' && words.charAt(words.length() - 1) == ']') {
words = words.substring(1, words.length() - 1);
}
diff --git a/htroot/Vocabulary_p.java b/htroot/Vocabulary_p.java
index 9ba54ca51..531169bc8 100644
--- a/htroot/Vocabulary_p.java
+++ b/htroot/Vocabulary_p.java
@@ -95,18 +95,18 @@ public class Vocabulary_p {
if (m != null) t = m.dc_creator();
}
t = t.replaceAll("_", " ").replaceAll("\"", " ").replaceAll("'", " ").replaceAll(",", " ").replaceAll(" ", " ").trim();
- if (t.length() == 0) continue;
+ if (t.isEmpty()) continue;
if (discoverFromTitleSplitted) {
String[] ts = t.split(" ");
for (String s: ts) {
- if (s.length() == 0) continue;
+ if (s.isEmpty()) continue;
if (s.endsWith(".jpg") || s.endsWith(".gif")) continue;
table.put(s, new Tagging.SOTuple(Tagging.normalizeTerm(s), u0));
}
} else if (discoverFromAuthor) {
String[] ts = t.split(";"); // author names are often separated by ';'
for (String s: ts) {
- if (s.length() == 0) continue;
+ if (s.isEmpty()) continue;
int p = s.indexOf(','); // check if there is a reversed method to mention the name
if (p >= 0) s = s.substring(p + 1).trim() + " " + s.substring(0, p).trim();
table.put(s, new Tagging.SOTuple(Tagging.normalizeTerm(s), u0));
diff --git a/htroot/WatchWebStructure_p.java b/htroot/WatchWebStructure_p.java
index aa1e56877..9270906d7 100644
--- a/htroot/WatchWebStructure_p.java
+++ b/htroot/WatchWebStructure_p.java
@@ -73,7 +73,7 @@ public class WatchWebStructure_p {
// find start point
if (host == null ||
- host.length() == 0 ||
+ host.isEmpty() ||
host.equals("auto")
// || sb.webStructure.referencesCount(DigestURI.hosthash6(host)) == 0
) {
diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.java
index d5614913a..f6f9127b2 100644
--- a/htroot/WebStructurePicture_p.java
+++ b/htroot/WebStructurePicture_p.java
@@ -93,7 +93,7 @@ public class WebStructurePicture_p {
final long timeout = (time < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + (time * 8 / 10);
// find start point
- if ((host == null) || (host.length() == 0) || (host.equals("auto"))) {
+ if ((host == null) || (host.isEmpty()) || (host.equals("auto"))) {
// find domain with most references
host = sb.webStructure.hostWithMaxReferences();
}
diff --git a/htroot/api/blacklists.java b/htroot/api/blacklists.java
index 66a27464b..88761edfc 100644
--- a/htroot/api/blacklists.java
+++ b/htroot/api/blacklists.java
@@ -31,7 +31,7 @@ public class blacklists {
int count=0;
for (final String entry : list){
- if (entry.length() == 0) {
+ if (entry.isEmpty()) {
continue;
}
if (entry.charAt(0) == '#') {
diff --git a/htroot/api/blacklists_p.java b/htroot/api/blacklists_p.java
index 0fad22409..12577ed21 100644
--- a/htroot/api/blacklists_p.java
+++ b/htroot/api/blacklists_p.java
@@ -48,7 +48,7 @@ public class blacklists_p {
count=0;
for (final String entry : list){
- if (entry.length() == 0) continue;
+ if (entry.isEmpty()) continue;
if (entry.charAt(0) == '#') continue;
prop.putXML("lists_" + blacklistCount + "_items_" + count + "_item", entry);
diff --git a/htroot/api/table_p.java b/htroot/api/table_p.java
index 0fa36909a..c55b97934 100644
--- a/htroot/api/table_p.java
+++ b/htroot/api/table_p.java
@@ -83,7 +83,7 @@ public class table_p {
final String counts = post.get("count", null);
int maxcount = (counts == null || counts.equals("all")) ? Integer.MAX_VALUE : post.getInt("count", 10);
final String pattern = post.get("search", "");
- final Pattern matcher = (pattern.length() == 0 || pattern.equals(".*")) ? null : Pattern.compile(".*" + pattern + ".*");
+ final Pattern matcher = (pattern.isEmpty() || pattern.equals(".*")) ? null : Pattern.compile(".*" + pattern + ".*");
if (post.containsKey("deleterows")) {
@@ -105,7 +105,7 @@ public class table_p {
}
}
try {
- if (pk == null || pk.length() == 0) {
+ if (pk == null || pk.isEmpty()) {
sb.tables.insert(table, map);
} else {
sb.tables.update(table, pk.getBytes(), map);
diff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.java
index 3aa549fe9..2cd5aace2 100644
--- a/htroot/api/yacydoc.java
+++ b/htroot/api/yacydoc.java
@@ -85,9 +85,9 @@ public class yacydoc {
final String urlstring = post.get("url", "").trim();
String urlhash = post.get("urlhash", "").trim();
- if (urlstring.length() == 0 && urlhash.length() == 0) return prop;
+ if (urlstring.isEmpty() && urlhash.isEmpty()) return prop;
- if (urlstring.length() > 0 && urlhash.length() == 0) {
+ if (urlstring.length() > 0 && urlhash.isEmpty()) {
try {
final DigestURI url = new DigestURI(urlstring);
urlhash = ASCII.String(url.hash());
@@ -95,7 +95,7 @@ public class yacydoc {
Log.logException(e);
}
}
- if (urlhash == null || urlhash.length() == 0) return prop;
+ if (urlhash == null || urlhash.isEmpty()) return prop;
final URIMetadataRow entry = segment.urlMetadata().load(urlhash.getBytes());
if (entry == null) return prop;
diff --git a/htroot/compare_yacy.java b/htroot/compare_yacy.java
index 6270961dd..0553cf682 100644
--- a/htroot/compare_yacy.java
+++ b/htroot/compare_yacy.java
@@ -99,7 +99,7 @@ public class compare_yacy {
prop.putHTML("search_left", searchengines.get(default_left));
prop.putHTML("search_right", searchengines.get(default_right));
- if (post == null || post.get("query", "").length() == 0) {
+ if (post == null || post.get("query", "").isEmpty()) {
prop.put("search", 0);
prop.put("search_query", "");
return prop;
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 90a4a4e9d..8df9ddb82 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -107,7 +107,7 @@ public final class message {
if (process.equals("post")) {
// post: post message to message board
final String otherSeedString = post.get("myseed", "");
- if (otherSeedString.length() == 0) {
+ if (otherSeedString.isEmpty()) {
prop.put("response", "-1"); // request rejected
return prop;
}
@@ -128,7 +128,7 @@ public final class message {
}
message = message.trim();
subject = subject.trim();
- if (subject.length() == 0 || message.length() == 0) {
+ if (subject.isEmpty() || message.isEmpty()) {
prop.put("response", "-1"); // don't accept empty messages
return prop;
}
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 081283208..e8d72632c 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -116,10 +116,10 @@ public final class search {
final String modifier = post.get("modifier", "").trim();
final String contentdom = post.get("contentdom", "all");
final String filter = post.get("filter", ".*"); // a filter on the url
- String sitehash = post.get("sitehash", ""); if (sitehash.length() == 0) sitehash = null;
- String authorhash = post.get("authorhash", ""); if (authorhash.length() == 0) authorhash = null;
+ String sitehash = post.get("sitehash", ""); if (sitehash.isEmpty()) sitehash = null;
+ String authorhash = post.get("authorhash", ""); if (authorhash.isEmpty()) authorhash = null;
String language = post.get("language", "");
- if (language == null || language.length() == 0 || !ISO639.exists(language)) {
+ if (language == null || language.isEmpty() || !ISO639.exists(language)) {
// take language from the user agent
String agent = header.get("User-Agent");
if (agent == null) agent = System.getProperty("user.language");
@@ -184,7 +184,7 @@ public final class search {
sb.intermissionAllThreads(100);
EventTracker.delete(EventTracker.EClass.SEARCH);
- final HandleSet abstractSet = (abstracts.length() == 0 || abstracts.equals("auto")) ? null : QueryParams.hashes2Set(abstracts);
+ final HandleSet abstractSet = (abstracts.isEmpty() || abstracts.equals("auto")) ? null : QueryParams.hashes2Set(abstracts);
// store accessing peer
Seed remoteSeed;
@@ -202,11 +202,11 @@ public final class search {
// prepare search
final HandleSet queryhashes = QueryParams.hashes2Set(query);
- final HandleSet excludehashes = (exclude.length() == 0) ? new HandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0) : QueryParams.hashes2Set(exclude);
+ final HandleSet excludehashes = (exclude.isEmpty()) ? new HandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0) : QueryParams.hashes2Set(exclude);
final long timestamp = System.currentTimeMillis();
// prepare a search profile
- final RankingProfile rankingProfile = (profile.length() == 0) ? new RankingProfile(Classification.ContentDomain.contentdomParser(contentdom)) : new RankingProfile("", profile);
+ final RankingProfile rankingProfile = (profile.isEmpty()) ? new RankingProfile(Classification.ContentDomain.contentdomParser(contentdom)) : new RankingProfile("", profile);
// prepare an abstract result
final StringBuilder indexabstract = new StringBuilder(6000);
@@ -215,7 +215,7 @@ public final class search {
QueryParams theQuery = null;
SearchEvent theSearch = null;
ArrayList<WeakPriorityBlockingQueue.Element<ResultEntry>> accu = null;
- if (query.length() == 0 && abstractSet != null) {
+ if (query.isEmpty() && abstractSet != null) {
// this is _not_ a normal search, only a request for index abstracts
final Segment indexSegment = sb.index;
theQuery = new QueryParams(
@@ -324,7 +324,7 @@ public final class search {
if (joincount != 0) {
accu = theSearch.result().completeResults(maxtime);
}
- if (joincount <= 0 || abstracts.length() == 0) {
+ if (joincount <= 0 || abstracts.isEmpty()) {
prop.put("indexcount", "");
} else {
// attach information about index abstracts
@@ -350,7 +350,7 @@ public final class search {
// generate compressed index for maxcounthash
// this is not needed if the search is restricted to specific
// urls, because it is a re-search
- if ((theSearch.getAbstractsMaxCountHash() == null) || (urls.length() != 0) || (queryhashes.size() <= 1) || (abstracts.length() == 0)) {
+ if ((theSearch.getAbstractsMaxCountHash() == null) || (urls.length() != 0) || (queryhashes.size() <= 1) || (abstracts.isEmpty())) {
prop.put("indexabstract", "");
} else if (abstracts.equals("auto")) {
// automatically attach the index abstract for the index that has the most references. This should be our target dht position
diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.java
index 35cacd8a9..ab1064957 100644
--- a/htroot/yacysearchtrailer.java
+++ b/htroot/yacysearchtrailer.java
@@ -338,7 +338,7 @@ public class yacysearchtrailer {
// about box
final String aboutBody = env.getConfig("about.body", "");
final String aboutHeadline = env.getConfig("about.headline", "");
- if ((aboutBody.length() == 0 && aboutHeadline.length() == 0) ||
+ if ((aboutBody.isEmpty() && aboutHeadline.isEmpty()) ||
theSearch.getRankingResult().getLocalIndexCount() - theSearch.getRankingResult().getMissCount() - theSearch.getRankingResult().getSortOutCount() + theSearch.getRankingResult().getRemoteIndexCount() == 0) {
prop.put("nav-about", 0);
} else {
@@ -349,7 +349,7 @@ public class yacysearchtrailer {
// category: location search
// show only if there is a location database present and if there had been any search results
- if (LibraryProvider.geoLoc.size() == 0 ||
+ if (LibraryProvider.geoLoc.isEmpty() ||
theSearch.getRankingResult().getLocalIndexCount() == 0) {
prop.put("cat-location", 0);
} else {
diff --git a/libbuild/GitRevTask/GitRevTask.java b/libbuild/GitRevTask/GitRevTask.java
index c12d9b80b..bf6246d10 100644
--- a/libbuild/GitRevTask/GitRevTask.java
+++ b/libbuild/GitRevTask/GitRevTask.java
@@ -34,11 +34,11 @@ public class GitRevTask extends org.apache.tools.ant.Task {
}
public void execute() {
- if (this.revprop==null || this.revprop.length() == 0) {
+ if (this.revprop==null || this.revprop.isEmpty()) {
log("git entries file name revprop was not set properly",Project.MSG_ERR);
return;
}
- if (this.dateprop==null || this.dateprop.length() == 0) {
+ if (this.dateprop==null || this.dateprop.isEmpty()) {
log("git entries file name dateprop was not set properly",Project.MSG_ERR);
return;
}
diff --git a/libbuild/svnRevNr/svnRevNrParser.java b/libbuild/svnRevNr/svnRevNrParser.java
index 40d6b6caf..f21389441 100644
--- a/libbuild/svnRevNr/svnRevNrParser.java
+++ b/libbuild/svnRevNr/svnRevNrParser.java
@@ -30,7 +30,7 @@ public class svnRevNrParser extends org.apache.tools.ant.Task{
}
public void execute() {
- if (this.property==null || this.property.length() == 0) {
+ if (this.property==null || this.property.isEmpty()) {
log("svn entries file name property was not set properly",Project.MSG_ERR);
return;
}
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.java
index cf877f610..c2996c478 100644
--- a/source/de/anomic/crawler/CrawlProfile.java
+++ b/source/de/anomic/crawler/CrawlProfile.java
@@ -349,7 +349,7 @@ public class CrawlProfile extends ConcurrentHashMap<String, String> implements M
public String[] countryMustMatchList() {
String countryMustMatch = get(FILTER_COUNTRY_MUSTMATCH);
if (countryMustMatch == null) countryMustMatch = "";
- if (countryMustMatch.length() == 0) return new String[0];
+ if (countryMustMatch.isEmpty()) return new String[0];
String[] list = countryMustMatch.split(",");
if (list.length == 1 && list.length == 0) list = new String[0];
return list;
diff --git a/source/de/anomic/crawler/CrawlSwitchboard.java b/source/de/anomic/crawler/CrawlSwitchboard.java
index dffbba033..f8ccce633 100644
--- a/source/de/anomic/crawler/CrawlSwitchboard.java
+++ b/source/de/anomic/crawler/CrawlSwitchboard.java
@@ -81,7 +81,7 @@ public final class CrawlSwitchboard
log.logInfo("Initializing Word Index for the network '" + networkName + "'.");
- if ( networkName == null || networkName.length() == 0 ) {
+ if ( networkName == null || networkName.isEmpty() ) {
log.logSevere("no network name given - shutting down");
System.exit(0);
}
diff --git a/source/de/anomic/crawler/RobotsTxtEntry.java b/source/de/anomic/crawler/RobotsTxtEntry.java
index 314110214..413761825 100644
--- a/source/de/anomic/crawler/RobotsTxtEntry.java
+++ b/source/de/anomic/crawler/RobotsTxtEntry.java
@@ -231,7 +231,7 @@ public class RobotsTxtEntry {
}
// if the path is null or empty we set it to /
- if (path == null || path.length() == 0) path = "/";
+ if (path == null || path.isEmpty()) path = "/";
// escaping all occurences of ; because this char is used as special char in the Robots DB
else path = RobotsTxt.ROBOTS_DB_PATH_SEPARATOR_MATCHER.matcher(path).replaceAll("%3B");
diff --git a/source/de/anomic/crawler/RobotsTxtParser.java b/source/de/anomic/crawler/RobotsTxtParser.java
index 7af6a140a..eb24a80bb 100644
--- a/source/de/anomic/crawler/RobotsTxtParser.java
+++ b/source/de/anomic/crawler/RobotsTxtParser.java
@@ -149,7 +149,7 @@ public final class RobotsTxtParser {
lineUpper = line.toUpperCase();
// parse empty line
- if (line.length() == 0) {
+ if (line.isEmpty()) {
// we have reached the end of the rule block
if (rule4ThisAgentsFound) {
// stop here because other robot blocks are either not for YaCy
@@ -167,7 +167,7 @@ public final class RobotsTxtParser {
// parse sitemap; if there are several sitemaps then take the first url
// TODO: support for multiple sitemaps
- if (lineUpper.startsWith(ROBOTS_SITEMAP) && (this.sitemap == null || this.sitemap.length() == 0)) {
+ if (lineUpper.startsWith(ROBOTS_SITEMAP) && (this.sitemap == null || this.sitemap.isEmpty())) {
pos = line.indexOf(' ');
if (pos != -1) {
this.sitemap = line.substring(pos).trim();
diff --git a/source/de/anomic/crawler/retrieval/FTPLoader.java b/source/de/anomic/crawler/retrieval/FTPLoader.java
index 4979a94e0..aab5f337f 100644
--- a/source/de/anomic/crawler/retrieval/FTPLoader.java
+++ b/source/de/anomic/crawler/retrieval/FTPLoader.java
@@ -110,7 +110,7 @@ public class FTPLoader {
}
}
- if (file.length() == 0) {
+ if (file.isEmpty()) {
// directory -> get list of files
final RequestHeader requestHeader = new RequestHeader();
if (request.referrerhash() != null) {
diff --git a/source/de/anomic/crawler/retrieval/HTTPLoader.java b/source/de/anomic/crawler/retrieval/HTTPLoader.java
index 05aee0a8e..9c1b48eaf 100644
--- a/source/de/anomic/crawler/retrieval/HTTPLoader.java
+++ b/source/de/anomic/crawler/retrieval/HTTPLoader.java
@@ -143,7 +143,7 @@ public final class HTTPLoader {
String redirectionUrlString = responseHeader.get(HeaderFramework.LOCATION);
redirectionUrlString = redirectionUrlString == null ? "" : redirectionUrlString.trim();
- if (redirectionUrlString.length() == 0) {
+ if (redirectionUrlString.isEmpty()) {
this.sb.crawlQueues.errorURL.push(request, myHash, new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "no redirection url provided, field '" + HeaderFramework.LOCATION + "' is empty", statusCode);
throw new IOException("REJECTED EMTPY REDIRECTION '" + client.getHttpResponse().getStatusLine() + "' for URL " + requestURLString);
}
@@ -283,7 +283,7 @@ public final class HTTPLoader {
String redirectionUrlString = header.get(HeaderFramework.LOCATION);
redirectionUrlString = redirectionUrlString.trim();
- if (redirectionUrlString.length() == 0) {
+ if (redirectionUrlString.isEmpty()) {
throw new IOException("CRAWLER Redirection of URL=" + request.url().toString() + " aborted. Location header is empty.");
}
diff --git a/source/de/anomic/crawler/retrieval/Response.java b/source/de/anomic/crawler/retrieval/Response.java
index dec791021..b71bf1eb1 100644
--- a/source/de/anomic/crawler/retrieval/Response.java
+++ b/source/de/anomic/crawler/retrieval/Response.java
@@ -782,7 +782,7 @@ public class Response {
public byte[] referrerHash() {
if (this.requestHeader == null) return null;
final String u = this.requestHeader.get(RequestHeader.REFERER, "");
- if (u == null || u.length() == 0) return null;
+ if (u == null || u.isEmpty()) return null;
try {
return new DigestURI(u).hash();
} catch (final Exception e) {
diff --git a/source/de/anomic/data/BlogBoard.java b/source/de/anomic/data/BlogBoard.java
index f75d03465..482c9babb 100644
--- a/source/de/anomic/data/BlogBoard.java
+++ b/source/de/anomic/data/BlogBoard.java
@@ -474,7 +474,7 @@ public class BlogBoard {
private void setIp(final String ip) {
String ret = ip;
- if ((ret == null) || (ret.length() == 0))
+ if ((ret == null) || (ret.isEmpty()))
ret = "";
this.record.put("ip", ret);
}
diff --git a/source/de/anomic/data/BlogBoardComments.java b/source/de/anomic/data/BlogBoardComments.java
index 02347e5cb..b26efac81 100644
--- a/source/de/anomic/data/BlogBoardComments.java
+++ b/source/de/anomic/data/BlogBoardComments.java
@@ -320,7 +320,7 @@ public class BlogBoardComments {
return author_byte;
}
private void setIp(String ip) {
- if ((ip == null) || (ip.length() == 0))
+ if ((ip == null) || (ip.isEmpty()))
ip = "";
this.record.put("ip", ip);
}
diff --git a/source/de/anomic/data/BookmarksDB.java b/source/de/anomic/data/BookmarksDB.java
index cdb63bb87..91c68936f 100644
--- a/source/de/anomic/data/BookmarksDB.java
+++ b/source/de/anomic/data/BookmarksDB.java
@@ -124,7 +124,7 @@ public class BookmarksDB {
// -----------------------------------------------------------
public Bookmark createBookmark(final String url, final String user){
- if (url == null || url.length() == 0) return null;
+ if (url == null || url.isEmpty()) return null;
Bookmark bk;
try {
bk = new Bookmark(url);
diff --git a/source/de/anomic/data/DidYouMean.java b/source/de/anomic/data/DidYouMean.java
index c57fa0a3d..d99149a92 100644
--- a/source/de/anomic/data/DidYouMean.java
+++ b/source/de/anomic/data/DidYouMean.java
@@ -179,7 +179,7 @@ public class DidYouMean {
}
// finished
- if (countSorted.size() == 0) {
+ if (countSorted.isEmpty()) {
Log.logInfo("DidYouMean", "found and returned " + preSorted.size() + " unsorted suggestions (2); execution time: "
+ (System.currentTimeMillis() - startTime) + "ms");
return preSorted;
diff --git a/source/de/anomic/data/MessageBoard.java b/source/de/anomic/data/MessageBoard.java
index bd72e09e3..8f20fce50 100644
--- a/source/de/anomic/data/MessageBoard.java
+++ b/source/de/anomic/data/MessageBoard.java
@@ -106,8 +106,8 @@ public class MessageBoard {
if (key.length() > categoryLength) key = key.substring(0, categoryLength);
while (key.length() < categoryLength) key += "_";
key += dateString() + snString();
- record.put("author", ((authorName == null) || (authorName.length() == 0)) ? authorName : "anonymous");
- record.put("recipient", ((recName == null) || (recName.length() == 0)) ? recName : "anonymous");
+ record.put("author", ((authorName == null) || (authorName.isEmpty())) ? authorName : "anonymous");
+ record.put("recipient", ((recName == null) || (recName.isEmpty())) ? recName : "anonymous");
record.put("ahash", (authorHash == null) ? authorHash : "");
record.put("rhash", (recHash == null) ? recHash : "");
record.put("subject", (subject == null) ? subject : "");
diff --git a/source/de/anomic/data/Translator.java b/source/de/anomic/data/Translator.java
index 5bb72349c..23135c23e 100644
--- a/source/de/anomic/data/Translator.java
+++ b/source/de/anomic/data/Translator.java
@@ -90,7 +90,7 @@ public class Translator {
String forFile = "";
for (final String line : list){
- if (line.length() == 0 || line.charAt(0) != '#'){
+ if (line.isEmpty() || line.charAt(0) != '#'){
final String[] split = line.split("==", 2);
if (split.length == 2) {
translationList.put(split[0], split[1]);
diff --git a/source/de/anomic/data/URLAnalysis.java b/source/de/anomic/data/URLAnalysis.java
index f9d09ce58..e90864e4d 100644
--- a/source/de/anomic/data/URLAnalysis.java
+++ b/source/de/anomic/data/URLAnalysis.java
@@ -115,7 +115,7 @@ public class URLAnalysis {
private void update(final String[] s) {
Integer c;
for (final String t: s) {
- if (t.length() == 0) continue;
+ if (t.isEmpty()) continue;
c = this.out.get(t);
this.out.put(t, (c == null) ? 1 : c.intValue() + 1);
}
diff --git a/source/de/anomic/data/WorkTables.java b/source/de/anomic/data/WorkTables.java
index 57c5b6ec9..4f65d0d1e 100644
--- a/source/de/anomic/data/WorkTables.java
+++ b/source/de/anomic/data/WorkTables.java
@@ -167,7 +167,7 @@ public class WorkTables extends Tables {
// this api call has already been stored somewhere.
return recordAPICall(post, servletName, type, comment);
}
- if (time < 0 || unit == null || unit.length() == 0 || "minutes,hours,days".indexOf(unit) < 0) {
+ if (time < 0 || unit == null || unit.isEmpty() || "minutes,hours,days".indexOf(unit) < 0) {
time = 0; unit = "";
} else {
if (unit.equals("minutes") && time < 10) time = 10;
diff --git a/source/de/anomic/http/server/ChunkedInputStream.java b/source/de/anomic/http/server/ChunkedInputStream.java
index 516a85e1f..d08964703 100644
--- a/source/de/anomic/http/server/ChunkedInputStream.java
+++ b/source/de/anomic/http/server/ChunkedInputStream.java
@@ -379,7 +379,7 @@ public class ChunkedInputStream extends InputStream {
throw new IllegalArgumentException("Parameter may not be null");
}
- if (charset == null || charset.length() == 0) {
+ if (charset == null || charset.isEmpty()) {
throw new IllegalArgumentException("charset may not be null or empty");
}
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index d0b2b718f..0292ba604 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -312,24 +312,24 @@ public final class HTTPDFileHandler {
// -2- a password is not configured; or
final String adminAccountBase64MD5 = switchboard.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");
if (!accessGranted) {
- accessGranted = adminAccountBase64MD5.length() == 0;
+ accessGranted = adminAccountBase64MD5.isEmpty();
}
// -3- access from localhost is granted and access comes from localhost; or
final String refererHost = requestHeader.refererHost();
if (!accessGranted) {
final boolean adminAccountForLocalhost = sb.getConfigBool("adminAccountForLocalhost", false);
- final boolean accessFromLocalhost = Domains.isLocalhost(clientIP) && (refererHost == null || refererHost.length() == 0 || Domains.isLocalhost(refererHost));
+ final boolean accessFromLocalhost = Domains.isLocalhost(clientIP) && (refererHost == null || refererHost.isEmpty() || Domains.isLocalhost(refererHost));
accessGranted = adminAccountForLocalhost && accessFromLocalhost;
}
// -4- a password is configured and access comes from localhost
// and the realm-value of a http-authentify String is equal to the stored base64MD5; or
String realmProp = requestHeader.get(RequestHeader.AUTHORIZATION);
- if (realmProp != null && realmProp.length() == 0) realmProp = null;
+ if (realmProp != null && realmProp.isEmpty()) realmProp = null;
final String realmValue = realmProp == null ? null : realmProp.substring(6);
if (!accessGranted) {
- final boolean accessFromLocalhost = Domains.isLocalhost(clientIP) && (refererHost == null || refererHost.length() == 0 || Domains.isLocalhost(refererHost));
+ final boolean accessFromLocalhost = Domains.isLocalhost(clientIP) && (refererHost == null || refererHost.isEmpty() || Domains.isLocalhost(refererHost));
accessGranted = accessFromLocalhost && realmValue != null && realmProp.length() > 6 && (adminAccountBase64MD5.equals(realmValue));
Log.logInfo("HTTPDFileHandler", "access from localhost blocked, clientIP=" + clientIP);
}
@@ -947,7 +947,7 @@ public final class HTTPDFileHandler {
return;
} else if (templatePatterns.containsKey(serverObjects.ACTION_LOCATION)) {
String location = templatePatterns.get(serverObjects.ACTION_LOCATION, "");
- if (location.length() == 0) location = path;
+ if (location.isEmpty()) location = path;
final ResponseHeader headers = getDefaultHeaders(path);
headers.setAdditionalHeaderProperties(templatePatterns.getOutgoingHeader().getAdditionalHeaderProperties()); //put the cookies into the new header TODO: can we put all headerlines, without trouble?
@@ -1279,7 +1279,7 @@ public final class HTTPDFileHandler {
}
private static final String appendPath(final String proplist, final String path) {
- if (proplist.length() == 0) return path;
+ if (proplist.isEmpty()) return path;
if (proplist.indexOf(path) >= 0) return proplist;
return proplist + "," + path;
}
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.java
index b41f64762..98c249911 100644
--- a/source/de/anomic/http/server/HTTPDemon.java
+++ b/source/de/anomic/http/server/HTTPDemon.java
@@ -697,7 +697,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// the String argsString is supposed to be constructed as
// <key1>=<value1>'&'<key2>=<value2>'&'<key3>=<value3>
// the calling function must strip off a possible leading '?' char
- if (argsString.length() == 0) return 0;
+ if (argsString.isEmpty()) return 0;
argsString = argsString + "&"; // for technical reasons
int sep;
int eqp;
@@ -1329,7 +1329,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
}
public static boolean shallTransportZipped(final String path) {
- if ((path == null) || (path.length() == 0)) return true;
+ if ((path == null) || (path.isEmpty())) return true;
int pos;
if ((pos = path.lastIndexOf('.')) != -1) {
@@ -1339,7 +1339,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
}
public static boolean isThisSeedIP(final String hostName) {
- if ((hostName == null) || (hostName.length() == 0)) return false;
+ if ((hostName == null) || (hostName.isEmpty())) return false;
// getting ip address and port of this seed
if (getAlternativeResolver() == null) return false;
@@ -1354,7 +1354,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
}
public static boolean isThisHostName(final String hostName) {
- if ((hostName == null) || (hostName.length() == 0)) return false;
+ if ((hostName == null) || (hostName.isEmpty())) return false;
try {
final int idx = hostName.indexOf(':');
@@ -1407,7 +1407,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
int p;
String line;
while ((line = theSession.readLineAsString()) != null) {
- if (line.length() == 0) break; // this separates the header of the HTTP request from the body
+ if (line.isEmpty()) break; // this separates the header of the HTTP request from the body
// parse the header line: a property separated with the ':' sign
if ((p = line.indexOf(':')) >= 0) {
// store a property
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index 00dda8aa6..9189b4c12 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -714,7 +714,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
try {
// if we can not determine the proper command string we try to call function emptyRequest
// of the commandObject
- if (this.request.trim().length() == 0) this.request = "EMPTY";
+ if (this.request.trim().isEmpty()) this.request = "EMPTY";
parameter = new Object[2];
@@ -1006,7 +1006,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
final PKCS12Tool pkcsTool = new PKCS12Tool(pkcs12ImportFile,pkcs12ImportPwd);
// creating a new keystore file
- if (keyStoreFileName.length() == 0) {
+ if (keyStoreFileName.isEmpty()) {
// using the default keystore name
keyStoreFileName = "DATA/SETTINGS/myPeerKeystore";
@@ -1034,7 +1034,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
} catch (final Exception e) {
this.log.logSevere("Unable to import certificate from import file '" + pkcs12ImportFile + "'.",e);
}
- } else if (keyStoreFileName.length() == 0) return null;
+ } else if (keyStoreFileName.isEmpty()) return null;
// get the ssl context
diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java
index ecef7083d..e0746b7a5 100644
--- a/source/de/anomic/server/serverObjects.java
+++ b/source/de/anomic/server/serverObjects.java
@@ -100,7 +100,7 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
}
private static final String removeByteOrderMark(final String s) {
- if (s == null || s.length() == 0) return s;
+ if (s == null || s.isEmpty()) return s;
if (s.charAt(0) == BOM) return s.substring(1);
return s;
}
diff --git a/source/de/anomic/tools/cryptbig.java b/source/de/anomic/tools/cryptbig.java
index 65e2190d7..107be12fa 100644
--- a/source/de/anomic/tools/cryptbig.java
+++ b/source/de/anomic/tools/cryptbig.java
@@ -444,7 +444,7 @@ public class cryptbig {
public static String oneWayEncryption(final String key) {
final cryptbig crypter = new cryptbig(key);
String e = crypter.encryptString(key);
- if (e.length() == 0) e = "0XXXX";
+ if (e.isEmpty()) e = "0XXXX";
if (e.length() % 2 != 0) e += "X";
while (e.length() < 32) e = e + e;
final char[] r = new char[16];
diff --git a/source/net/yacy/ai/example/Hanoi.java b/source/net/yacy/ai/example/Hanoi.java
index 7ca41348e..090690aab 100644
--- a/source/net/yacy/ai/example/Hanoi.java
+++ b/source/net/yacy/ai/example/Hanoi.java
@@ -179,9 +179,9 @@ public class Hanoi {
for (int from = 0; from < 3; from++) {
toloop: for (int to = 0; to < 3; to++) {
if (from == to) continue toloop;
- Coin fromCoin = (this.stacks[from].size() == 0) ? null : this.stacks[from].get(this.stacks[from].size() - 1);
+ Coin fromCoin = (this.stacks[from].isEmpty()) ? null : this.stacks[from].get(this.stacks[from].size() - 1);
if (fromCoin == null) continue toloop;
- Coin toCoin = (this.stacks[to].size() == 0) ? null : this.stacks[to].get(this.stacks[to].size() - 1);
+ Coin toCoin = (this.stacks[to].isEmpty()) ? null : this.stacks[to].get(this.stacks[to].size() - 1);
if (toCoin != null && fromCoin.size >= toCoin.size) continue toloop;
Move move = new Move(from, to);
move.setPriority(getPriority(move));
diff --git a/source/net/yacy/cora/date/GenericFormatter.java b/source/net/yacy/cora/date/GenericFormatter.java
index 7d599f3f1..606de99b8 100644
--- a/source/net/yacy/cora/date/GenericFormatter.java
+++ b/source/net/yacy/cora/date/GenericFormatter.java
@@ -132,8 +132,8 @@ public class GenericFormatter extends AbstractFormatter implements DateFormatter
// FIXME: This method returns an incorrect date, check callers!
// ex: de.anomic.server.serverDate.parseShortSecond("20070101120000", "+0200").toGMTString()
// => 1 Jan 2007 13:00:00 GMT
- if (timeString == null || timeString.length() == 0) { return new Date(); }
- if (UTCOffset == null || UTCOffset.length() == 0) { return new Date(); }
+ if (timeString == null || timeString.isEmpty()) { return new Date(); }
+ if (UTCOffset == null || UTCOffset.isEmpty()) { return new Date(); }
try {
return new Date(this.dateFormat.parse(timeString).getTime() - UTCDiff() + UTCDiff(UTCOffset));
} catch (final Throwable e) {
diff --git a/source/net/yacy/cora/date/ISO8601Formatter.java b/source/net/yacy/cora/date/ISO8601Formatter.java
index 1bdb44b2c..e68d05867 100644
--- a/source/net/yacy/cora/date/ISO8601Formatter.java
+++ b/source/net/yacy/cora/date/ISO8601Formatter.java
@@ -75,16 +75,16 @@ public class ISO8601Formatter extends AbstractFormatter implements DateFormatter
public Date parse(String s) throws ParseException {
// do some lazy checks here
s = s.trim();
- while (s.length() > 0 && s.endsWith("?")) s = s.substring(0, s.length() - 1); // sometimes used if write is not sure about date
+ while (!s.isEmpty() && s.endsWith("?")) s = s.substring(0, s.length() - 1); // sometimes used if write is not sure about date
if (s.startsWith("{")) s = s.substring(1);
if (s.endsWith("}")) s = s.substring(0, s.length() - 1);
if (s.startsWith("[")) s = s.substring(1);
if (s.endsWith("]")) s = s.substring(0, s.length() - 1);
- while (s.length() > 0 && (s.charAt(0) > '9' || s.charAt(0) < '0')) s = s.substring(1);
+ while (!s.isEmpty() && (s.charAt(0) > '9' || s.charAt(0) < '0')) s = s.substring(1);
if (s.endsWith("--")) s = s.substring(0, s.length() - 2) + "00";
int p = s.indexOf(';'); if (p >= 0) s = s.substring(0, p); // a semicolon may be used to separate two dates from each other; then we take the first
p = s.indexOf(','); if (p >= 0) s = s.substring(0, p); // a comma may be used to separate two dates from each other; then we take the first
- while (s.length() > 0 && s.endsWith("?")) s = s.substring(0, s.length() - 1); // sometimes used if write is not sure about date
+ while (!s.isEmpty() && s.endsWith("?")) s = s.substring(0, s.length() - 1); // sometimes used if write is not sure about date
// no go for exact parsing
final Calendar cal = Calendar.getInstance(TZ_GMT, Locale.US);
diff --git a/source/net/yacy/cora/document/Classification.java b/source/net/yacy/cora/document/Classification.java
index 6b776e0dd..13afe7018 100644
--- a/source/net/yacy/cora/document/Classification.java
+++ b/source/net/yacy/cora/document/Classification.java
@@ -101,7 +101,7 @@ public class Classification {
}
private static void addSet(Set<String> set, final String extString) {
- if ((extString == null) || (extString.length() == 0)) return;
+ if ((extString == null) || (extString.isEmpty())) return;
for (String s: extString.split(",")) set.add(s.toLowerCase().trim());
}
diff --git a/source/net/yacy/cora/document/JSONObject.java b/source/net/yacy/cora/document/JSONObject.java
index 60f96c87d..c077dd597 100644
--- a/source/net/yacy/cora/document/JSONObject.java
+++ b/source/net/yacy/cora/document/JSONObject.java
@@ -1107,7 +1107,7 @@ public class JSONObject {
* @return A String correctly formatted for insertion in a JSON text.
*/
public static String quote(String string) {
- if (string == null || string.length() == 0) {
+ if (string == null || string.isEmpty()) {
return "\"\"";
}
diff --git a/source/net/yacy/cora/document/MultiProtocolURI.java b/source/net/yacy/cora/document/MultiProtocolURI.java
index 615889c3c..822d06667 100644
--- a/source/net/yacy/cora/document/MultiProtocolURI.java
+++ b/source/net/yacy/cora/document/MultiProtocolURI.java
@@ -82,7 +82,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
for (String s: idNames) {
if (s == null) continue;
s = s.trim();
- if (s.length() > 0) sessionIDnames.put(s, PRESENT);
+ if (!s.isEmpty()) sessionIDnames.put(s, PRESENT);
}
}
@@ -379,7 +379,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
// resolve '..'
private static final String resolveBackpath(final String path) {
String p = path;
- if (p.length() == 0 || p.charAt(0) != '/') { p = "/" + p; }
+ if (p.isEmpty() || p.charAt(0) != '/') { p = "/" + p; }
final Matcher qm = patternQuestion.matcher(p); // do not resolve backpaths in the post values
final int end = qm.find() ? qm.start() : p.length();
final Matcher matcher = backPathPattern.matcher(p);
@@ -824,7 +824,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
public static Map<String, Object> parseCamelCase(String s) {
final Map<String, Object> token = new LinkedHashMap<String, Object>();
- if (s.length() == 0) return token;
+ if (s.isEmpty()) return token;
int p = 0;
CharType type = charType(s.charAt(0)), nct = type;
while (p < s.length()) {
diff --git a/source/net/yacy/cora/document/RSSMessage.java b/source/net/yacy/cora/document/RSSMessage.java
index 1143134ae..cb643e7be 100644
--- a/source/net/yacy/cora/document/RSSMessage.java
+++ b/source/net/yacy/cora/document/RSSMessage.java
@@ -213,7 +213,7 @@ public class RSSMessage implements Hit, Comparable<RSSMessage>, Comparator<RSSMe
@Override
public String getGuid() {
String guid = Token.guid.valueFrom(this.map, "");
- if ((guid.length() == 0 || guid.startsWith(artificialGuidPrefix)) &&
+ if ((guid.isEmpty() || guid.startsWith(artificialGuidPrefix)) &&
(this.map.containsKey("title") || this.map.containsKey("description") || this.map.containsKey("link"))) {
guid = calculatedGuidPrefix + Integer.toHexString(getTitle().hashCode() + getDescription().hashCode() + getLink().hashCode());
this.map.put("guid", guid);
@@ -233,7 +233,7 @@ public class RSSMessage implements Hit, Comparable<RSSMessage>, Comparator<RSSMe
@Override
public long getSize() {
final String size = Token.size.valueFrom(this.map, "-1");
- return (size == null || size.length() == 0) ? -1 : Long.parseLong(size);
+ return (size == null || size.isEmpty()) ? -1 : Long.parseLong(size);
}
public String getFulltext() {
diff --git a/source/net/yacy/cora/language/phonetic/DoubleMetaphone.java b/source/net/yacy/cora/language/phonetic/DoubleMetaphone.java
index 1ccbf73c2..d1924c9cc 100644
--- a/source/net/yacy/cora/language/phonetic/DoubleMetaphone.java
+++ b/source/net/yacy/cora/language/phonetic/DoubleMetaphone.java
@@ -922,7 +922,7 @@ public class DoubleMetaphone implements StringEncoder {
return null;
}
input = input.trim();
- if (input.length() == 0) {
+ if (input.isEmpty()) {
return null;
}
return input.toUpperCase(java.util.Locale.ENGLISH);
diff --git a/source/net/yacy/cora/language/phonetic/Metaphone.java b/source/net/yacy/cora/language/phonetic/Metaphone.java
index 65f4f0716..d8b1ca71d 100644
--- a/source/net/yacy/cora/language/phonetic/Metaphone.java
+++ b/source/net/yacy/cora/language/phonetic/Metaphone.java
@@ -81,7 +81,7 @@ public class Metaphone implements StringEncoder {
*/
public String metaphone(String txt) {
boolean hard = false ;
- if ((txt == null) || (txt.length() == 0)) {
+ if ((txt == null) || (txt.isEmpty())) {
return "" ;
}
// single character is itself
diff --git a/source/net/yacy/cora/language/phonetic/Soundex.java b/source/net/yacy/cora/language/phonetic/Soundex.java
index 7581aa944..ad45db616 100644
--- a/source/net/yacy/cora/language/phonetic/Soundex.java
+++ b/source/net/yacy/cora/language/phonetic/Soundex.java
@@ -225,7 +225,7 @@ public class Soundex implements StringEncoder {
return null;
}
str = clean(str);
- if (str.length() == 0) {
+ if (str.isEmpty()) {
return str;
}
char out[] = {'0', '0', '0', '0'};
@@ -256,7 +256,7 @@ public class Soundex implements StringEncoder {
* @return A clean String.
*/
static String clean(String str) {
- if (str == null || str.length() == 0) {
+ if (str == null || str.isEmpty()) {
return str;
}
int len = str.length();
diff --git a/source/net/yacy/cora/lod/JenaTripleStore.java b/source/net/yacy/cora/lod/JenaTripleStore.java
index a45df78c6..cf5774a1c 100644
--- a/source/net/yacy/cora/lod/JenaTripleStore.java
+++ b/source/net/yacy/cora/lod/JenaTripleStore.java
@@ -115,7 +115,7 @@ public class JenaTripleStore {
public static void saveFile(String filename, Model model) {
File f = new File(filename);
File ftmp = new File(filename + "." + System.currentTimeMillis());
- if (model.size() == 0 && !f.exists()) {
+ if (model.isEmpty() && !f.exists()) {
// we don't store zero-size models if they did not exist before
Log.logInfo("TRIPLESTORE", "NOT saving triplestore with " + model.size() + " triples to " + filename);
return;
diff --git a/source/net/yacy/cora/lod/vocabulary/Tagging.java b/source/net/yacy/cora/lod/vocabulary/Tagging.java
index f8716d59c..c9acb0878 100644
--- a/source/net/yacy/cora/lod/vocabulary/Tagging.java
+++ b/source/net/yacy/cora/lod/vocabulary/Tagging.java
@@ -127,7 +127,7 @@ public class Tagging {
String term, v;
String[] tags;
vocloop: for (Map.Entry<String, SOTuple> e: table.entrySet()) {
- if (e.getValue().getSynonymsCSV() == null || e.getValue().getSynonymsCSV().length() == 0) {
+ if (e.getValue().getSynonymsCSV() == null || e.getValue().getSynonymsCSV().isEmpty()) {
term = normalizeKey(e.getKey());
v = normalizeTerm(e.getKey());
this.synonym2term.put(v, term);
@@ -140,10 +140,10 @@ public class Tagging {
Set<String> synonyms = new HashSet<String>();
synonyms.add(term);
tagloop: for (String synonym: tags) {
- if (synonym.length() == 0) continue tagloop;
+ if (synonym.isEmpty()) continue tagloop;
synonyms.add(synonym);
synonym = normalizeTerm(synonym);
- if (synonym.length() == 0) continue tagloop;
+ if (synonym.isEmpty()) continue tagloop;
synonyms.add(synonym);
this.synonym2term.put(synonym, term);
this.term2synonym.put(term, synonym);
@@ -163,7 +163,7 @@ public class Tagging {
for (Map.Entry<String, SOTuple> e: table.entrySet()) {
String s = e.getValue() == null ? "" : e.getValue().getSynonymsCSV();
String o = e.getValue() == null ? "" : e.getValue().getObjectlink();
- w.write(e.getKey() + (s == null || s.length() == 0 ? "" : ":" + e.getValue().getSynonymsCSV()) + (o == null || o.length() == 0 || o.equals(objectspace + e.getKey()) ? "" : "#" + o) + "\n");
+ w.write(e.getKey() + (s == null || s.isEmpty() ? "" : ":" + e.getValue().getSynonymsCSV()) + (o == null || o.isEmpty() || o.equals(objectspace + e.getKey()) ? "" : "#" + o) + "\n");
}
w.close();
init();
@@ -180,7 +180,7 @@ public class Tagging {
this.synonym2term.put(syn, loc);
this.term2synonym.put(loc, syn);
geo = location.find(loc, true);
- if (geo.size() > 0) {
+ if (!geo.isEmpty()) {
g = geo.iterator().next();
this.term2objectlink.put(loc, "http://www.openstreetmap.org/?lat=" + g.lat() + "&lon=" + g.lon() + "&zoom=16");
}
@@ -249,10 +249,10 @@ public class Tagging {
Set<String> synonyms = new HashSet<String>();
synonyms.add(term);
tagloop: for (String synonym: tags) {
- if (synonym.length() == 0) continue tagloop;
+ if (synonym.isEmpty()) continue tagloop;
synonyms.add(synonym);
synonym = normalizeTerm(synonym);
- if (synonym.length() == 0) continue tagloop;
+ if (synonym.isEmpty()) continue tagloop;
synonyms.add(synonym);
this.synonym2term.put(synonym, term);
this.term2synonym.put(term, synonym);
@@ -295,14 +295,14 @@ public class Tagging {
continue vocloop;
}
if (pl[0].equals(term)) {
- w.write(term + (synonyms == null || synonyms.length() == 0 ? "" : ":" + synonyms) + (objectlink == null || objectlink.length() == 0 || objectlink.equals(this.objectspace + term) ? "" : "#" + objectlink) + "\n");
+ w.write(term + (synonyms == null || synonyms.isEmpty() ? "" : ":" + synonyms) + (objectlink == null || objectlink.isEmpty() || objectlink.equals(this.objectspace + term) ? "" : "#" + objectlink) + "\n");
written = true;
} else {
- w.write(pl[0] + (pl[1] == null || pl[1].length() == 0 ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].length() == 0 || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");
+ w.write(pl[0] + (pl[1] == null || pl[1].isEmpty() ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].isEmpty() || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");
}
}
if (!written) {
- w.write(term + (synonyms == null || synonyms.length() == 0 ? "" : ":" + synonyms) + (objectlink == null || objectlink.length() == 0 || objectlink.equals(this.objectspace + term) ? "" : "#" + objectlink) + "\n");
+ w.write(term + (synonyms == null || synonyms.isEmpty() ? "" : ":" + synonyms) + (objectlink == null || objectlink.isEmpty() || objectlink.equals(this.objectspace + term) ? "" : "#" + objectlink) + "\n");
}
} catch (InterruptedException e) {
}
@@ -329,7 +329,7 @@ public class Tagging {
if (pl[0].equals(term)) {
continue vocloop;
}
- w.write(pl[0] + (pl[1] == null || pl[1].length() == 0 ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].length() == 0 || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");
+ w.write(pl[0] + (pl[1] == null || pl[1].isEmpty() ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].isEmpty() || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");
}
} catch (InterruptedException e) {
}
@@ -367,7 +367,7 @@ public class Tagging {
if (pl == null) {
continue vocloop;
}
- w.write(pl[0] + (pl[1] == null || pl[1].length() == 0 ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].length() == 0 || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");
+ w.write(pl[0] + (pl[1] == null || pl[1].isEmpty() ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].isEmpty() || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");
}
} catch (InterruptedException e) {
}
@@ -431,7 +431,7 @@ public class Tagging {
if (pl == null) {
continue vocloop;
}
- map.put(pl[0], new SOTuple(pl[1] == null || pl[1].length() == 0 ? "" : pl[1], pl[2] == null || pl[2].length() == 0 || pl[2].equals(this.objectspace + pl[0]) ? "" : pl[2]));
+ map.put(pl[0], new SOTuple(pl[1] == null || pl[1].isEmpty() ? "" : pl[1], pl[2] == null || pl[2].isEmpty() || pl[2].equals(this.objectspace + pl[0]) ? "" : pl[2]));
}
} catch (InterruptedException e) {
}
@@ -446,7 +446,7 @@ public class Tagging {
c = line.substring(p + 1);
line = line.substring(0, p).trim();
}
- if (line.length() == 0) {
+ if (line.isEmpty()) {
return null;
}
p = line.indexOf(':');
@@ -600,7 +600,7 @@ public class Tagging {
}
public static String cleanTagFromAutotagging(final String tagString) {
- if (tagString == null || tagString.length() == 0) return "";
+ if (tagString == null || tagString.isEmpty()) return "";
String[] tags = PATTERN_SP.split(tagString);
StringBuilder sb = new StringBuilder(tagString.length());
for (String tag : tags) {
diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.java
index 9531d0dd4..0249aa32b 100644
--- a/source/net/yacy/cora/protocol/Domains.java
+++ b/source/net/yacy/cora/protocol/Domains.java
@@ -570,7 +570,7 @@ public class Domains {
* @return the hosts InetAddress or null if the address cannot be resolved
*/
public static InetAddress dnsResolve(final String host0) {
- if (host0 == null || host0.length() == 0) return null;
+ if (host0 == null || host0.isEmpty()) return null;
final String host = host0.toLowerCase().trim();
// try to simply parse the address
InetAddress ip = parseInetAddress(host);
@@ -856,7 +856,7 @@ public class Domains {
}
public static boolean isThisHostIP(final String hostName) {
- if ((hostName == null) || (hostName.length() == 0)) return false;
+ if ((hostName == null) || (hostName.isEmpty())) return false;
boolean isThisHostIP = false;
try {
@@ -934,7 +934,7 @@ public class Domains {
if (noLocalCheck || // DO NOT REMOVE THIS! it is correct to return true if the check is off
host == null ||
- host.length() == 0) return true;
+ host.isEmpty()) return true;
// FIXME IPv4 only
// check local ip addresses
diff --git a/source/net/yacy/cora/protocol/HeaderFramework.java b/source/net/yacy/cora/protocol/HeaderFramework.java
index c8a593ecb..e519cc9df 100644
--- a/source/net/yacy/cora/protocol/HeaderFramework.java
+++ b/source/net/yacy/cora/protocol/HeaderFramework.java
@@ -578,7 +578,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
int p;
String line;
while ((line = reader.readLine()) != null) {
- if (line.length() == 0) break;
+ if (line.isEmpty()) break;
if ((p = line.indexOf(':')) >= 0) {
// store a property
add(line.substring(0, p).trim(), line.substring(p + 1).trim());
diff --git a/source/net/yacy/cora/protocol/ResponseHeader.java b/source/net/yacy/cora/protocol/ResponseHeader.java
index 6d405d33a..328c10722 100644
--- a/source/net/yacy/cora/protocol/ResponseHeader.java
+++ b/source/net/yacy/cora/protocol/ResponseHeader.java
@@ -99,7 +99,7 @@ public class ResponseHeader extends HeaderFramework {
public static Object[] parseResponseLine(final String respLine) {
- if ((respLine == null) || (respLine.length() == 0)) {
+ if ((respLine == null) || (respLine.isEmpty())) {
return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};
}
diff --git a/source/net/yacy/cora/protocol/ftp/FTPClient.java b/source/net/yacy/cora/protocol/ftp/FTPClient.java
index 31f446439..d7ff3d697 100644
--- a/source/net/yacy/cora/protocol/ftp/FTPClient.java
+++ b/source/net/yacy/cora/protocol/ftp/FTPClient.java
@@ -143,7 +143,7 @@ public class FTPClient {
}
public boolean exec(String command, final boolean promptIt) {
- if ((command == null) || (command.length() == 0)) {
+ if ((command == null) || (command.isEmpty())) {
return true;
}
int pos;
@@ -205,7 +205,7 @@ public class FTPClient {
private String[] line2args(final String line) {
// parse the command line
- if ((line == null) || (line.length() == 0)) {
+ if ((line == null) || (line.isEmpty())) {
return null;
}
// pre-parse
@@ -2693,7 +2693,7 @@ public class FTPClient {
c.exec("lcd \"" + localFile.getParent() + "\"", false);
localFile = new File(localFile.getName());
}
- c.exec("put " + localFile.toString() + ((remoteName.length() == 0) ? "" : (" " + remoteName)), false);
+ c.exec("put " + localFile.toString() + ((remoteName.isEmpty()) ? "" : (" " + remoteName)), false);
c.exec("close", false);
c.exec("exit", false);
@@ -2719,7 +2719,7 @@ public class FTPClient {
public static void get(final String host, String remoteFile, final File localPath, final String account, final String password) {
try {
final FTPClient c = new FTPClient();
- if (remoteFile.length() == 0) {
+ if (remoteFile.isEmpty()) {
remoteFile = "/";
}
c.exec("open " + host, false);
diff --git a/source/net/yacy/cora/services/federated/solr/SingleSolrConnector.java b/source/net/yacy/cora/services/federated/solr/SingleSolrConnector.java
index 28de5b84d..13afcba9c 100644
--- a/source/net/yacy/cora/services/federated/solr/SingleSolrConnector.java
+++ b/source/net/yacy/cora/services/federated/solr/SingleSolrConnector.java
@@ -65,7 +65,7 @@ public class SingleSolrConnector extends AbstractSolrConnector implements SolrCo
this.port = u.getPort();
this.solrpath = u.getPath();
final String userinfo = u.getUserInfo();
- if (userinfo == null || userinfo.length() == 0) {
+ if (userinfo == null || userinfo.isEmpty()) {
this.solraccount = ""; this.solrpw = "";
} else {
final int p = userinfo.indexOf(':');
diff --git a/source/net/yacy/cora/sorting/ClusteredScoreMap.java b/source/net/yacy/cora/sorting/ClusteredScoreMap.java
index 397bd756d..a0ebb8ef8 100644
--- a/source/net/yacy/cora/sorting/ClusteredScoreMap.java
+++ b/source/net/yacy/cora/sorting/ClusteredScoreMap.java
@@ -98,7 +98,7 @@ public final class ClusteredScoreMap<E> extends AbstractScoreMap<E> implements R
int score;
Long key;
synchronized (this) {
- while (this.pam.size() > 0) {
+ while (!this.pam.isEmpty()) {
// find and remove objects where their score is smaller than the demanded minimum score
key = this.pam.firstKey();
if (key == null) break;
@@ -140,7 +140,7 @@ public final class ClusteredScoreMap<E> extends AbstractScoreMap<E> implements R
if (o instanceof byte[]) s = UTF8.String((byte[]) o);
// this can be used to calculate a score from a string
- if (s == null || s.length() == 0 || s.charAt(0) == '-') return 0;
+ if (s == null || s.isEmpty() || s.charAt(0) == '-') return 0;
try {
long l = 0;
if (s.length() == shortDateFormatString.length()) {
diff --git a/source/net/yacy/cora/storage/KeyList.java b/source/net/yacy/cora/storage/KeyList.java
index 3697403ad..5d95b2800 100644
--- a/source/net/yacy/cora/storage/KeyList.java
+++ b/source/net/yacy/cora/storage/KeyList.java
@@ -63,7 +63,7 @@ public class KeyList implements Iterable<String> {
String l;
try {
while ((l = reader.readLine()) != null) {
- if (l.length() == 0 || l.charAt(0) == '#') continue;
+ if (l.isEmpty() || l.charAt(0) == '#') continue;
l = l.trim().toLowerCase();
this.keys.put(l, _obj);
}
diff --git a/source/net/yacy/dbtest.java b/source/net/yacy/dbtest.java
index 45d344011..ac8a44f43 100644
--- a/source/net/yacy/dbtest.java
+++ b/source/net/yacy/dbtest.java
@@ -71,7 +71,7 @@ public class dbtest {
public boolean isValid() {
final String s = UTF8.String(this.value).trim();
- if (s.length() == 0) return false;
+ if (s.isEmpty()) return false;
final long source = Long.parseLong(s);
return ByteBuffer.equals(this.key, randomHash(source, source));
}
diff --git a/source/net/yacy/document/Autotagging.java b/source/net/yacy/document/Autotagging.java
index 5e01093bc..4930ba8ed 100644
--- a/source/net/yacy/document/Autotagging.java
+++ b/source/net/yacy/document/Autotagging.java
@@ -109,7 +109,7 @@ public class Autotagging {
}
public void addPlaces(Locations locations) {
- if (locations.size() == 0) return; // otherwise we get a navigation that does nothing
+ if (locations.isEmpty()) return; // otherwise we get a navigation that does nothing
Tagging voc = new Tagging("Locations", locations);
try {
voc.setObjectspace("http://dbpedia.org/resource/");
@@ -125,6 +125,10 @@ public class Autotagging {
return this.vocabularies.size();
}
+ public boolean isEmpty() {
+ return this.vocabularies.isEmpty();
+ }
+
/**
* maximum number of compound tags (number of words in one tag)
* @return
diff --git a/source/net/yacy/document/Condenser.java b/source/net/yacy/document/Condenser.java
index 24b1968d7..e6091018e 100644
--- a/source/net/yacy/document/Condenser.java
+++ b/source/net/yacy/document/Condenser.java
@@ -309,7 +309,7 @@ public final class Condenser {
int wordInSentenceCounter = 1;
boolean comb_indexof = false, last_last = false, last_index = false;
final Map<StringBuilder, Phrase> sentences = new HashMap<StringBuilder, Phrase>(100);
- if (LibraryProvider.autotagging.size() == 0) doAutotagging = false;
+ if (LibraryProvider.autotagging.isEmpty()) doAutotagging = false;
// read source
final WordTokenizer wordenum = new WordTokenizer(new SentenceReader(text), meaningLib);
diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.java
index 34b1bd15e..53b1532e9 100644
--- a/source/net/yacy/document/Document.java
+++ b/source/net/yacy/document/Document.java
@@ -230,7 +230,7 @@ dc_rights
sb.append(',').append(s.getObject());
String objectlink = vocabulary.getObjectlink(s.getObject());
if ((objectspace != null && objectspace.length() > 0) || (objectlink != null && objectlink.length() > 0)) {
- JenaTripleStore.addTriple(subject, DCTerms.references.getPredicate(), objectlink == null || objectlink.length() == 0 ? objectspace + s.getObject() + "#" + s.getObject() : objectlink + "#" + s.getObject());
+ JenaTripleStore.addTriple(subject, DCTerms.references.getPredicate(), objectlink == null || objectlink.isEmpty() ? objectspace + s.getObject() + "#" + s.getObject() : objectlink + "#" + s.getObject());
}
}
// put to triplestore
@@ -246,7 +246,7 @@ dc_rights
for (int i = 0; i < this.keywords.size(); i++) {
if (this.keywords.get(i) == null) continue;
s = (this.keywords.get(i)).trim();
- if (s.length() > 0) hs.add(s);
+ if (!s.isEmpty()) hs.add(s);
}
final String[] t = new String[hs.size()];
int i = 0;
@@ -892,7 +892,7 @@ dc_rights
}
private static final String description(Document d, String tagname) {
- if (tagname == null || tagname.length() == 0) {
+ if (tagname == null || tagname.isEmpty()) {
tagname = d.source.toTokens();
}
StringBuilder sb = new StringBuilder(60);
diff --git a/source/net/yacy/document/LibraryProvider.java b/source/net/yacy/document/LibraryProvider.java
index 440d07147..ee5830126 100644
--- a/source/net/yacy/document/LibraryProvider.java
+++ b/source/net/yacy/document/LibraryProvider.java
@@ -245,13 +245,13 @@ public class LibraryProvider {
p = term.indexOf('(');
if (p >= 0) term = term.substring(0, p);
term = term.replaceAll("_", " ").trim();
- if (term.length() == 0) continue;
+ if (term.isEmpty()) continue;
if (term.indexOf(' ') < 0) continue; // accept only names that have at least two parts
// store the term into the vocabulary map
map.put(term, new SOTuple(Tagging.normalizeTerm(term), subject));
}
- if (map.size() > 0) try {
+ if (!map.isEmpty()) try {
Log.logInfo("LibraryProvider", "adding vocabulary to autotagging");
Tagging pndVoc = new Tagging("Persons", null, objectspace, map);
autotagging.addVocabulary(pndVoc);
diff --git a/source/net/yacy/document/SnippetExtractor.java b/source/net/yacy/document/SnippetExtractor.java
index 417833418..4427fdc68 100644
--- a/source/net/yacy/document/SnippetExtractor.java
+++ b/source/net/yacy/document/SnippetExtractor.java
@@ -61,7 +61,7 @@ public class SnippetExtractor {
// - 2nd order: word distance
// - 3th order: line length (not too short and not too long)
// - 4rd order: line number
- if (positions.size() > 0) {
+ if (!positions.isEmpty()) {
order.put(Long.valueOf(-100000000L * (linenumber == 0 ? 1 : 0) + 10000000L * positions.size() + 1000000L * worddistance + 100000L * linelengthKey(sentence.length(), maxLength) - 10000L * linenumber + uniqCounter--), sentence);
if (order.size() > 5) order.remove(order.firstEntry().getKey());
if (positions.size() == queryhashes.size()) fullmatchcounter++;
diff --git a/source/net/yacy/document/StringBuilderComparator.java b/source/net/yacy/document/StringBuilderComparator.java
index 41e77dc0b..6eea342c6 100644
--- a/source/net/yacy/document/StringBuilderComparator.java
+++ b/source/net/yacy/document/StringBuilderComparator.java
@@ -125,7 +125,7 @@ public class StringBuilderComparator implements Comparator<StringBuilder> {
list.add(sb.substring(off, sb.length()));
int resultSize = list.size();
- while (resultSize > 0 && list.get(resultSize - 1).length() == 0) resultSize--;
+ while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) resultSize--;
final StringBuilder[] result = new StringBuilder[resultSize];
for (int i = 0; i < resultSize; i++) result[i] = new StringBuilder(list.get(i));
return result;
diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.java
index 75e8cb49f..51b02503f 100644
--- a/source/net/yacy/document/TextParser.java
+++ b/source/net/yacy/document/TextParser.java
@@ -408,13 +408,13 @@ public final class TextParser {
* @return an error if the extension is not supported, null otherwise
*/
public static String supportsExtension(final String ext) {
- if (ext == null || ext.length() == 0) return null;
+ if (ext == null || ext.isEmpty()) return null;
if (denyExtensionx.containsKey(ext)) return "file extension '" + ext + "' is denied (2)";
final String mimeType = ext2mime.get(ext);
if (mimeType == null) return "no parser available";
final Set<Parser> idiom = mime2parser.get(mimeType);
assert idiom != null;
- if (idiom == null || idiom.size() == 0) return "no parser available (internal error!)";
+ if (idiom == null || idiom.isEmpty()) return "no parser available (internal error!)";
return null;
}
@@ -455,13 +455,13 @@ public final class TextParser {
public static String getDenyMime() {
String s = "";
for (final String d: denyMime.keySet()) s += d + ",";
- if (s.length() > 0) s = s.substring(0, s.length() - 1);
+ if (!s.isEmpty()) s = s.substring(0, s.length() - 1);
return s;
}
public static void grantMime(final String mime, final boolean grant) {
final String n = normalizeMimeType(mime);
- if (n == null || n.length() == 0) return;
+ if (n == null || n.isEmpty()) return;
if (grant) denyMime.remove(n); else denyMime.put(n, v);
}
@@ -478,7 +478,7 @@ public final class TextParser {
}
public static void grantExtension(final String ext, final boolean grant) {
- if (ext == null || ext.length() == 0) return;
+ if (ext == null || ext.isEmpty()) return;
if (grant) denyExtensionx.remove(ext); else denyExtensionx.put(ext, v);
}
diff --git a/source/net/yacy/document/WordCache.java b/source/net/yacy/document/WordCache.java
index cbce70c61..491146190 100644
--- a/source/net/yacy/document/WordCache.java
+++ b/source/net/yacy/document/WordCache.java
@@ -78,7 +78,7 @@ public class WordCache {
StringBuilder sb;
try {
while ((l = reader.readLine()) != null) {
- if (l.length() == 0 || l.charAt(0) == '#') {
+ if (l.isEmpty() || l.charAt(0) == '#') {
continue;
}
l = l.trim().toLowerCase();
diff --git a/source/net/yacy/document/content/DCEntry.java b/source/net/yacy/document/content/DCEntry.java
index 3b7d2c414..c310fa5e3 100644
--- a/source/net/yacy/document/content/DCEntry.java
+++ b/source/net/yacy/document/content/DCEntry.java
@@ -98,7 +98,7 @@ public class DCEntry extends TreeMap<String, String> {
String d = this.get("docdatetime");
if (d == null) d = this.get("dc:date");
if (d == null) return null;
- if (d.length() == 0) return null;
+ if (d.isEmpty()) return null;
try {
return ISO8601Formatter.FORMATTER.parse(d);
} catch (ParseException e) {
diff --git a/source/net/yacy/document/content/dao/ImportDump.java b/source/net/yacy/document/content/dao/ImportDump.java
index c33abbe27..bf8511c94 100644
--- a/source/net/yacy/document/content/dao/ImportDump.java
+++ b/source/net/yacy/document/content/dao/ImportDump.java
@@ -61,7 +61,7 @@ public class ImportDump {
String s = UTF8.String(baos.toByteArray());
int p, q;
String t;
- loop: while (s.length() > 0) {
+ loop: while (!s.isEmpty()) {
p = s.indexOf("INSERT INTO", 1);
q = s.indexOf("CREATE TABLE", 1);
if (q >= 0 && q < p) p = q;
diff --git a/source/net/yacy/document/geolocation/GeonamesLocation.java b/source/net/yacy/document/geolocation/GeonamesLocation.java
index 5b5842b26..0f25639d2 100644
--- a/source/net/yacy/document/geolocation/GeonamesLocation.java
+++ b/source/net/yacy/document/geolocation/GeonamesLocation.java
@@ -43,8 +43,7 @@ import net.yacy.document.StringBuilderComparator;
import net.yacy.document.WordCache;
import net.yacy.kelondro.logging.Log;
-public class GeonamesLocation implements Locations
-{
+public class GeonamesLocation implements Locations {
/*
The main 'geoname' table has the following fields :
@@ -125,7 +124,7 @@ public class GeonamesLocation implements Locations
String[] fields;
Set<StringBuilder> locnames;
while ( (line = reader.readLine()) != null ) {
- if ( line.length() == 0 ) {
+ if ( line.isEmpty() ) {
continue;
}
fields = line.split("\t");
@@ -163,6 +162,11 @@ public class GeonamesLocation implements Locations
return this.id2loc.size();
}
+ @Override
+ public boolean isEmpty() {
+ return this.id2loc.isEmpty();
+ }
+
@Override
public TreeSet<GeoLocation> find(final String anyname, final boolean locationexact) {
final Set<Integer> r = new HashSet<Integer>();
@@ -211,7 +215,7 @@ public class GeonamesLocation implements Locations
public Set<String> recommend(final String s) {
final Set<String> a = new HashSet<String>();
final StringBuilder an = new StringBuilder(s);
- if ( s.length() == 0 ) {
+ if ( s.isEmpty() ) {
return a;
}
final SortedMap<StringBuilder, List<Integer>> t = this.name2ids.tailMap(an);
diff --git a/source/net/yacy/document/geolocation/Locations.java b/source/net/yacy/document/geolocation/Locations.java
index 2a56a4ea8..919c9bd5f 100644
--- a/source/net/yacy/document/geolocation/Locations.java
+++ b/source/net/yacy/document/geolocation/Locations.java
@@ -39,6 +39,11 @@ public interface Locations {
*/
public int size();
+ /**
+ * @return true if the number of locations that this localization stores is empty
+ */
+ public boolean isEmpty();
+
/**
* find a location by name
* @param anyname - a name of a location
diff --git a/source/net/yacy/document/geolocation/OpenGeoDBLocation.java b/source/net/yacy/document/geolocation/OpenGeoDBLocation.java
index 0c09b8ab4..844f9091f 100644
--- a/source/net/yacy/document/geolocation/OpenGeoDBLocation.java
+++ b/source/net/yacy/document/geolocation/OpenGeoDBLocation.java
@@ -189,6 +189,11 @@ public class OpenGeoDBLocation implements Locations
return this.id2loc.size();
}
+ @Override
+ public boolean isEmpty() {
+ return this.id2loc.isEmpty();
+ }
+
/**
* check database tables against occurrences of this entity the anyname - String may be one of: - name of
* a town, villa, region etc - zip code - telephone prefix - kfz sign
@@ -262,7 +267,7 @@ public class OpenGeoDBLocation implements Locations
public Set<String> recommend(final String s) {
final Set<String> a = new HashSet<String>();
final StringBuilder an = new StringBuilder(s);
- if ( s.length() == 0 ) {
+ if ( s.isEmpty() ) {
return a;
}
final SortedMap<StringBuilder, List<Integer>> t = this.name2ids.tailMap(an);
diff --git a/source/net/yacy/document/geolocation/OverarchingLocation.java b/source/net/yacy/document/geolocation/OverarchingLocation.java
index 687b3cefe..ce400cccf 100644
--- a/source/net/yacy/document/geolocation/OverarchingLocation.java
+++ b/source/net/yacy/document/geolocation/OverarchingLocation.java
@@ -70,6 +70,14 @@ public class OverarchingLocation implements Locations {
return locations;
}
+ @Override
+ public boolean isEmpty() {
+ for (final Locations service: this.services.values()) {
+ if (!service.isEmpty()) return false;
+ }
+ return true;
+ }
+
/**
* find a location by name
* @param anyname - a name of a location
@@ -106,7 +114,7 @@ public class OverarchingLocation implements Locations {
@Override
public Set<String> recommend(final String s) {
final Set<String> recommendations = new HashSet<String>();
- if (s.length() == 0) {
+ if (s.isEmpty()) {
return recommendations;
}
for (final Locations service: this.services.values()) {
diff --git a/source/net/yacy/document/importer/ResumptionToken.java b/source/net/yacy/document/importer/ResumptionToken.java
index 86dc3ac54..831d88460 100644
--- a/source/net/yacy/document/importer/ResumptionToken.java
+++ b/source/net/yacy/document/importer/ResumptionToken.java
@@ -131,7 +131,7 @@ public class ResumptionToken extends TreeMap<String, String> {
final String token = getToken();
if (token == null) throw new IOException("end of resumption reached - token == null");
- if (token.length() == 0) throw new IOException("end of resumption reached - token.length() == 0");
+ if (token.isEmpty()) throw new IOException("end of resumption reached - token.isEmpty()");
final String url = truncatedURL(this.source);
// encoded state
diff --git a/source/net/yacy/document/parser/csvParser.java b/source/net/yacy/document/parser/csvParser.java
index 6e05fee1c..42a849864 100644
--- a/source/net/yacy/document/parser/csvParser.java
+++ b/source/net/yacy/document/parser/csvParser.java
@@ -104,7 +104,7 @@ public class csvParser extends AbstractParser implements Parser {
try {
while ((row = reader.readLine()) != null) {
row = row.trim();
- if (row.length() == 0) continue;
+ if (row.isEmpty()) continue;
if (separator == null) {
// try comma, semicolon and tab; take that one that results with more columns
final String[] colc = row.split(",");
diff --git a/source/net/yacy/document/parser/dwgParser.java b/source/net/yacy/document/parser/dwgParser.java
index 436396cdf..6289b1a57 100644
--- a/source/net/yacy/document/parser/dwgParser.java
+++ b/source/net/yacy/document/parser/dwgParser.java
@@ -103,11 +103,11 @@ public class dwgParser extends AbstractParser implements Parser {
docSubject = info.getSubject();
docAuthor = info.getAuthor();
docPublisher = info.getProducer();
- if (docPublisher == null || docPublisher.length() == 0) docPublisher = info.getCreator();
+ if (docPublisher == null || docPublisher.isEmpty()) docPublisher = info.getCreator();
docKeywordStr = info.getKeywords();
}
- if (docTitle == null || docTitle.length() == 0) {
+ if (docTitle == null || docTitle.isEmpty()) {
docTitle = MultiProtocolURI.unescape(location.getFileName());
}
@@ -259,7 +259,7 @@ public class dwgParser extends AbstractParser implements Parser {
private void handleHeader(
int headerNumber, String value, Metadata metadata,
XHTMLContentHandler xhtml) throws SAXException {
- if(value == null || value.length() == 0) {
+ if(value == null || value.isEmpty()) {
return;
}
diff --git a/source/net/yacy/document/parser/genericParser.java b/source/net/yacy/document/parser/genericParser.java
index 93a8714cc..623c907a1 100644
--- a/source/net/yacy/document/parser/genericParser.java
+++ b/source/net/yacy/document/parser/genericParser.java
@@ -54,7 +54,7 @@ public class genericParser extends AbstractParser implements Parser {
this,
null,
null,
- location.getFileName().length() == 0 ? location.toTokens() : MultiProtocolURI.unescape(location.getFileName()), // title
+ location.getFileName().isEmpty() ? location.toTokens() : MultiProtocolURI.unescape(location.getFileName()), // title
"", // author
location.getHost(),
null,
diff --git a/source/net/yacy/document/parser/html/ContentScraper.java b/source/net/yacy/document/parser/html/ContentScraper.java
index d2e8eb9b0..650a1d6b5 100644
--- a/source/net/yacy/document/parser/html/ContentScraper.java
+++ b/source/net/yacy/document/parser/html/ContentScraper.java
@@ -567,7 +567,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {
// take description tag
s = getDescription();
- if (s.length() > 0) return s;
+ if (!s.isEmpty()) return s;
// extract headline from file name
return MultiProtocolURI.unescape(this.root.getFileName());
@@ -763,7 +763,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {
String s = this.metas.get("keywords");
if (s == null) s = this.metas.get("dc.description");
if (s == null) s = EMPTY_STRING;
- if (s.length() == 0) {
+ if (s.isEmpty()) {
return new String[0];
}
if (s.contains(",")) return commaSepPattern.split(s);
diff --git a/source/net/yacy/document/parser/html/ContentTransformer.java b/source/net/yacy/document/parser/html/ContentTransformer.java
index 957202eb6..22f61a088 100644
--- a/source/net/yacy/document/parser/html/ContentTransformer.java
+++ b/source/net/yacy/document/parser/html/ContentTransformer.java
@@ -65,7 +65,7 @@ public class ContentTransformer extends AbstractTransformer implements Transform
final BufferedReader r = new BufferedReader(new FileReader(f));
String s;
while ((s = r.readLine()) != null) {
- if (s.length() > 0 && s.charAt(0) != '#') this.bluelist.add(s.toLowerCase());
+ if (!s.isEmpty() && s.charAt(0) != '#') this.bluelist.add(s.toLowerCase());
}
r.close();
} catch (final IOException e) {
diff --git a/source/net/yacy/document/parser/html/ScraperInputStream.java b/source/net/yacy/document/parser/html/ScraperInputStream.java
index c76074496..fe8acf71e 100644
--- a/source/net/yacy/document/parser/html/ScraperInputStream.java
+++ b/source/net/yacy/document/parser/html/ScraperInputStream.java
@@ -104,7 +104,7 @@ public class ScraperInputStream extends InputStream implements ScraperListener {
@Override
public void scrapeTag0(final String tagname, final Properties tagopts) {
- if (tagname == null || tagname.length() == 0) return;
+ if (tagname == null || tagname.isEmpty()) return;
if (tagname.equalsIgnoreCase("meta")) {
if (tagopts.containsKey("http-equiv")) {
@@ -127,7 +127,7 @@ public class ScraperInputStream extends InputStream implements ScraperListener {
@Override
public void scrapeTag1(final String tagname, final Properties tagopts, final char[] text) {
- if (tagname == null || tagname.length() == 0) return;
+ if (tagname == null || tagname.isEmpty()) return;
if (tagname.equalsIgnoreCase("head")) {
this.endOfHead = true;
diff --git a/source/net/yacy/document/parser/html/TransformerWriter.java b/source/net/yacy/document/parser/html/TransformerWriter.java
index 187e60885..e9c1310e5 100644
--- a/source/net/yacy/document/parser/html/TransformerWriter.java
+++ b/source/net/yacy/document/parser/html/TransformerWriter.java
@@ -411,7 +411,7 @@ public final class TransformerWriter extends Writer {
this.buffer.reset();
}
} else {
- if (this.buffer.length() == 0) {
+ if (this.buffer.isEmpty()) {
if (c == rb) {
// very strange error case; we just let it pass
if (this.out != null) this.out.write(c);
diff --git a/source/net/yacy/document/parser/images/genericImageParser.java b/source/net/yacy/document/parser/images/genericImageParser.java
index ee9e8026b..334bb16f8 100644
--- a/source/net/yacy/document/parser/images/genericImageParser.java
+++ b/source/net/yacy/document/parser/images/genericImageParser.java
@@ -157,23 +157,23 @@ public class genericImageParser extends AbstractParser implements Parser {
}
}
title = props.get("Image Description");
- if (title == null || title.length() == 0) title = props.get("Headline");
- if (title == null || title.length() == 0) title = props.get("Object Name");
+ if (title == null || title.isEmpty()) title = props.get("Headline");
+ if (title == null || title.isEmpty()) title = props.get("Object Name");
author = props.get("Artist");
- if (author == null || author.length() == 0) author = props.get("Writer/Editor");
- if (author == null || author.length() == 0) author = props.get("By-line");
- if (author == null || author.length() == 0) author = props.get("Credit");
- if (author == null || author.length() == 0) author = props.get("Make");
+ if (author == null || author.isEmpty()) author = props.get("Writer/Editor");
+ if (author == null || author.isEmpty()) author = props.get("By-line");
+ if (author == null || author.isEmpty()) author = props.get("Credit");
+ if (author == null || author.isEmpty()) author = props.get("Make");
keywords = props.get("Keywords");
- if (keywords == null || keywords.length() == 0) keywords = props.get("Category");
- if (keywords == null || keywords.length() == 0) keywords = props.get("Supplemental Category(s)");
+ if (keywords == null || keywords.isEmpty()) keywords = props.get("Category");
+ if (keywords == null || keywords.isEmpty()) keywords = props.get("Supplemental Category(s)");
description = props.get("Caption/Abstract");
- if (description == null || description.length() == 0) description = props.get("Country/Primary Location");
- if (description == null || description.length() == 0) description = props.get("Province/State");
- if (description == null || description.length() == 0) description = props.get("Copyright Notice");
+ if (description == null || description.isEmpty()) description = props.get("Country/Primary Location");
+ if (description == null || description.isEmpty()) description = props.get("Province/State");
+ if (description == null || description.isEmpty()) description = props.get("Copyright Notice");
}
} catch (final JpegProcessingException e) {
//Log.logException(e);
@@ -190,7 +190,7 @@ public class genericImageParser extends AbstractParser implements Parser {
final String infoString = ii.info.toString();
images.put(ii.location, new ImageEntry(location, "", ii.width, ii.height, -1));
- if (title == null || title.length() == 0) title = MultiProtocolURI.unescape(location.getFileName());
+ if (title == null || title.isEmpty()) title = MultiProtocolURI.unescape(location.getFileName());
return new Document[]{new Document(
location,
diff --git a/source/net/yacy/document/parser/ooxmlParser.java b/source/net/yacy/document/parser/ooxmlParser.java
index 13c990ce1..f1cf0717b 100644
--- a/source/net/yacy/document/parser/ooxmlParser.java
+++ b/source/net/yacy/document/parser/ooxmlParser.java
@@ -148,11 +148,11 @@ public class ooxmlParser extends AbstractParser implements Parser {
// make the languages set
final Set<String> languages = new HashSet<String>(1);
- if (docLanguage != null && docLanguage.length() == 0)
+ if (docLanguage != null && docLanguage.isEmpty())
languages.add(docLanguage);
// if there is no title availabe we generate one
- if ((docLongTitle == null || docLongTitle.length() == 0) && (docShortTitle != null)) {
+ if ((docLongTitle == null || docLongTitle.isEmpty()) && (docShortTitle != null)) {
docLongTitle = docShortTitle;
}
diff --git a/source/net/yacy/document/parser/pdfParser.java b/source/net/yacy/document/parser/pdfParser.java
index 827567980..b6daef6d7 100644
--- a/source/net/yacy/document/parser/pdfParser.java
+++ b/source/net/yacy/document/parser/pdfParser.java
@@ -115,7 +115,7 @@ public class pdfParser extends AbstractParser implements Parser {
docSubject = info.getSubject();
docAuthor = info.getAuthor();
docPublisher = info.getProducer();
- if (docPublisher == null || docPublisher.length() == 0) docPublisher = info.getCreator();
+ if (docPublisher == null || docPublisher.isEmpty()) docPublisher = info.getCreator();
docKeywordStr = info.getKeywords();
// unused:
// info.getTrapped());
@@ -123,7 +123,7 @@ public class pdfParser extends AbstractParser implements Parser {
// info.getModificationDate();
}
- if (docTitle == null || docTitle.length() == 0) {
+ if (docTitle == null || docTitle.isEmpty()) {
docTitle = MultiProtocolURI.unescape(location.getFileName());
}
final CharBuffer writer = new CharBuffer(odtParser.MAX_DOCSIZE);
diff --git a/source/net/yacy/document/parser/torrentParser.java b/source/net/yacy/document/parser/torrentParser.java
index 51c5556ae..339946d83 100644
--- a/source/net/yacy/document/parser/torrentParser.java
+++ b/source/net/yacy/document/parser/torrentParser.java
@@ -92,7 +92,7 @@ public class torrentParser extends AbstractParser implements Parser {
final BObject nameo = info.get("name");
if (nameo != null) title = UTF8.String(nameo.getString());
}
- if (title == null || title.length() == 0) title = MultiProtocolURI.unescape(location.getFileName());
+ if (title == null || title.isEmpty()) title = MultiProtocolURI.unescape(location.getFileName());
return new Document[]{new Document(
location,
mimeType,
diff --git a/source/net/yacy/document/parser/vcfParser.java b/source/net/yacy/document/parser/vcfParser.java
index 138359fb5..b1d6936bd 100644
--- a/source/net/yacy/document/parser/vcfParser.java
+++ b/source/net/yacy/document/parser/vcfParser.java
@@ -89,7 +89,7 @@ public class vcfParser extends AbstractParser implements Parser {
}
if (line == null) break;
- else if (line.length() == 0) continue;
+ else if (line.isEmpty()) continue;
lineNr++;
final int pos = line.indexOf(':',0);
diff --git a/source/net/yacy/kelondro/blob/ArrayStack.java b/source/net/yacy/kelondro/blob/ArrayStack.java
index 2af1e674e..4ede3318d 100644
--- a/source/net/yacy/kelondro/blob/ArrayStack.java
+++ b/source/net/yacy/kelondro/blob/ArrayStack.java
@@ -311,7 +311,7 @@ public class ArrayStack implements BLOB {
}
public synchronized File unmountOldest() {
- if (this.blobs.size() == 0) return null;
+ if (this.blobs.isEmpty()) return null;
if (System.currentTimeMillis() - this.blobs.get(0).creation.getTime() < this.fileAgeLimit) return null;
final File f = this.blobs.get(0).location;
unmountBLOB(f, false);
@@ -557,7 +557,7 @@ public class ArrayStack implements BLOB {
* @return the blobItem that holds the key or null if no blobItem is found
*/
private blobItem keeperOf(final byte[] key) {
- if (this.blobs.size() == 0) return null;
+ if (this.blobs.isEmpty()) return null;
if (this.blobs.size() == 1) {
final blobItem bi = this.blobs.get(0);
if (bi.blob.containsKey(key)) return bi;
@@ -628,7 +628,7 @@ public class ArrayStack implements BLOB {
*/
@Override
public byte[] get(final byte[] key) throws IOException, RowSpaceExceededException {
- if (this.blobs == null || this.blobs.size() == 0) return null;
+ if (this.blobs == null || this.blobs.isEmpty()) return null;
if (this.blobs.size() == 1) {
final blobItem bi = this.blobs.get(0);
return bi.blob.get(key);
@@ -835,7 +835,7 @@ public class ArrayStack implements BLOB {
@Override
public synchronized void delete(final byte[] key) throws IOException {
final long m = mem();
- if (this.blobs.size() == 0) {
+ if (this.blobs.isEmpty()) {
// do nothing
} else if (this.blobs.size() == 1) {
final blobItem bi = this.blobs.get(0);
diff --git a/source/net/yacy/kelondro/blob/BEncodedHeap.java b/source/net/yacy/kelondro/blob/BEncodedHeap.java
index 86d64d94f..1cfa67742 100644
--- a/source/net/yacy/kelondro/blob/BEncodedHeap.java
+++ b/source/net/yacy/kelondro/blob/BEncodedHeap.java
@@ -233,7 +233,7 @@ public class BEncodedHeap implements MapStore {
*/
@Override
public boolean isEmpty() {
- return this.table.size() == 0;
+ return this.table.isEmpty();
}
/**
@@ -646,7 +646,7 @@ public class BEncodedHeap implements MapStore {
* @return a list of column names
*/
public ArrayList<String> columns() {
- if ( this.columnames.size() == 0 ) {
+ if ( this.columnames.isEmpty() ) {
for ( final Map.Entry<byte[], Map<String, byte[]>> row : this ) {
this.columnames.addAll(row.getValue().keySet());
}
diff --git a/source/net/yacy/kelondro/blob/MapHeap.java b/source/net/yacy/kelondro/blob/MapHeap.java
index b28de4b07..9df9b3858 100644
--- a/source/net/yacy/kelondro/blob/MapHeap.java
+++ b/source/net/yacy/kelondro/blob/MapHeap.java
@@ -130,7 +130,7 @@ public class MapHeap implements Map<byte[], Map<String, String>> {
while ((line = br.readLine()) != null) { // very slow readLine????
line = line.trim();
if (line.equals("# EOF")) return map;
- if ((line.length() == 0) || (line.charAt(0) == '#')) continue;
+ if ((line.isEmpty()) || (line.charAt(0) == '#')) continue;
pos = line.indexOf('=');
if (pos < 0) continue;
map.put(line.substring(0, pos), line.substring(pos + 1));
diff --git a/source/net/yacy/kelondro/blob/Tables.java b/source/net/yacy/kelondro/blob/Tables.java
index 73b263845..99aacd43c 100644
--- a/source/net/yacy/kelondro/blob/Tables.java
+++ b/source/net/yacy/kelondro/blob/Tables.java
@@ -369,7 +369,7 @@ public class Tables implements Iterable<String> {
public RowIterator(final String table, final String whereColumn, final Pattern wherePattern) throws IOException {
this.whereColumn = whereColumn;
this.whereValue = null;
- this.wherePattern = wherePattern == null || wherePattern.toString().length() == 0 ? null : wherePattern;
+ this.wherePattern = wherePattern == null || wherePattern.toString().isEmpty() ? null : wherePattern;
final BEncodedHeap heap = getHeap(table);
this.i = heap.iterator();
}
@@ -384,7 +384,7 @@ public class Tables implements Iterable<String> {
public RowIterator(final String table, final Pattern pattern) throws IOException {
this.whereColumn = null;
this.whereValue = null;
- this.wherePattern = pattern == null || pattern.toString().length() == 0 ? null : pattern;
+ this.wherePattern = pattern == null || pattern.toString().isEmpty() ? null : pattern;
final BEncodedHeap heap = getHeap(table);
this.i = heap.iterator();
}
diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.java
index c038e10f5..9ed2163f4 100644
--- a/source/net/yacy/kelondro/data/meta/DigestURI.java
+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java
@@ -86,7 +86,7 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
for (String h: hs) {
if (h == null) continue;
h = h.trim();
- if (h.length() == 0) continue;
+ if (h.isEmpty()) continue;
h = hosthash(h);
if (h == null || h.length() != 6) continue;
sb.append(h);
@@ -95,7 +95,7 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
}
public static Set<String> hosthashess(String hosthashes) {
- if (hosthashes == null || hosthashes.length() == 0) return null;
+ if (hosthashes == null || hosthashes.isEmpty()) return null;
HashSet<String> h = new HashSet<String>();
assert hosthashes.length() % 6 == 0;
for (int i = 0; i < hosthashes.length(); i = i + 6) {
@@ -222,7 +222,7 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
// find rootpath
int rootpathStart = 0;
int rootpathEnd = this.path.length() - 1;
- if (this.path.length() > 0 && this.path.charAt(0) == '/')
+ if (!this.path.isEmpty() && this.path.charAt(0) == '/')
rootpathStart = 1;
if (this.path.endsWith("/"))
rootpathEnd = this.path.length() - 2;
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
index e110337cb..5593fd602 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -548,12 +548,12 @@ public class URIMetadataNode /*extends URIReferenceNode implements URIMetadata*/
public String dc_publisher() { return this.dc_publisher; }
public String dc_subject() { return this.dc_subject; }
public float lat() {
- if (this.latlon == null || this.latlon.length() == 0) return 0.0f;
+ if (this.latlon == null || this.latlon.isEmpty()) return 0.0f;
final int p = this.latlon.indexOf(',');
return p < 0 ? 0.0f : Float.parseFloat(this.latlon.substring(0, p));
}
public float lon() {
- if (this.latlon == null || this.latlon.length() == 0) return 0.0f;
+ if (this.latlon == null || this.latlon.isEmpty()) return 0.0f;
final int p = this.latlon.indexOf(',');
return p < 0 ? 0.0f : Float.parseFloat(this.latlon.substring(p + 1));
}
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
index 21d4e156b..572af984c 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
@@ -264,7 +264,7 @@ public class URIMetadataRow implements URIMetadata {
this.entry.setCol(col_size, Integer.parseInt(prop.getProperty("size", "0")));
this.entry.setCol(col_wc, Integer.parseInt(prop.getProperty("wc", "0")));
final String dt = prop.getProperty("dt", "t");
- this.entry.setCol(col_dt, dt.length() > 0 ? new byte[]{(byte) dt.charAt(0)} : new byte[]{(byte) 't'});
+ this.entry.setCol(col_dt, dt.isEmpty() ? new byte[]{(byte) 't'} : new byte[]{(byte) dt.charAt(0)});
final String flags = prop.getProperty("flags", "AAAAAA");
this.entry.setCol(col_flags, (flags.length() > 6) ? QueryParams.empty_constraint.bytes() : (new Bitfield(4, flags)).bytes());
this.entry.setCol(col_lang, UTF8.getBytes(prop.getProperty("lang", "uk")));
@@ -285,7 +285,7 @@ public class URIMetadataRow implements URIMetadata {
}
public static URIMetadataRow importEntry(final String propStr) {
- if (propStr == null || (propStr.length() > 0 && propStr.charAt(0) != '{') || !propStr.endsWith("}")) {
+ if (propStr == null || (!propStr.isEmpty() && propStr.charAt(0) != '{') || !propStr.endsWith("}")) {
return null;
}
try {
@@ -670,12 +670,12 @@ public class URIMetadataRow implements URIMetadata {
public String dc_publisher() { return this.dc_publisher; }
public String dc_subject() { return this.dc_subject; }
public double lat() {
- if (this.latlon == null || this.latlon.length() == 0) return 0.0d;
+ if (this.latlon == null || this.latlon.isEmpty()) return 0.0d;
final int p = this.latlon.indexOf(',');
return p < 0 ? 0.0f : Double.parseDouble(this.latlon.substring(0, p));
}
public double lon() {
- if (this.latlon == null || this.latlon.length() == 0) return 0.0d;
+ if (this.latlon == null || this.latlon.isEmpty()) return 0.0d;
final int p = this.latlon.indexOf(',');
return p < 0 ? 0.0f : Double.parseDouble(this.latlon.substring(p + 1));
}
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java b/source/net/yacy/kelondro/data/word/WordReferenceFactory.java
index c70b17f54..382400673 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceFactory.java
@@ -129,11 +129,11 @@ public class WordReferenceFactory implements ReferenceFactory<WordReference>, Se
String dom, url;
Set<String> peers;
StringBuilder urlsb;
- while ((ci.length() >= 13) && (ci.byteAt(6) == ':')) {
+ while (ci.length() >= 13 && ci.byteAt(6) == ':') {
assert ci.length() >= 6 : "ci.length() = " + ci.length();
dom = ci.toStringBuilder(0, 6, 6).toString();
ci.trim(7);
- while ((ci.length() > 0) && (ci.byteAt(0) != ',')) {
+ while (!ci.isEmpty() && ci.byteAt(0) != ',') {
assert ci.length() >= 6 : "ci.length() = " + ci.length();
urlsb = ci.toStringBuilder(0, 6, 12);
urlsb.append(dom);
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceVars.java b/source/net/yacy/kelondro/data/word/WordReferenceVars.java
index 11c4641fd..bdd623836 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceVars.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceVars.java
@@ -101,7 +101,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
this.lother = outlinksOther;
this.phrasesintext = phrasecount;
this.positions = new LinkedBlockingQueue<Integer>();
- if (ps.size() > 0) for (final Integer i: ps) this.positions.add(i);
+ if (!ps.isEmpty()) for (final Integer i: ps) this.positions.add(i);
this.posinphrase = posinphrase;
this.posofphrase = posofphrase;
this.urlcomps = urlComps;
@@ -124,7 +124,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
this.lother = e.lother();
this.phrasesintext = e.phrasesintext();
this.positions = new LinkedBlockingQueue<Integer>();
- if (e.positions().size() > 0) for (final Integer i: e.positions()) this.positions.add(i);
+ if (!e.positions().isEmpty()) for (final Integer i: e.positions()) this.positions.add(i);
this.posinphrase = e.posinphrase();
this.posofphrase = e.posofphrase();
this.urlcomps = e.urlcomps();
diff --git a/source/net/yacy/kelondro/index/BufferedObjectIndex.java b/source/net/yacy/kelondro/index/BufferedObjectIndex.java
index 38b418b1b..6708e0311 100644
--- a/source/net/yacy/kelondro/index/BufferedObjectIndex.java
+++ b/source/net/yacy/kelondro/index/BufferedObjectIndex.java
@@ -71,7 +71,7 @@ public class BufferedObjectIndex implements Index, Iterable<Row.Entry> {
}
private final void flushBuffer() throws IOException, RowSpaceExceededException {
- if (this.buffer.size() > 0) {
+ if (!this.buffer.isEmpty()) {
for (final Row.Entry e: this.buffer) {
this.backend.put(e);
}
diff --git a/source/net/yacy/kelondro/index/Column.java b/source/net/yacy/kelondro/index/Column.java
index a8e4800f9..09dd1015d 100644
--- a/source/net/yacy/kelondro/index/Column.java
+++ b/source/net/yacy/kelondro/index/Column.java
@@ -68,7 +68,7 @@ public final class Column implements Cloneable, Serializable {
// cut quotes etc.
celldef = celldef.trim();
- if (celldef.length() > 0 && celldef.charAt(0) == '<') celldef = celldef.substring(1);
+ if (!celldef.isEmpty() && celldef.charAt(0) == '<') celldef = celldef.substring(1);
if (celldef.endsWith(">")) celldef = celldef.substring(0, celldef.length() - 1);
// parse type definition
@@ -166,7 +166,7 @@ public final class Column implements Cloneable, Serializable {
) throw new kelondroException("kelondroColumn - cell width " + this.cellwidth + " not appropriate for type " + typename);
*/
// parse/check encoder type
- if (celldef.length() > 0 && celldef.charAt(0) == '{') {
+ if (!celldef.isEmpty() && celldef.charAt(0) == '{') {
p = celldef.indexOf('}');
final String expf = celldef.substring(1, p);
celldef = celldef.substring(p + 1).trim();
@@ -188,7 +188,7 @@ public final class Column implements Cloneable, Serializable {
assert (this.celltype != celltype_cardinal) || (this.encoder == encoder_b64e) || (this.encoder == encoder_b256);
// parse/check description
- if (celldef.length() > 0 && celldef.charAt(0) == '"') {
+ if (!celldef.isEmpty() && celldef.charAt(0) == '"') {
p = celldef.indexOf('"', 1);
this.description = celldef.substring(1, p);
//unused: celldef = celldef.substring(p + 1).trim();
diff --git a/source/net/yacy/kelondro/index/Row.java b/source/net/yacy/kelondro/index/Row.java
index 242da3d5f..4e87035fd 100644
--- a/source/net/yacy/kelondro/index/Row.java
+++ b/source/net/yacy/kelondro/index/Row.java
@@ -286,7 +286,7 @@ public final class Row implements Serializable {
public Entry(String external, final boolean decimalCardinal) {
// parse external form
- if (external.length() > 0 && external.charAt(0) == '{') external = external.substring(1, external.length() - 1);
+ if (!external.isEmpty() && external.charAt(0) == '{') external = external.substring(1, external.length() - 1);
//final String[] elts = commaPattern.split(external);
final StringTokenizer st = new StringTokenizer(external, ",");
if (Row.this.nickref == null) genNickRef();
diff --git a/source/net/yacy/kelondro/io/AbstractWriter.java b/source/net/yacy/kelondro/io/AbstractWriter.java
index a1e5d1192..8da31bcda 100644
--- a/source/net/yacy/kelondro/io/AbstractWriter.java
+++ b/source/net/yacy/kelondro/io/AbstractWriter.java
@@ -129,7 +129,7 @@ public abstract class AbstractWriter extends AbstractReader implements Writer {
while ((line = br.readLine()) != null) { // very slow readLine????
line = line.trim();
if ("# EOF".equals(line)) return map;
- if ((line.length() == 0) || (line.charAt(0) == '#')) continue;
+ if ((line.isEmpty()) || (line.charAt(0) == '#')) continue;
pos = line.indexOf('=');
if (pos < 0) continue;
map.put(line.substring(0, pos), line.substring(pos + 1));
diff --git a/source/net/yacy/kelondro/io/CharBuffer.java b/source/net/yacy/kelondro/io/CharBuffer.java
index 128581cfa..401e2da83 100644
--- a/source/net/yacy/kelondro/io/CharBuffer.java
+++ b/source/net/yacy/kelondro/io/CharBuffer.java
@@ -108,6 +108,10 @@ public final class CharBuffer extends Writer {
return this.length;
}
+ public boolean isEmpty() {
+ return this.length == 0;
+ }
+
private void grow(int minSize) {
int newsize = 12 * Math.max(this.buffer.length, minSize) / 10; // grow by 20%
char[] tmp = new char[newsize];
diff --git a/source/net/yacy/kelondro/logging/ThreadDump.java b/source/net/yacy/kelondro/logging/ThreadDump.java
index 6ed2571c7..956bbd96d 100644
--- a/source/net/yacy/kelondro/logging/ThreadDump.java
+++ b/source/net/yacy/kelondro/logging/ThreadDump.java
@@ -242,7 +242,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
} else {
line = null;
}
- if ((line != null) && (line.length() > 0)) {
+ if (line != null && !line.isEmpty()) {
bufferappend(sb, plain, tracename + "at " + CharacterCoding.unicode2html(ste.toString(), true) + " [" + line.trim() + "]");
} else {
bufferappend(sb, plain, tracename + "at " + CharacterCoding.unicode2html(ste.toString(), true));
diff --git a/source/net/yacy/kelondro/order/Base64Order.java b/source/net/yacy/kelondro/order/Base64Order.java
index ae0603de0..b8a04edfe 100644
--- a/source/net/yacy/kelondro/order/Base64Order.java
+++ b/source/net/yacy/kelondro/order/Base64Order.java
@@ -265,7 +265,7 @@ public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Com
}
public final byte[] decode(String in) {
- if ((in == null) || (in.length() == 0)) return new byte[0];
+ if ((in == null) || (in.isEmpty())) return new byte[0];
try {
int posIn = 0;
int posOut = 0;
diff --git a/source/net/yacy/kelondro/rwi/AbstractReference.java b/source/net/yacy/kelondro/rwi/AbstractReference.java
index 35cde10bb..96f93485e 100644
--- a/source/net/yacy/kelondro/rwi/AbstractReference.java
+++ b/source/net/yacy/kelondro/rwi/AbstractReference.java
@@ -40,8 +40,8 @@ public abstract class AbstractReference implements Reference {
}
protected static int max(Collection<Integer> a, Collection<Integer> b) {
- if (a == null || a.size() == 0) return max(b);
- if (b == null || b.size() == 0) return max(a);
+ if (a == null || a.isEmpty()) return max(b);
+ if (b == null || b.isEmpty()) return max(a);
int ma = max(a);
int mb = max(b);
if (ma == Integer.MIN_VALUE) return mb;
@@ -51,8 +51,8 @@ public abstract class AbstractReference implements Reference {
protected static int min(Collection<Integer> a, Collection<Integer> b) {
assert a != null;
- if (a == null || a.size() == 0) return min(b);
- if (b == null || b.size() == 0) return min(a);
+ if (a == null || a.isEmpty()) return min(b);
+ if (b == null || b.isEmpty()) return min(a);
int ma = min(a);
int mb = min(b);
if (ma == Integer.MAX_VALUE) return mb;
@@ -61,7 +61,7 @@ public abstract class AbstractReference implements Reference {
}
private static int max(Collection<Integer> a) {
- if (a == null || a.size() == 0) return Integer.MIN_VALUE;
+ if (a == null || a.isEmpty()) return Integer.MIN_VALUE;
Iterator<Integer> i = a.iterator();
if (a.size() == 1) return i.next();
if (a.size() == 2) return Math.max(i.next(), i.next());
@@ -75,7 +75,7 @@ public abstract class AbstractReference implements Reference {
}
private static int min(Collection<Integer> a) {
- if (a == null || a.size() == 0) return Integer.MAX_VALUE;
+ if (a == null || a.isEmpty()) return Integer.MAX_VALUE;
Iterator<Integer> i = a.iterator();
if (a.size() == 1) return i.next();
if (a.size() == 2) return Math.min(i.next(), i.next());
diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
index 35becf2a9..f904e4dee 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
@@ -271,7 +271,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
@Override
public boolean hasNext() {
- if (this.rot) return this.cachecopy.size() > 0;
+ if (this.rot) return !this.cachecopy.isEmpty();
return this.p < this.cachecopy.size();
}
@@ -366,7 +366,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
@Override
public boolean hasNext() {
- if (this.rot) return this.cachecounts.size() > 0;
+ if (this.rot) return !this.cachecounts.isEmpty();
return this.p < this.cachecounts.size();
}
diff --git a/source/net/yacy/kelondro/table/Table.java b/source/net/yacy/kelondro/table/Table.java
index fe1388fe3..ee92b70dd 100644
--- a/source/net/yacy/kelondro/table/Table.java
+++ b/source/net/yacy/kelondro/table/Table.java
@@ -1031,7 +1031,7 @@ public class Table implements Index, Iterable<Row.Entry> {
}
private static String[] permutations(final String source) {
- if (source.length() == 0) return new String[0];
+ if (source.isEmpty()) return new String[0];
if (source.length() == 1) return new String[]{source};
final char c = source.charAt(0);
final String[] recres = permutations(source.substring(1));
diff --git a/source/net/yacy/kelondro/util/ByteBuffer.java b/source/net/yacy/kelondro/util/ByteBuffer.java
index efd6af2b8..bc6630619 100644
--- a/source/net/yacy/kelondro/util/ByteBuffer.java
+++ b/source/net/yacy/kelondro/util/ByteBuffer.java
@@ -131,6 +131,10 @@ public final class ByteBuffer extends OutputStream {
public int length() {
return this.length;
}
+
+ public boolean isEmpty() {
+ return this.length == 0;
+ }
private void grow() {
int newsize = this.buffer.length * 2 + 1;
diff --git a/source/net/yacy/kelondro/util/FileUtils.java b/source/net/yacy/kelondro/util/FileUtils.java
index 52721dd28..d31d2fd02 100644
--- a/source/net/yacy/kelondro/util/FileUtils.java
+++ b/source/net/yacy/kelondro/util/FileUtils.java
@@ -637,7 +637,7 @@ public final class FileUtils
while ( li.hasNext() ) {
int pos = 0;
line = li.next().trim();
- if ( line.length() > 0 && line.charAt(0) == '#' ) {
+ if ( !line.isEmpty() && line.charAt(0) == '#' ) {
continue; // exclude comments
}
do {
@@ -751,7 +751,7 @@ public final class FileUtils
// Read the List
String line = "";
while ( (line = br.readLine()) != null ) {
- if ( line.length() == 0 ) {
+ if ( line.isEmpty() ) {
continue;
}
if ( line.charAt(0) != '#' || withcomments ) {
@@ -899,7 +899,7 @@ public final class FileUtils
if (this.reader != null) try {
while ( (this.nextLine = this.reader.readLine()) != null ) {
this.nextLine = this.nextLine.trim();
- if ( this.nextLine.length() > 0 ) {
+ if ( !this.nextLine.isEmpty() ) {
break;
}
}
@@ -1003,7 +1003,7 @@ public final class FileUtils
final File tempFile =
File.createTempFile(
parserClassName + "_" + ((idx > -1) ? fileName.substring(0, idx) : fileName),
- (fileExt.length() > 0) ? "." + fileExt : fileExt);
+ (!fileExt.isEmpty()) ? "." + fileExt : fileExt);
return tempFile;
}
diff --git a/source/net/yacy/kelondro/util/ReverseMapIterator.java b/source/net/yacy/kelondro/util/ReverseMapIterator.java
index cc590b5c0..509d7a68a 100644
--- a/source/net/yacy/kelondro/util/ReverseMapIterator.java
+++ b/source/net/yacy/kelondro/util/ReverseMapIterator.java
@@ -54,7 +54,7 @@ public class ReverseMapIterator <E, F> implements Iterator<Map.Entry<E, F>> {
}
public boolean hasNext() {
- return a.size() > 0;
+ return !a.isEmpty();
}
public Map.Entry<E, F> next() {
diff --git a/source/net/yacy/kelondro/util/SetTools.java b/source/net/yacy/kelondro/util/SetTools.java
index 6f34a9b74..43f225c56 100644
--- a/source/net/yacy/kelondro/util/SetTools.java
+++ b/source/net/yacy/kelondro/util/SetTools.java
@@ -485,7 +485,7 @@ public final class SetTools {
int pos;
while ((line = br.readLine()) != null) {
line = line.trim();
- if ((line.length() > 0 && line.charAt(0) != '#') && ((pos = line.indexOf(sep)) > 0))
+ if ((!line.isEmpty() && line.charAt(0) != '#') && ((pos = line.indexOf(sep)) > 0))
map.put(line.substring(0, pos).trim().toLowerCase(), line.substring(pos + sep.length()).trim());
}
} catch (final IOException e) {
@@ -504,7 +504,7 @@ public final class SetTools {
int pos;
while ((line = br.readLine()) != null) {
line = line.trim();
- if ((line.length() > 0 && line.charAt(0) != '#') && ((pos = line.indexOf(sep)) > 0)) {
+ if ((!line.isEmpty() && line.charAt(0) != '#') && ((pos = line.indexOf(sep)) > 0)) {
key = line.substring(0, pos).trim().toLowerCase();
value = line.substring(pos + sep.length()).trim();
if (!map.containsKey(key)) map.put(key, new ArrayList<String>());
@@ -528,7 +528,7 @@ public final class SetTools {
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
- if (line.length() > 0 && line.charAt(0) != '#') list.add(line.trim().toLowerCase());
+ if (!line.isEmpty() && line.charAt(0) != '#') list.add(line.trim().toLowerCase());
}
br.close();
} catch (final IOException e) {
diff --git a/source/net/yacy/peers/Network.java b/source/net/yacy/peers/Network.java
index 27e81ff30..946cce7bc 100644
--- a/source/net/yacy/peers/Network.java
+++ b/source/net/yacy/peers/Network.java
@@ -711,7 +711,7 @@ public class Network
}
public static boolean changeSeedUploadMethod(final String method) {
- if ( method == null || method.length() == 0 ) {
+ if ( method == null || method.isEmpty() ) {
return false;
}
@@ -772,7 +772,7 @@ public class Network
DigestURI seedURL;
try {
final String seedURLStr = sb.peers.mySeed().get(Seed.SEEDLISTURL, "");
- if ( seedURLStr.length() == 0 ) {
+ if ( seedURLStr.isEmpty() ) {
throw new MalformedURLException("The seed-file url must not be empty.");
}
if ( !(seedURLStr.toLowerCase().startsWith("http://") || seedURLStr.toLowerCase().startsWith(
diff --git a/source/net/yacy/peers/NewsDB.java b/source/net/yacy/peers/NewsDB.java
index 82502db3a..4355c7d96 100644
--- a/source/net/yacy/peers/NewsDB.java
+++ b/source/net/yacy/peers/NewsDB.java
@@ -324,7 +324,7 @@ public class NewsDB {
public String attribute(final String key, final String dflt) {
final String s = this.attributes.get(key);
- if ((s == null) || (s.length() == 0)) return dflt;
+ if ((s == null) || (s.isEmpty())) return dflt;
return s;
}
}
diff --git a/source/net/yacy/peers/PeerActions.java b/source/net/yacy/peers/PeerActions.java
index 198eb6da5..78b5755c5 100644
--- a/source/net/yacy/peers/PeerActions.java
+++ b/source/net/yacy/peers/PeerActions.java
@@ -226,7 +226,7 @@ public class PeerActions {
private void processPeerArrival(final Seed peer) {
final String recordString = peer.get("news", null);
//System.out.println("### triggered news arrival from peer " + peer.getName() + ", news " + ((recordString == null) ? "empty" : "attached"));
- if ((recordString == null) || (recordString.length() == 0)) return;
+ if ((recordString == null) || (recordString.isEmpty())) return;
final String decodedString = de.anomic.tools.crypt.simpleDecode(recordString);
final NewsDB.Record record = this.newsPool.parseExternal(decodedString);
if (record != null) {
diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.java
index b8c366bbd..552848693 100644
--- a/source/net/yacy/peers/Protocol.java
+++ b/source/net/yacy/peers/Protocol.java
@@ -1206,7 +1206,7 @@ public final class Protocol
targetSeed.hash));
uhss = uhss.trim();
- if ( uhss.length() == 0 || uhss.equals(",") ) {
+ if ( uhss.isEmpty() || uhss.equals(",") ) {
return null;
} // all url's known, we are ready here
@@ -1595,7 +1595,7 @@ public final class Protocol
}
final String authenticationMethod =
env.getConfig("network.unit.protocol.request.authentication.method", "");
- if ( authenticationMethod.length() == 0 ) {
+ if ( authenticationMethod.isEmpty() ) {
return false;
}
if ( authenticationMethod.equals("salted-magic-sim") ) {
diff --git a/source/net/yacy/peers/RemoteSearch.java b/source/net/yacy/peers/RemoteSearch.java
index 74ece99b4..a6d8f6094 100644
--- a/source/net/yacy/peers/RemoteSearch.java
+++ b/source/net/yacy/peers/RemoteSearch.java
@@ -84,7 +84,7 @@ public class RemoteSearch extends Thread {
final RankingProfile rankingProfile,
final Bitfield constraint) {
super(ysThreadGroup, "yacySearch_" + targetPeer.getName());
- //System.out.println("DEBUG - yacySearch thread " + this.getName() + " initialized " + ((urlhashes.length() == 0) ? "(primary)" : "(secondary)"));
+ //System.out.println("DEBUG - yacySearch thread " + this.getName() + " initialized " + ((urlhashes.isEmpty()) ? "(primary)" : "(secondary)"));
assert wordhashes.length() >= 12;
this.wordhashes = wordhashes;
this.excludehashes = excludehashes;
diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.java
index a47c6b77b..27ce23723 100644
--- a/source/net/yacy/peers/Seed.java
+++ b/source/net/yacy/peers/Seed.java
@@ -306,7 +306,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
*/
public final String getIP() {
final String ip = get(Seed.IP, Domains.LOCALHOST);
- return (ip == null || ip.length() == 0) ? Domains.LOCALHOST : ip;
+ return (ip == null || ip.isEmpty()) ? Domains.LOCALHOST : ip;
}
/**
@@ -965,15 +965,15 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
if ( seedStr == null ) {
throw new IOException("seedStr == null");
}
- if ( seedStr.length() == 0 ) {
- throw new IOException("seedStr.length() == 0");
+ if ( seedStr.isEmpty() ) {
+ throw new IOException("seedStr.isEmpty()");
}
final String seed = crypt.simpleDecode(seedStr);
if ( seed == null ) {
throw new IOException("seed == null");
}
- if ( seed.length() == 0 ) {
- throw new IOException("seed.length() == 0");
+ if ( seed.isEmpty() ) {
+ throw new IOException("seed.isEmpty()");
}
// extract hash
@@ -1040,7 +1040,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
// seedURL
final String seedURL = this.dna.get(SEEDLISTURL);
- if ( seedURL != null && seedURL.length() > 0 ) {
+ if ( seedURL != null && !seedURL.isEmpty() ) {
if ( !seedURL.startsWith("http://") && !seedURL.startsWith("https://") ) {
return "wrong protocol for seedURL";
}
@@ -1062,7 +1062,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
if ( ipString == null ) {
return ipString + " -> IP is null";
}
- if ( ipString.length() > 0 && ipString.length() < 8 ) {
+ if ( !ipString.isEmpty() && ipString.length() < 8 ) {
return ipString + " -> IP is too short: ";
}
if ( Switchboard.getSwitchboard().isAllIPMode() ) {
diff --git a/source/net/yacy/peers/SeedDB.java b/source/net/yacy/peers/SeedDB.java
index 605fbeadd..c7a537f9e 100644
--- a/source/net/yacy/peers/SeedDB.java
+++ b/source/net/yacy/peers/SeedDB.java
@@ -246,7 +246,7 @@ public final class SeedDB implements AlternativeDomainNames {
if (sizeConnected() == 0) try {Thread.sleep(5000);} catch (final InterruptedException e) {} // wait for init
initMySeed();
// check if my seed has an IP assigned
- if (myIP() == null || myIP().length() == 0) {
+ if (myIP() == null || myIP().isEmpty()) {
this.mySeed.setIP(Domains.myPublicLocalIP().getHostAddress());
}
}
@@ -376,7 +376,7 @@ public final class SeedDB implements AlternativeDomainNames {
// address has therefore the form
// address ::= (<peername>'.yacy'|<peerhexhash>'.yacyh'){'='<ip>{':'<port}}
// clusterdef ::= {address}{','address}*
- final String[] addresses = (clusterdefinition.length() == 0) ? new String[0] : clusterdefinition.split(",");
+ final String[] addresses = (clusterdefinition.isEmpty()) ? new String[0] : clusterdefinition.split(",");
final TreeMap<byte[], String> clustermap = new TreeMap<byte[], String>(Base64Order.enhancedCoder);
Seed seed;
String hash, yacydom, ipport;
@@ -557,7 +557,7 @@ public final class SeedDB implements AlternativeDomainNames {
}
private Seed get(final String hash, final MapDataMining database) {
- if (hash == null || hash.length() == 0) return null;
+ if (hash == null || hash.isEmpty()) return null;
if ((this.mySeed != null) && (hash.equals(this.mySeed.hash))) return this.mySeed;
final ConcurrentHashMap<String, String> entry = new ConcurrentHashMap<String, String>();
try {
diff --git a/source/net/yacy/peers/graphics/WebStructureGraph.java b/source/net/yacy/peers/graphics/WebStructureGraph.java
index 7424b7f5a..1a1a0068c 100644
--- a/source/net/yacy/peers/graphics/WebStructureGraph.java
+++ b/source/net/yacy/peers/graphics/WebStructureGraph.java
@@ -171,7 +171,7 @@ public class WebStructureGraph
}
}
final leanrefObject lro = new leanrefObject(url, globalRefURLs);
- if ( globalRefURLs.size() > 0 ) {
+ if ( !globalRefURLs.isEmpty() ) {
try {
if ( this.publicRefDNSResolvingWorker.isAlive() ) {
this.publicRefDNSResolvingQueue.put(lro);
@@ -291,10 +291,10 @@ public class WebStructureGraph
final String key = tailMap.firstKey();
if ( key.startsWith(hosthash) ) {
ref = UTF8.String(tailMap.get(key));
- if ( hostname.length() == 0 ) {
+ if ( hostname.isEmpty() ) {
hostname = key.substring(7);
}
- if ( date.length() == 0 ) {
+ if ( date.isEmpty() ) {
date = ref.substring(0, 8);
}
h.putAll(refstr2map(ref));
@@ -765,9 +765,9 @@ public class WebStructureGraph
+ " entries");
final long time = System.currentTimeMillis();
joinOldNew();
- if ( this.structure_old.size() > 0 ) {
+ if ( !this.structure_old.isEmpty() ) {
synchronized ( this.structure_old ) {
- if ( this.structure_old.size() > 0 ) {
+ if ( !this.structure_old.isEmpty() ) {
FileUtils
.saveMapB(
this.structureFile,
diff --git a/source/net/yacy/peers/operation/yacySeedUploadFile.java b/source/net/yacy/peers/operation/yacySeedUploadFile.java
index 930ec81d9..7c1da9a1e 100644
--- a/source/net/yacy/peers/operation/yacySeedUploadFile.java
+++ b/source/net/yacy/peers/operation/yacySeedUploadFile.java
@@ -41,7 +41,7 @@ public class yacySeedUploadFile implements yacySeedUploader {
String seedFilePath = "";
try {
seedFilePath = sb.getConfig(CONFIG_FILE_PATH,"");
- if (seedFilePath.length() == 0) throw new Exception("Path to seed file is not configured properly");
+ if (seedFilePath.isEmpty()) throw new Exception("Path to seed file is not configured properly");
final File publicSeedFile = new File(seedFilePath);
Files.copy(seedFile,publicSeedFile);
diff --git a/source/net/yacy/peers/operation/yacySeedUploadScp.java b/source/net/yacy/peers/operation/yacySeedUploadScp.java
index b29ad4a4f..7afd42b1a 100644
--- a/source/net/yacy/peers/operation/yacySeedUploadScp.java
+++ b/source/net/yacy/peers/operation/yacySeedUploadScp.java
@@ -63,15 +63,15 @@ public class yacySeedUploadScp implements yacySeedUploader {
final String seedScpPassword = sb.getConfig(CONFIG_SCP_PASSWORD,null);
final String seedScpPath = sb.getConfig(CONFIG_SCP_PATH,null);
- if (seedScpServer == null || seedScpServer.length() == 0)
+ if (seedScpServer == null || seedScpServer.isEmpty())
throw new Exception("Seed SCP upload settings not configured properly. Servername must not be null or empty.");
- else if (seedScpAccount == null || seedScpAccount.length() == 0)
+ else if (seedScpAccount == null || seedScpAccount.isEmpty())
throw new Exception("Seed SCP upload settings not configured properly. Username must not be null or empty.");
- else if (seedScpPassword == null || seedScpPassword.length() == 0)
+ else if (seedScpPassword == null || seedScpPassword.isEmpty())
throw new Exception("Seed SCP upload settings not configured properly. Password must not be null or empty.");
- else if (seedScpPath == null || seedScpPath.length() == 0)
+ else if (seedScpPath == null || seedScpPath.isEmpty())
throw new Exception("Seed SCP upload settings not configured properly. File path must not be null or empty.");
- else if (seedScpServerPort == null || seedScpServerPort.length() == 0)
+ else if (seedScpServerPort == null || seedScpServerPort.isEmpty())
throw new Exception("Seed SCP upload settings not configured properly. Server port must not be null or empty.");
int port = 22;
try {
diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java
index 750ab6abf..c17724fbb 100644
--- a/source/net/yacy/repository/Blacklist.java
+++ b/source/net/yacy/repository/Blacklist.java
@@ -282,11 +282,11 @@ public class Blacklist {
throw new IllegalArgumentException("path may not be null");
}
- final String p = (path.length() > 0 && path.charAt(0) == '/') ? path.substring(1) : path;
+ final String p = (!path.isEmpty() && path.charAt(0) == '/') ? path.substring(1) : path;
final Map<String, List<Pattern>> blacklistMap = getBlacklistMap(blacklistType, isMatchable(host));
// avoid PatternSyntaxException e
- final String h = ((!isMatchable(host) && host.length() > 0 && host.charAt(0) == '*') ? "." + host : host).toLowerCase();
+ final String h = ((!isMatchable(host) && !host.isEmpty() && host.charAt(0) == '*') ? "." + host : host).toLowerCase();
List<Pattern> hostList;
if (!(blacklistMap.containsKey(h) && ((hostList = blacklistMap.get(h)) != null))) {
@@ -316,7 +316,7 @@ public class Blacklist {
final Map<String, List<Pattern>> blacklistMap = getBlacklistMap(blacklistType, isMatchable(host));
// avoid PatternSyntaxException e
- final String h = ((!isMatchable(host) && host.length() > 0 && host.charAt(0) == '*') ? "." + host : host).toLowerCase();
+ final String h = ((!isMatchable(host) && !host.isEmpty() && host.charAt(0) == '*') ? "." + host : host).toLowerCase();
final List<Pattern> hostList = blacklistMap.get(h);
if (hostList != null) {
@@ -382,7 +382,7 @@ public class Blacklist {
// getting the proper blacklist
final Map<String, List<Pattern>> blacklistMapMatched = getBlacklistMap(blacklistType, true);
- final String p = (path.length() > 0 && path.charAt(0) == '/') ? path.substring(1) : path;
+ final String p = (!path.isEmpty() && path.charAt(0) == '/') ? path.substring(1) : path;
List<Pattern> app;
boolean matched = false;
@@ -478,7 +478,7 @@ public class Blacklist {
}
// in host-part only full sub-domains may be wildcards
- if (host.length() > 0 && i > -1) {
+ if (!host.isEmpty() && i > -1) {
if (!(i == 0 || i == host.length() - 1)) {
return BlacklistError.WILDCARD_BEGIN_OR_END;
}
diff --git a/source/net/yacy/repository/FilterEngine.java b/source/net/yacy/repository/FilterEngine.java
index 6de0251bb..62b17af11 100644
--- a/source/net/yacy/repository/FilterEngine.java
+++ b/source/net/yacy/repository/FilterEngine.java
@@ -81,7 +81,7 @@ public class FilterEngine {
final String path = entry.substring(pos + 1).trim();
// avoid PatternSyntaxException e
- if (!isMatchable(host) && host.length() > 0 && host.charAt(0) == '*')
+ if (!isMatchable(host) && !host.isEmpty() && host.charAt(0) == '*')
host = "." + host;
if(isMatchable(host)) {
diff --git a/source/net/yacy/repository/LoaderDispatcher.java b/source/net/yacy/repository/LoaderDispatcher.java
index 0a219d93e..28361c1e8 100644
--- a/source/net/yacy/repository/LoaderDispatcher.java
+++ b/source/net/yacy/repository/LoaderDispatcher.java
@@ -92,7 +92,7 @@ public final class LoaderDispatcher {
}
public boolean isSupportedProtocol(final String protocol) {
- if ((protocol == null) || (protocol.length() == 0)) return false;
+ if ((protocol == null) || (protocol.isEmpty())) return false;
return this.supportedProtocols.contains(protocol.trim().toLowerCase());
}
diff --git a/source/net/yacy/search/EventTracker.java b/source/net/yacy/search/EventTracker.java
index 131205078..6ae7965bc 100644
--- a/source/net/yacy/search/EventTracker.java
+++ b/source/net/yacy/search/EventTracker.java
@@ -99,7 +99,7 @@ public class EventTracker {
if (history.size() % 10 == 0) { // check again
Event e;
final long now = System.currentTimeMillis();
- while (history.size() > 0) {
+ while (!history.isEmpty()) {
e = history.peek();
if (now - e.time < maxQueueAge) break;
history.poll();
diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java
index 46e0472b0..f9f507da3 100644
--- a/source/net/yacy/search/Switchboard.java
+++ b/source/net/yacy/search/Switchboard.java
@@ -1008,7 +1008,7 @@ public final class Switchboard extends serverSwitch
// load network configuration into settings
String networkUnitDefinition =
getConfig("network.unit.definition", "defaults/yacy.network.freeworld.unit");
- if (networkUnitDefinition.length() == 0) networkUnitDefinition = "defaults/yacy.network.freeworld.unit"; // patch for a strange failure case where the path was overwritten by empty string
+ if (networkUnitDefinition.isEmpty()) networkUnitDefinition = "defaults/yacy.network.freeworld.unit"; // patch for a strange failure case where the path was overwritten by empty string
// patch old values
if ( networkUnitDefinition.equals("yacy.network.unit") ) {
@@ -1451,7 +1451,7 @@ public final class Switchboard extends serverSwitch
}
public RankingProfile getRanking() {
- return (getConfig("rankingProfile", "").length() == 0)
+ return (getConfig("rankingProfile", "").isEmpty())
? new RankingProfile(Classification.ContentDomain.TEXT)
: new RankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", "")));
}
@@ -1902,7 +1902,7 @@ public final class Switchboard extends serverSwitch
// set a random password if no password is configured
if ( getConfigBool("adminAccountForLocalhost", false)
- && getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").length() == 0 ) {
+ && getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty() ) {
// make a 'random' password
setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "0000" + this.genRandomPassword());
setConfig("adminAccount", "");
@@ -2876,7 +2876,7 @@ public final class Switchboard extends serverSwitch
return false;
}
final String refererHost = requestHeader.refererHost();
- return refererHost == null || refererHost.length() == 0 || Domains.isLocalhost(refererHost);
+ return refererHost == null || refererHost.isEmpty() || Domains.isLocalhost(refererHost);
}
/**
@@ -2895,7 +2895,7 @@ public final class Switchboard extends serverSwitch
// authorization in case that there is no account stored
final String adminAccountBase64MD5 = getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");
- if ( adminAccountBase64MD5.length() == 0 ) {
+ if ( adminAccountBase64MD5.isEmpty() ) {
return 2; // no password stored; this should not happen for older peers
}
@@ -2925,7 +2925,7 @@ public final class Switchboard extends serverSwitch
}
// authorization with admin keyword in configuration
- if ( realmValue == null || realmValue.length() == 0 ) {
+ if ( realmValue == null || realmValue.isEmpty() ) {
return 1;
}
if ( adminAccountBase64MD5.equals(Digest.encodeMD5Hex(realmValue)) ) {
@@ -3366,7 +3366,7 @@ public final class Switchboard extends serverSwitch
break;
}
seedListFileURL = sb.getConfig("network.unit.bootstrap.seedlist" + c, "");
- if ( seedListFileURL.length() == 0 ) {
+ if ( seedListFileURL.isEmpty() ) {
break;
}
c++;
diff --git a/source/net/yacy/search/index/MetadataRepository.java b/source/net/yacy/search/index/MetadataRepository.java
index 5ffb187ee..adc76f637 100644
--- a/source/net/yacy/search/index/MetadataRepository.java
+++ b/source/net/yacy/search/index/MetadataRepository.java
@@ -595,8 +595,8 @@ public final class MetadataRepository implements /*Metadata,*/ Iterable<byte[]>
pw.println("<item>");
pw.println("<title>" + CharacterCoding.unicode2xml(entry.dc_title(), true) + "</title>");
pw.println("<link>" + MultiProtocolURI.escape(url) + "</link>");
- if (entry.dc_creator().length() > 0) pw.println("<author>" + CharacterCoding.unicode2xml(entry.dc_creator(), true) + "</author>");
- if (entry.dc_subject().length() > 0) pw.println("<description>" + CharacterCoding.unicode2xml(entry.dc_subject(), true) + "</description>");
+ if (!entry.dc_creator().isEmpty()) pw.println("<author>" + CharacterCoding.unicode2xml(entry.dc_creator(), true) + "</author>");
+ if (!entry.dc_subject().isEmpty()) pw.println("<description>" + CharacterCoding.unicode2xml(entry.dc_subject(), true) + "</description>");
pw.println("<pubDate>" + entry.moddate().toString() + "</pubDate>");
pw.println("<yacy:size>" + entry.size() + "</yacy:size>");
pw.println("<guid isPermaLink=\"false\">" + ASCII.String(entry.hash()) + "</guid>");
diff --git a/source/net/yacy/search/index/SolrConfiguration.java b/source/net/yacy/search/index/SolrConfiguration.java
index a526b107f..553027ceb 100644
--- a/source/net/yacy/search/index/SolrConfiguration.java
+++ b/source/net/yacy/search/index/SolrConfiguration.java
@@ -92,11 +92,11 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable
}
protected void addSolr(final SolrDoc solrdoc, final SolrField key, final String value) {
- if ((isEmpty() || contains(key.name())) && (!this.lazy || (value != null && value.length() > 0))) solrdoc.addSolr(key, value);
+ if ((isEmpty() || contains(key.name())) && (!this.lazy || (value != null && !value.isEmpty()))) solrdoc.addSolr(key, value);
}
protected void addSolr(final SolrDoc solrdoc, final SolrField key, final String value, final float boost) {
- if ((isEmpty() || contains(key.name())) && (!this.lazy || (value != null && value.length() > 0))) solrdoc.addSolr(key, value, boost);
+ if ((isEmpty() || contains(key.name())) && (!this.lazy || (value != null && !value.isEmpty()))) solrdoc.addSolr(key, value, boost);
}
protected void addSolr(final SolrDoc solrdoc, final SolrField key, final Date value) {
@@ -225,9 +225,10 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable
if (robots_meta.indexOf("nofollow",0) >= 0) b += 8; // set bit 3
}
String x_robots_tag = header.get(HeaderFramework.X_ROBOTS_TAG, "");
- if (x_robots_tag.length() == 0) x_robots_tag = header.get(HeaderFramework.X_ROBOTS, "");
- // this tag may have values: noarchive, nosnippet, noindex, unavailable_after
- if (x_robots_tag.length() > 0) {
+ if (x_robots_tag.isEmpty()) {
+ x_robots_tag = header.get(HeaderFramework.X_ROBOTS, "");
+ } else {
+ // this tag may have values: noarchive, nosnippet, noindex, unavailable_after
if (x_robots_tag.indexOf("noarchive",0) >= 0) b += 256; // set bit 8
if (x_robots_tag.indexOf("nosnippet",0) >= 0) b += 512; // set bit 9
if (x_robots_tag.indexOf("noindex",0) >= 0) b += 1024; // set bit 10
diff --git a/source/net/yacy/search/query/AccessTracker.java b/source/net/yacy/search/query/AccessTracker.java
index 7533bfb33..80b54b91a 100644
--- a/source/net/yacy/search/query/AccessTracker.java
+++ b/source/net/yacy/search/query/AccessTracker.java
@@ -69,9 +69,9 @@ public class AccessTracker {
list.add(query);
// shrink dump list but keep essentials in dump
- while (list.size() > maxSize || (list.size() > 0 && MemoryControl.shortStatus())) {
+ while (list.size() > maxSize || (!list.isEmpty() && MemoryControl.shortStatus())) {
synchronized (list) {
- if (list.size() > 0) addToDump(list.removeFirst()); else break;
+ if (!list.isEmpty()) addToDump(list.removeFirst()); else break;
}
}
@@ -80,7 +80,7 @@ public class AccessTracker {
// if the list is large we look for too old entries
final long timeout = System.currentTimeMillis() - maxAge;
- while (list.size() > 0) {
+ while (!list.isEmpty()) {
final QueryParams q = list.getFirst();
if (q.starttime > timeout) break;
addToDump(list.removeFirst());
@@ -101,7 +101,7 @@ public class AccessTracker {
private static void addToDump(final QueryParams query) {
//if (query.resultcount == 0) return;
- if (query.queryString == null || query.queryString.length() == 0) return;
+ if (query.queryString == null || query.queryString.isEmpty()) return;
final StringBuilder sb = new StringBuilder(40);
sb.append(GenericFormatter.SHORT_SECOND_FORMATTER.format(new Date(query.starttime)));
sb.append(' ');
@@ -112,7 +112,7 @@ public class AccessTracker {
}
public static void dumpLog(final File file) {
- while (localSearches.size() > 0) {
+ while (!localSearches.isEmpty()) {
addToDump(localSearches.removeFirst());
}
RandomAccessFile raf = null;
diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.java
index 0663bc45c..652bcb91f 100644
--- a/source/net/yacy/search/query/QueryParams.java
+++ b/source/net/yacy/search/query/QueryParams.java
@@ -235,7 +235,7 @@ public final class QueryParams {
this.query_include_hashes = queryHashes;
this.query_exclude_hashes = excludeHashes;
this.query_all_hashes = fullqueryHashes;
- this.tenant = (tenant != null && tenant.length() == 0) ? null : tenant;
+ this.tenant = (tenant != null && tenant.isEmpty()) ? null : tenant;
this.modifier = new Modifier(modifier == null ? "" : modifier);
this.ranking = ranking;
this.maxDistance = maxDistance;
@@ -264,7 +264,7 @@ public final class QueryParams {
this.constraint = constraint;
this.allofconstraint = allofconstraint;
this.sitehash = site; assert site == null || site.length() == 6;
- this.siteexcludes = siteexcludes != null && siteexcludes.size() == 0 ? null: siteexcludes;
+ this.siteexcludes = siteexcludes != null && siteexcludes.isEmpty() ? null: siteexcludes;
this.authorhash = authorhash; assert authorhash == null || !authorhash.isEmpty();
this.snippetCacheStrategy = snippetCacheStrategy;
this.host = host;
diff --git a/source/net/yacy/search/query/RWIProcess.java b/source/net/yacy/search/query/RWIProcess.java
index 7c5f3041b..b7ec216c6 100644
--- a/source/net/yacy/search/query/RWIProcess.java
+++ b/source/net/yacy/search/query/RWIProcess.java
@@ -370,7 +370,7 @@ public final class RWIProcess extends Thread
// check vocabulary constraint
String subject = YaCyMetadata.hashURI(iEntry.urlhash());
Resource resource = JenaTripleStore.getResource(subject);
- if (this.query.metatags != null && this.query.metatags.size() > 0) {
+ if (this.query.metatags != null && !this.query.metatags.isEmpty()) {
// all metatags must appear in the tags list
for (Tagging.Metatag metatag: this.query.metatags) {
Iterator<RDFNode> ni = JenaTripleStore.getObjects(resource, metatag.getPredicate());
@@ -509,7 +509,7 @@ public final class RWIProcess extends Thread
while ( ((!feedingIsFinished() && this.addRunning) || this.stack.sizeQueue() > 0) &&
(this.query.itemsPerPage < 1 ||
loops++ < this.query.itemsPerPage ||
- (loops > 1000 && this.doubleDomCache.size() > 0)) ) {
+ (loops > 1000 && !this.doubleDomCache.isEmpty())) ) {
if ( waitingtime <= 0 ) {
rwi = this.addRunning ? this.stack.poll(waitingtime) : this.stack.poll();
} else {
diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.java
index 4578b379c..bb7121845 100644
--- a/source/net/yacy/search/query/SearchEvent.java
+++ b/source/net/yacy/search/query/SearchEvent.java
@@ -684,7 +684,7 @@ public final class SearchEvent
}
urls = entry.getValue();
words = wordsFromPeer(peer, urls);
- if ( words.size() == 0 ) {
+ if ( words.isEmpty() ) {
continue; // ???
}
Log.logInfo("SearchEvent.SecondarySearchSuperviser", "asking peer " + peer + " for urls: " + urls + " from words: " + words);
diff --git a/source/net/yacy/search/query/SnippetProcess.java b/source/net/yacy/search/query/SnippetProcess.java
index 8c4f40a22..46e569abf 100644
--- a/source/net/yacy/search/query/SnippetProcess.java
+++ b/source/net/yacy/search/query/SnippetProcess.java
@@ -497,7 +497,7 @@ public class SnippetProcess {
if (this.solr != null) {
SolrDocument sd = null;
final SolrDocumentList sdl = this.solr.get(SolrField.id.getSolrFieldName()+ ":" + ASCII.String(page.hash()), 0, 1);
- if (sdl.size() > 0) {
+ if (!sdl.isEmpty()) {
sd = sdl.get(0);
}
if (sd != null) {
diff --git a/source/net/yacy/search/ranking/BlockRank.java b/source/net/yacy/search/ranking/BlockRank.java
index 421e7e25d..7ea68f3d1 100644
--- a/source/net/yacy/search/ranking/BlockRank.java
+++ b/source/net/yacy/search/ranking/BlockRank.java
@@ -109,7 +109,7 @@ public class BlockRank {
@Override
public void run() {
final ReferenceContainerCache<HostReference> partialIndex = Protocol.loadIDXHosts(this.seed);
- if (partialIndex == null || partialIndex.size() == 0) return;
+ if (partialIndex == null || partialIndex.isEmpty()) return;
Log.logInfo("BlockRank", "loaded " + partialIndex.size() + " host indexes from peer " + this.seed.getName());
try {
this.index.merge(partialIndex);
@@ -168,7 +168,7 @@ public class BlockRank {
HostStat hostStat;
int hostCount;
for (final ReferenceContainer<HostReference> container: index) {
- if (container.size() == 0) continue;
+ if (container.isEmpty()) continue;
if (referenceTable == null) {
hostStat = hostHashResolver.get(ASCII.String(container.getTermHash()));
hostCount = hostStat == null ? 6 /* high = a penalty for 'i do not know this', this may not be fair*/ : Math.max(1, hostStat.count);
@@ -191,12 +191,12 @@ public class BlockRank {
final List<BinSearch> table = new ArrayList<BinSearch>();
while (hostScore.size() > 10) {
final List<byte[]> smallest = hostScore.lowerHalf();
- if (smallest.size() == 0) break; // should never happen but this ensures termination of the loop
+ if (smallest.isEmpty()) break; // should never happen but this ensures termination of the loop
Log.logInfo("BlockRank", "index evaluation: computed partition of size " + smallest.size());
table.add(new BinSearch(smallest, 6));
for (final byte[] host: smallest) hostScore.delete(host);
}
- if (hostScore.size() > 0) {
+ if (!hostScore.isEmpty()) {
final ArrayList<byte[]> list = new ArrayList<byte[]>();
for (final byte[] entry: hostScore) list.add(entry);
Log.logInfo("BlockRank", "index evaluation: computed last partition of size " + list.size());
diff --git a/source/net/yacy/search/ranking/RankingProfile.java b/source/net/yacy/search/ranking/RankingProfile.java
index b9e0bad64..42700c6dd 100644
--- a/source/net/yacy/search/ranking/RankingProfile.java
+++ b/source/net/yacy/search/ranking/RankingProfile.java
@@ -210,7 +210,7 @@ public class RankingProfile {
public Map<String, String> preToExternalMap(final String prefix) {
final Map<String, String> ext = new LinkedHashMap<String, String>(40);
- if (prefix.length() == 0) {
+ if (prefix.isEmpty()) {
ext.put(APPEMPH, Integer.toString(this.coeff_appemph));
ext.put(APPURL, Integer.toString(this.coeff_appurl));
ext.put(APP_DC_CREATOR, Integer.toString(this.coeff_app_dc_creator));
@@ -276,7 +276,7 @@ public class RankingProfile {
public Map<String, String> postToExternalMap(final String prefix) {
final Map<String, String> ext = new LinkedHashMap<String, String>();
- if (prefix.length() == 0) {
+ if (prefix.isEmpty()) {
ext.put(URLCOMPINTOPLIST, Integer.toString(this.coeff_urlcompintoplist));
ext.put(DESCRCOMPINTOPLIST, Integer.toString(this.coeff_descrcompintoplist));
ext.put(PREFER, Integer.toString(this.coeff_prefer));
diff --git a/source/net/yacy/search/snippet/MediaSnippet.java b/source/net/yacy/search/snippet/MediaSnippet.java
index cdbb2805d..b2409d734 100644
--- a/source/net/yacy/search/snippet/MediaSnippet.java
+++ b/source/net/yacy/search/snippet/MediaSnippet.java
@@ -81,8 +81,8 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaS
this.height = NumberTools.parseIntDecSubstring(attr, p + 3);
}
this.ranking = ranking; // the smaller the better! small values should be shown first
- if ((this.name == null) || (this.name.length() == 0)) this.name = "_";
- if ((this.attr == null) || (this.attr.length() == 0)) this.attr = "_";
+ if ((this.name == null) || (this.name.isEmpty())) this.name = "_";
+ if ((this.attr == null) || (this.attr.isEmpty())) this.attr = "_";
}
public MediaSnippet(final ContentDomain type, final DigestURI href, final String mime, final String name, final long fileSize, final int width, final int height, final long ranking, final DigestURI source) {
@@ -96,8 +96,8 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaS
this.width = width;
this.height = height;
this.ranking = ranking; // the smaller the better! small values should be shown first
- if ((this.name == null) || (this.name.length() == 0)) this.name = "_";
- if ((this.attr == null) || (this.attr.length() == 0)) this.attr = "_";
+ if ((this.name == null) || (this.name.isEmpty())) this.name = "_";
+ if ((this.attr == null) || (this.attr.isEmpty())) this.attr = "_";
}
private int hashCache = Integer.MIN_VALUE; // if this is used in a compare method many times, a cache is useful
diff --git a/source/net/yacy/search/snippet/TextSnippet.java b/source/net/yacy/search/snippet/TextSnippet.java
index be561a482..c2ec5a252 100644
--- a/source/net/yacy/search/snippet/TextSnippet.java
+++ b/source/net/yacy/search/snippet/TextSnippet.java
@@ -205,7 +205,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
removeMatchingHashes(row.dc_subject(), remainingHashes);
removeMatchingHashes(row.url().toNormalform(true, true).replace('-', ' '), remainingHashes);
- if (remainingHashes.size() == 0) {
+ if (remainingHashes.isEmpty()) {
// the snippet is fully inside the metadata!
if (de.anomic.crawler.Cache.has(url.hash())) {
@@ -308,11 +308,11 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
//String imageline = computeMediaSnippet(document.getAudiolinks(), queryhashes);
snippetLine = "";
- //if (audioline != null) line += (line.length() == 0) ? audioline : "<br />" + audioline;
- //if (videoline != null) line += (line.length() == 0) ? videoline : "<br />" + videoline;
- //if (appline != null) line += (line.length() == 0) ? appline : "<br />" + appline;
- //if (hrefline != null) line += (line.length() == 0) ? hrefline : "<br />" + hrefline;
- if (textline != null) snippetLine += (snippetLine.length() == 0) ? textline : "<br />" + textline;
+ //if (audioline != null) line += (line.isEmpty()) ? audioline : "<br />" + audioline;
+ //if (videoline != null) line += (line.isEmpty()) ? videoline : "<br />" + videoline;
+ //if (appline != null) line += (line.isEmpty()) ? appline : "<br />" + appline;
+ //if (hrefline != null) line += (line.isEmpty()) ? hrefline : "<br />" + hrefline;
+ if (textline != null) snippetLine += (snippetLine.isEmpty()) ? textline : "<br />" + textline;
if (snippetLine == null || !remainingHashes.isEmpty()) {
init(url.hash(), null, ResultClass.ERROR_NO_MATCH, "no matching snippet found");
diff --git a/source/net/yacy/upnp/Discovery.java b/source/net/yacy/upnp/Discovery.java
index 74629837e..4259650a6 100644
--- a/source/net/yacy/upnp/Discovery.java
+++ b/source/net/yacy/upnp/Discovery.java
@@ -156,7 +156,7 @@ public class Discovery {
}
private static UPNPRootDevice[] discoverDevices( int timeOut, int ttl, int mx, String searchTarget, NetworkInterface ni ) throws IOException {
- if ( searchTarget == null || searchTarget.trim().length() == 0 ) {
+ if ( searchTarget == null || searchTarget.trim().isEmpty() ) {
throw new IllegalArgumentException( "Illegal searchTarget" );
}
diff --git a/source/net/yacy/upnp/DiscoveryAdvertisement.java b/source/net/yacy/upnp/DiscoveryAdvertisement.java
index f04eaf9c8..e926fdf98 100644
--- a/source/net/yacy/upnp/DiscoveryAdvertisement.java
+++ b/source/net/yacy/upnp/DiscoveryAdvertisement.java
@@ -291,7 +291,7 @@ public class DiscoveryAdvertisement implements Runnable
log.debug(received);
}
String ntsField = msg.getHTTPHeaderField("nts");
- if ( ntsField == null || ntsField.trim().length() == 0 ) {
+ if ( ntsField == null || ntsField.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'ntsField' field");
}
@@ -299,7 +299,7 @@ public class DiscoveryAdvertisement implements Runnable
}
if ( ntsField.equals(NTS_SSDP_ALIVE) ) {
String deviceDescrLoc = msg.getHTTPHeaderField("location");
- if ( deviceDescrLoc == null || deviceDescrLoc.trim().length() == 0 ) {
+ if ( deviceDescrLoc == null || deviceDescrLoc.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'location' field");
}
@@ -320,21 +320,21 @@ public class DiscoveryAdvertisement implements Runnable
}
String nt = msg.getHTTPHeaderField("nt");
- if ( nt == null || nt.trim().length() == 0 ) {
+ if ( nt == null || nt.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'nt' field");
}
return;
}
String maxAge = msg.getHTTPFieldElement("Cache-Control", "max-age");
- if ( maxAge == null || maxAge.trim().length() == 0 ) {
+ if ( maxAge == null || maxAge.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'max-age' field");
}
return;
}
String usn = msg.getHTTPHeaderField("usn");
- if ( usn == null || usn.trim().length() == 0 ) {
+ if ( usn == null || usn.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'usn' field");
}
@@ -363,14 +363,14 @@ public class DiscoveryAdvertisement implements Runnable
}
} else if ( ntsField.equals(NTS_SSDP_BYE_BYE) ) {
String usn = msg.getHTTPHeaderField("usn");
- if ( usn == null || usn.trim().length() == 0 ) {
+ if ( usn == null || usn.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'usn' field");
}
return;
}
String nt = msg.getHTTPHeaderField("nt");
- if ( nt == null || nt.trim().length() == 0 ) {
+ if ( nt == null || nt.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) {
log.debug("Skipping SSDP message, missing HTTP header 'nt' field");
}
diff --git a/source/net/yacy/upnp/DiscoveryListener.java b/source/net/yacy/upnp/DiscoveryListener.java
index 28cce2229..358a93020 100644
--- a/source/net/yacy/upnp/DiscoveryListener.java
+++ b/source/net/yacy/upnp/DiscoveryListener.java
@@ -234,7 +234,7 @@ public void run() {
if ( header != null && header.startsWith( "HTTP/1.1 200 OK" ) && msg.getHTTPHeaderField( "st" ) != null ) {
// probably a search repsonse !
String deviceDescrLoc = msg.getHTTPHeaderField( "location" );
- if( deviceDescrLoc == null || deviceDescrLoc.trim().length() == 0 ) {
+ if( deviceDescrLoc == null || deviceDescrLoc.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) log.debug( "Skipping SSDP message, missing HTTP header 'location' field" );
return;
}
@@ -251,22 +251,22 @@ public void run() {
}
if ( log.isDebugEnabled() ) log.debug( "Processing " + deviceDescrLoc + " device description location" );
String st = msg.getHTTPHeaderField( "st" );
- if( st == null || st.trim().length() == 0 ) {
+ if( st == null || st.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) log.debug( "Skipping SSDP message, missing HTTP header 'st' field" );
return;
}
String usn = msg.getHTTPHeaderField( "usn" );
- if( usn == null || usn.trim().length() == 0 ) {
+ if( usn == null || usn.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) log.debug( "Skipping SSDP message, missing HTTP header 'usn' field" );
return;
}
String maxAge = msg.getHTTPFieldElement( "Cache-Control", "max-age" );
- if( maxAge == null || maxAge.trim().length() == 0 ) {
+ if( maxAge == null || maxAge.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) log.debug( "Skipping SSDP message, missing HTTP header 'max-age' field" );
return;
}
String server = msg.getHTTPHeaderField( "server" );
- if( server == null || server.trim().length() == 0 ) {
+ if( server == null || server.trim().isEmpty() ) {
if ( log.isDebugEnabled() ) log.debug( "Skipping SSDP message, missing HTTP header 'server' field" );
return;
}
diff --git a/source/net/yacy/upnp/HttpResponse.java b/source/net/yacy/upnp/HttpResponse.java
index ad3df87ce..1e3a5c1ae 100644
--- a/source/net/yacy/upnp/HttpResponse.java
+++ b/source/net/yacy/upnp/HttpResponse.java
@@ -68,7 +68,7 @@ public class HttpResponse {
* @throws IllegalArgumentException if some error occurs during parsing
*/
protected HttpResponse( String rawHttpResponse ) throws IllegalArgumentException {
- if ( rawHttpResponse == null || rawHttpResponse.trim().length() == 0 ) {
+ if ( rawHttpResponse == null || rawHttpResponse.trim().isEmpty() ) {
throw new IllegalArgumentException( "Empty HTTP response message" );
}
boolean bodyParsing = false;
@@ -80,7 +80,7 @@ public class HttpResponse {
for ( int i = 1; i < lines.length; i++ ) {
String line = lines[i];
- if ( line.length() == 0 ) {
+ if ( line.isEmpty() ) {
// line break before body
bodyParsing = true;
} else if ( bodyParsing ) {
diff --git a/source/net/yacy/upnp/devices/UPNPRootDevice.java b/source/net/yacy/upnp/devices/UPNPRootDevice.java
index 4b0bfd9ed..aa21b67b3 100644
--- a/source/net/yacy/upnp/devices/UPNPRootDevice.java
+++ b/source/net/yacy/upnp/devices/UPNPRootDevice.java
@@ -312,7 +312,7 @@ public class UPNPRootDevice extends UPNPDevice {
private String getMandatoryData( JXPathContext ctx, String ctxFieldName ) {
String value = (String)ctx.getValue( ctxFieldName );
- if ( value != null && value.length() == 0 ) {
+ if ( value != null && value.isEmpty() ) {
throw new JXPathException( "Mandatory field " + ctxFieldName + " not provided, uncompliant UPNP device !!" );
}
return value;
@@ -322,7 +322,7 @@ public class UPNPRootDevice extends UPNPDevice {
String value = null;
try {
value = (String)ctx.getValue( ctxFieldName );
- if ( value != null && value.length() == 0 ) {
+ if ( value != null && value.isEmpty() ) {
value = null;
}
} catch ( JXPathException ex ) {
@@ -402,7 +402,7 @@ public class UPNPRootDevice extends UPNPDevice {
*/
public final static URL getURL( String url, URL baseURL ) throws MalformedURLException {
URL rtrVal;
- if ( url == null || url.trim().length() == 0 ) return null;
+ if ( url == null || url.trim().isEmpty() ) return null;
try {
rtrVal = new URL( url );
} catch ( MalformedURLException malEx ) {
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index bb9287898..aa0fa5119 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -353,7 +353,7 @@ public final class yacy {
final boolean browserPopUpTrigger = sb.getConfig(SwitchboardConstants.BROWSER_POP_UP_TRIGGER, "true").equals("true");
if (browserPopUpTrigger) try {
final String browserPopUpPage = sb.getConfig(SwitchboardConstants.BROWSER_POP_UP_PAGE, "ConfigBasic.html");
- //boolean properPW = (sb.getConfig("adminAccount", "").length() == 0) && (sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() > 0);
+ //boolean properPW = (sb.getConfig("adminAccount", "").isEmpty()) && (sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() > 0);
//if (!properPW) browserPopUpPage = "ConfigBasic.html";
Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage);
} catch (final Throwable e) {