Skip to content

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

applied code changes that are recommended by PMD

orbiterdd459281c8c1
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index a6a168383..860fbabfe 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -388,7 +388,7 @@ public class Blacklist_p {
final String nextEntry = sortedlist[j];
if (nextEntry.length() == 0) continue;
- if (nextEntry.startsWith("#")) continue;
+ if (nextEntry.charAt(0) == '#') continue;
prop.put(DISABLED + EDIT + "Itemlist_" + entryCount + "_dark", dark ? "1" : "0");
dark = !dark;
prop.putHTML(DISABLED + EDIT + "Itemlist_" + entryCount + "_item", nextEntry);
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index 3040df7ce..37f1e1a90 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -327,7 +327,7 @@ public class BlogComments {
private static void messageForwardingViaEmail(final Switchboard sb, final messageBoard.entry msgEntry) {
try {
- if (!Boolean.valueOf(sb.getConfig("msgForwardingEnabled","false")).booleanValue()) return;
+ if (!Boolean.parseBoolean(sb.getConfig("msgForwardingEnabled","false"))) return;
// get the recipient address
final String sendMailTo = sb.getConfig("msgForwardingTo","root@localhost").trim();
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index 3407b23cc..7a4d61fe5 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -313,7 +313,7 @@ public class Bookmarks {
tagCount=0;
while (tagsIt.hasNext()) {
final String tname = tagsIt.next();
- if ((!tname.startsWith("/")) && (!tname.equals(""))) {
+ if (!tname.isEmpty() && tname.charAt(0) != '/') {
prop.putHTML("display_bookmarks_"+count+"_tags_"+tagCount+"_tag", tname);
tagCount++;
}
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index 58084f8e5..004bc6bf3 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -175,7 +175,7 @@ public class ConfigBasic {
}
if (post.get("usecase", "").equals("intranet")) {
String repositoryPath = post.get("repositoryPath", "/DATA/HTROOT/repository");
- File repository = (repositoryPath.startsWith("/") || repositoryPath.charAt(1) == ':') ? new File(repositoryPath) : new File(sb.getRootPath(), repositoryPath);
+ File repository = ((repositoryPath.length() > 0 && repositoryPath.charAt(0) == '/') || (repositoryPath.length() > 1 && repositoryPath.charAt(1) == ':')) ? new File(repositoryPath) : new File(sb.getRootPath(), repositoryPath);
if (repository.exists() && repository.isDirectory()) {
sb.setConfig("repositoryPath", repositoryPath);
}
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index a6b557b43..d7c4ab758 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -237,7 +237,7 @@ public class ConfigNetwork_p {
input = input.replace(' ', ',');
input = input.replace(' ', ';');
input = input.replaceAll(",,", ",");
- if (input.startsWith(",")) input = input.substring(1);
+ if (input.length() > 0 && input.charAt(0) == ',') input = input.substring(1);
if (input.endsWith(",")) input = input.substring(0, input.length() - 1);
return input;
}
diff --git a/htroot/CrawlProfileEditor_p.java b/htroot/CrawlProfileEditor_p.java
index 1bdf37ce6..d15ffeb98 100644
--- a/htroot/CrawlProfileEditor_p.java
+++ b/htroot/CrawlProfileEditor_p.java
@@ -207,7 +207,7 @@ public class CrawlProfileEditor_p {
prop.put("edit_entries_" + count + "_readonly_label", ee.label);
prop.put("edit_entries_" + count + "_readonly_type", ee.type);
if (ee.type == eentry.BOOLEAN) {
- prop.put("edit_entries_" + count + "_readonly_type_checked", Boolean.valueOf(val).booleanValue() ? "1" : "0");
+ prop.put("edit_entries_" + count + "_readonly_type_checked", Boolean.parseBoolean(val) ? "1" : "0");
} else {
prop.put("edit_entries_" + count + "_readonly_type_value", val);
}
@@ -228,7 +228,7 @@ public class CrawlProfileEditor_p {
prop.put("crawlProfiles_" + count + "_depth", profile.depth());
prop.put("crawlProfiles_" + count + "_mustmatch", profile.mustMatchPattern().toString());
prop.put("crawlProfiles_" + count + "_mustnotmatch", profile.mustNotMatchPattern().toString());
- prop.put("crawlProfiles_" + count + "_crawlingIfOlder", (profile.recrawlIfOlder() == 0L) ? "no re-crawl" : ""+ DateFormat.getDateTimeInstance().format(profile.recrawlIfOlder()));
+ prop.put("crawlProfiles_" + count + "_crawlingIfOlder", (profile.recrawlIfOlder() == 0L) ? "no re-crawl" : DateFormat.getDateTimeInstance().format(profile.recrawlIfOlder()));
prop.put("crawlProfiles_" + count + "_crawlingDomFilterDepth", (profile.domFilterDepth() == Integer.MAX_VALUE) ? "inactive" : Integer.toString(profile.domFilterDepth()));
// start contrib [MN]
@@ -245,7 +245,7 @@ public class CrawlProfileEditor_p {
prop.put("crawlProfiles_"+count+"_crawlingDomFilterContent", i);
// end contrib [MN]
- prop.put("crawlProfiles_" + count + "_crawlingDomMaxPages", (profile.domMaxPages() == Integer.MAX_VALUE) ? "unlimited" : ""+profile.domMaxPages());
+ prop.put("crawlProfiles_" + count + "_crawlingDomMaxPages", (profile.domMaxPages() == Integer.MAX_VALUE) ? "unlimited" : Integer.toString(profile.domMaxPages()));
prop.put("crawlProfiles_" + count + "_withQuery", (profile.crawlingQ()) ? "1" : "0");
prop.put("crawlProfiles_" + count + "_storeCache", (profile.storeHTCache()) ? "1" : "0");
prop.put("crawlProfiles_" + count + "_indexText", (profile.indexText()) ? "1" : "0");
diff --git a/htroot/IndexCleaner_p.java b/htroot/IndexCleaner_p.java
index 2452dbf71..45384d7ba 100755
--- a/htroot/IndexCleaner_p.java
+++ b/htroot/IndexCleaner_p.java
@@ -96,14 +96,14 @@ public class IndexCleaner_p {
prop.put("urldb_lastBlacklistedHash", urldbCleanerThread.lastBlacklistedHash);
prop.putHTML("urldb_lastUrl", urldbCleanerThread.lastUrl);
prop.put("urldb_lastHash", urldbCleanerThread.lastHash);
- prop.put("urldb_threadAlive", urldbCleanerThread.isAlive() + "");
+ prop.put("urldb_threadAlive", Boolean.toString(urldbCleanerThread.isAlive()));
prop.put("urldb_threadToString", urldbCleanerThread.toString());
final double percent = ((double)urldbCleanerThread.blacklistedUrls/urldbCleanerThread.totalSearchedUrls)*100;
prop.putNum("urldb_percent", percent);
}
if (indexCleanerThread!=null) {
prop.put("rwidb", "1");
- prop.put("rwidb_threadAlive", indexCleanerThread.isAlive() + "");
+ prop.put("rwidb_threadAlive", Boolean.toString(indexCleanerThread.isAlive()));
prop.put("rwidb_threadToString", indexCleanerThread.toString());
prop.putNum("rwidb_RWIcountstart", indexCleanerThread.rwiCountAtStart);
prop.putNum("rwidb_RWIcountnow", indexCleanerThread.rwisize());
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index f7f9442ce..6b3319f1e 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -337,7 +337,7 @@ public class IndexControlURLs_p {
prop.put("genUrlProfile_referrer", (le == null) ? 0 : 1);
prop.putHTML("genUrlProfile_referrer_url", (le == null) ? "<unknown>" : le.metadata().url().toNormalform(false, true));
prop.put("genUrlProfile_referrer_hash", (le == null) ? "" : le.hash());
- prop.put("genUrlProfile_doctype", ""+entry.doctype());
+ prop.put("genUrlProfile_doctype", String.valueOf(entry.doctype()));
prop.put("genUrlProfile_language", entry.language());
prop.put("genUrlProfile_size", entry.size());
prop.put("genUrlProfile_wordCount", entry.wordCount());
diff --git a/htroot/IndexCreateWWWGlobalQueue_p.java b/htroot/IndexCreateWWWGlobalQueue_p.java
index 9d51f277b..c4d4dc05d 100644
--- a/htroot/IndexCreateWWWGlobalQueue_p.java
+++ b/htroot/IndexCreateWWWGlobalQueue_p.java
@@ -58,7 +58,7 @@ public class IndexCreateWWWGlobalQueue_p {
if (post != null) {
if (post.containsKey("limit")) {
try {
- showLimit = Integer.valueOf(post.get("limit")).intValue();
+ showLimit = Integer.parseInt(post.get("limit"));
} catch (final NumberFormatException e) {}
}
diff --git a/htroot/IndexCreateWWWLocalQueue_p.java b/htroot/IndexCreateWWWLocalQueue_p.java
index cda9df442..097b39066 100644
--- a/htroot/IndexCreateWWWLocalQueue_p.java
+++ b/htroot/IndexCreateWWWLocalQueue_p.java
@@ -73,7 +73,7 @@ public class IndexCreateWWWLocalQueue_p {
if (post != null) {
if (post.containsKey("limit")) {
try {
- showLimit = Integer.valueOf(post.get("limit")).intValue();
+ showLimit = Integer.parseInt(post.get("limit"));
} catch (final NumberFormatException e) {}
}
diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index 2699836ab..43622e60a 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -84,7 +84,7 @@ public class PerformanceQueues_p {
}
if (post.containsKey("Xmx")) {
int xmx = 180; // default maximum heap size
- try { xmx = Integer.valueOf(post.get("Xmx", "" + xmx)).intValue(); } catch (final NumberFormatException e){}
+ try { xmx = Integer.parseInt(post.get("Xmx", Integer.toString(xmx))); } catch (final NumberFormatException e){}
if (!(OS.isWin32 && xmx >= 2000)){
sb.setConfig("javastart_Xmx", "Xmx" + xmx + "m");
sb.setConfig("javastart_Xms", "Xms" + xmx + "m");
@@ -93,17 +93,17 @@ public class PerformanceQueues_p {
}
if(post.containsKey("diskFree")) {
int diskFree = 3000; // default
- try { diskFree = Integer.valueOf(post.get("diskFree", "" + diskFree)).intValue(); } catch (final NumberFormatException e){}
+ try { diskFree = Integer.parseInt(post.get("diskFree", Integer.toString(diskFree))); } catch (final NumberFormatException e){}
sb.setConfig(SwitchboardConstants.DISK_FREE, diskFree);
}
if(post.containsKey("diskFreeHardlimit")) {
int diskFreeHardlimit = 1000; // default
- try { diskFreeHardlimit = Integer.valueOf(post.get("diskFreeHardlimit", "" + diskFreeHardlimit)).intValue(); } catch (final NumberFormatException e){}
+ try { diskFreeHardlimit = Integer.parseInt(post.get("diskFreeHardlimit", Integer.toString(diskFreeHardlimit))); } catch (final NumberFormatException e){}
sb.setConfig(SwitchboardConstants.DISK_FREE_HARDLIMIT, diskFreeHardlimit);
}
if(post.containsKey("memoryAcceptDHT")) {
int memoryAcceptDHT = 50000; // default
- try { memoryAcceptDHT = Integer.valueOf(post.get("memoryAcceptDHT", "" + memoryAcceptDHT)).intValue(); } catch (final NumberFormatException e){}
+ try { memoryAcceptDHT = Integer.parseInt(post.get("memoryAcceptDHT", Integer.toString(memoryAcceptDHT))); } catch (final NumberFormatException e){}
sb.setConfig(SwitchboardConstants.MEMORY_ACCEPTDHT, memoryAcceptDHT);
}
if(post.containsKey("resetObserver")) {
diff --git a/htroot/Ranking_p.java b/htroot/Ranking_p.java
index 774509d6c..3a381b51b 100644
--- a/htroot/Ranking_p.java
+++ b/htroot/Ranking_p.java
@@ -117,13 +117,13 @@ public class Ranking_p {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_value", i);
try {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked",
- (i == Integer.valueOf(entry.getValue()).intValue()) ? "1" : "0");
+ (i == Integer.parseInt(entry.getValue())) ? "1" : "0");
} catch (final NumberFormatException e) {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked", "0");
}
}
prop.put("attr" + attrExtension + "_" + j + "_value",
- Integer.valueOf(map.get(key)).intValue());
+ Integer.parseInt(map.get(key)));
j++;
}
}
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 4184a8a21..ff8dc5d98 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -458,7 +458,7 @@ public class SettingsAck_p {
int crawlerTimeout;
try {
- crawlerTimeout = Integer.valueOf(timeoutStr).intValue();
+ crawlerTimeout = Integer.parseInt(timeoutStr);
if (crawlerTimeout < 0) crawlerTimeout = 0;
env.setConfig("crawler.clientTimeout", Integer.toString(crawlerTimeout));
} catch (final NumberFormatException e) {
@@ -473,7 +473,7 @@ public class SettingsAck_p {
long maxHttpSize;
try {
- maxHttpSize = Integer.valueOf(maxSizeStr).intValue();
+ maxHttpSize = Integer.parseInt(maxSizeStr);
if(maxHttpSize < 0) {
maxHttpSize = -1;
}
@@ -490,7 +490,7 @@ public class SettingsAck_p {
long maxFtpSize;
try {
- maxFtpSize = Integer.valueOf(maxSizeStr).intValue();
+ maxFtpSize = Integer.parseInt(maxSizeStr);
env.setConfig("crawler.ftp.maxFileSize", Long.toString(maxFtpSize));
} catch (final NumberFormatException e) {
prop.put("info", "31");
diff --git a/htroot/api/blacklists.java b/htroot/api/blacklists.java
index 8ffd8ffcc..c92f233b0 100644
--- a/htroot/api/blacklists.java
+++ b/htroot/api/blacklists.java
@@ -36,7 +36,7 @@ public class blacklists {
final String nextEntry = list.get(j);
if (nextEntry.length() == 0) continue;
- if (nextEntry.startsWith("#")) continue;
+ if (nextEntry.charAt(0) == '#') continue;
prop.putXML("lists_" + blacklistCount + "_items_" + count + "_item", nextEntry);
count++;
diff --git a/htroot/api/blacklists_p.java b/htroot/api/blacklists_p.java
index 6435c1eef..180481484 100644
--- a/htroot/api/blacklists_p.java
+++ b/htroot/api/blacklists_p.java
@@ -52,7 +52,7 @@ public class blacklists_p {
final String nextEntry = list.get(j);
if (nextEntry.length() == 0) continue;
- if (nextEntry.startsWith("#")) continue;
+ if (nextEntry.charAt(0) == '#') continue;
prop.putXML("lists_" + blacklistCount + "_items_" + count + "_item", nextEntry);
count++;
diff --git a/htroot/api/bookmarks/get_bookmarks.java b/htroot/api/bookmarks/get_bookmarks.java
index 0aba3d688..a26786d03 100644
--- a/htroot/api/bookmarks/get_bookmarks.java
+++ b/htroot/api/bookmarks/get_bookmarks.java
@@ -101,8 +101,8 @@ public class get_bookmarks {
count = print_XBEL(it, count);
prop.put("display_xbel", count);
break;
- } else if (qtype.equals("folders") && !query.equals("")) {
- if (query.startsWith("/")) { root = query; }
+ } else if (qtype.equals("folders") && !query.isEmpty()) {
+ if (query.length() > 0 && query.charAt(0) == '/') { root = query; }
else { root = "/" + query; }
}
prop.putHTML("display_folder", "0");
diff --git a/htroot/api/bookmarks/xbel/xbel.java b/htroot/api/bookmarks/xbel/xbel.java
index 4dea78c69..2e9c88052 100755
--- a/htroot/api/bookmarks/xbel/xbel.java
+++ b/htroot/api/bookmarks/xbel/xbel.java
@@ -47,7 +47,7 @@ public class xbel {
}
if(post.containsKey("folder")) {
final String folderName=post.get("folder");
- if (folderName.startsWith("/")) { root = folderName; }
+ if (folderName.length() > 0 && folderName.charAt(0) == '/') { root = folderName; }
else { root = "/" + folderName; }
}
if(post.containsKey("style") && !post.get("style").equals("")) {
diff --git a/htroot/api/util/ynetSearch.java b/htroot/api/util/ynetSearch.java
index 8d7802307..e4c980d9b 100755
--- a/htroot/api/util/ynetSearch.java
+++ b/htroot/api/util/ynetSearch.java
@@ -32,7 +32,7 @@ public class ynetSearch {
String searchaddress = post.get("url");
if (!searchaddress.startsWith("http://")) {
// a relative path .. this addresses the local peer
- searchaddress = "http://" + switchboard.peers.mySeed().getPublicAddress() + (searchaddress.startsWith("/") ? "" : "/") + searchaddress;
+ searchaddress = "http://" + switchboard.peers.mySeed().getPublicAddress() + ((searchaddress.length() > 0 && searchaddress.charAt(0) == '/') ? "" : "/") + searchaddress;
}
post.remove("url");
post.remove("login");
diff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.java
index c4ba1cf65..353d4ad28 100644
--- a/htroot/api/yacydoc.java
+++ b/htroot/api/yacydoc.java
@@ -97,7 +97,7 @@ public class yacydoc {
prop.putXML("dc_publisher", metadata.url().toNormalform(false, true));
prop.putXML("dc_contributor", "");
prop.putXML("dc_date", entry.moddate().toString());
- prop.putXML("dc_type", "" + entry.doctype());
+ prop.putXML("dc_type", String.valueOf(entry.doctype()));
prop.putXML("dc_identifier", urlhash);
prop.putXML("dc_language", entry.language());
diff --git a/htroot/imagetest.java b/htroot/imagetest.java
index 96292c904..3797a7c5e 100644
--- a/htroot/imagetest.java
+++ b/htroot/imagetest.java
@@ -66,8 +66,8 @@ public class imagetest {
*/
final RasterPlotter img = new RasterPlotter(800, 600, RasterPlotter.MODE_SUB, "FFFFFF");
img.setColor(RasterPlotter.GREY);
- for (int y = 0; y < 600; y = y + 50) PrintTool.print(img, 0, 6 + y, 0, "" + y, -1);
- for (int x = 0; x < 800; x = x + 50) PrintTool.print(img, x, 6 , 0, "" + x, -1);
+ for (int y = 0; y < 600; y = y + 50) PrintTool.print(img, 0, 6 + y, 0, Integer.toString(y), -1);
+ for (int x = 0; x < 800; x = x + 50) PrintTool.print(img, x, 6 , 0, Integer.toString(x), -1);
img.setColor(RasterPlotter.RED);
img.dot(550, 110, 90, true);
img.setColor(RasterPlotter.GREEN);
diff --git a/htroot/index.java b/htroot/index.java
index 241aa78f9..e3a287651 100644
--- a/htroot/index.java
+++ b/htroot/index.java
@@ -112,7 +112,7 @@ public class index {
prop.put("searchoptions_prefermaskoptions", "0");
prop.putHTML("searchoptions_prefermaskoptions_prefermaskfilter", prefermaskfilter);
prop.put("searchoptions_indexofChecked", "");
- prop.put("searchoptions_publicSearchpage", (publicPage == true) ? "0" : "1");
+ prop.put("searchoptions_publicSearchpage", (publicPage) ? "0" : "1");
prop.put("results", "");
prop.putHTML("cat", cat);
prop.put("type", type);
diff --git a/htroot/processing/domaingraph/applet/domaingraph.java b/htroot/processing/domaingraph/applet/domaingraph.java
index a212a8c6e..cf67db7bb 100755
--- a/htroot/processing/domaingraph/applet/domaingraph.java
+++ b/htroot/processing/domaingraph/applet/domaingraph.java
@@ -11,10 +11,10 @@ import processing.core.*; import traer.physics.*; import traer.animation.*; impo
-final float NODE_SIZE = 6;
-final float EDGE_LENGTH = 30;
-final float EDGE_STRENGTH = 0.001f;
-final float SPACER_STRENGTH = 250;
+final static float NODE_SIZE = 6;
+final static float EDGE_LENGTH = 30;
+final static float EDGE_STRENGTH = 0.001f;
+final static float SPACER_STRENGTH = 250;
ParticleSystem physics;
Smoother3D centroid;
@@ -195,7 +195,7 @@ public HashMap parseProps(String s) {
p = l[i].indexOf("=");
if (p > 0) {
z = l[i].substring(p + 1).trim();
- if (z.charAt(0) == '"') z = z.substring(1);
+ if (z.length() > 0 && z.charAt(0) == '"') z = z.substring(1);
if (z.charAt(z.length() - 1) == '"') z = z.substring(0, z.length() - 1);
map.put(l[i].substring(0, p), z);
}
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 19306b22d..233fc0f31 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -166,7 +166,7 @@ public final class message {
*/
private static void messageForwardingViaEmail(final Switchboard sb, final messageBoard.entry msgEntry) {
try {
- if (!Boolean.valueOf(sb.getConfig("msgForwardingEnabled","false")).booleanValue()) return;
+ if (!Boolean.parseBoolean(sb.getConfig("msgForwardingEnabled","false"))) return;
// get the recipient address
final String sendMailTo = sb.getConfig("msgForwardingTo","root@localhost").trim();
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index c3b7852ab..73c4a4b77 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -87,7 +87,7 @@ public final class transfer {
// consolidation of cr files
//System.out.println("yacy/transfer:post=" + post.toString());
//String cansendprotocol = (String) post.get("can-send-protocol", "http");
- final String access = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(otherpeer + ":" + filename)) + ":" + Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw("" + System.currentTimeMillis()));
+ final String access = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(otherpeer + ":" + filename)) + ":" + Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis())));
prop.put("response", "ok");
prop.put("process_access", access);
prop.put("process_address", sb.peers.mySeed().getPublicAddress());
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 6322f3efb..7593db55e 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -287,7 +287,7 @@ public class yacysearch {
if (ftb == -1) ftb = querystring.length();
String ft = querystring.substring(filetype + 9, ftb);
querystring = querystring.replace("filetype:" + ft, "");
- while(ft.startsWith(".")) ft = ft.substring(1);
+ while (ft.length() > 0 && ft.charAt(0) == '.') ft = ft.substring(1);
if(ft.length() > 0) {
if (urlmask == null) {
urlmask = ".*\\." + ft;
@@ -311,8 +311,8 @@ public class yacysearch {
if (ftb == -1) ftb = querystring.length();
String domain = querystring.substring(site + 5, ftb);
querystring = querystring.replace("site:" + domain, "");
- while(domain.startsWith(".")) domain = domain.substring(1);
- while(domain.endsWith(".")) domain = domain.substring(0, domain.length() - 1);
+ while (domain.length() > 0 && domain.charAt(0) == '.') domain = domain.substring(1);
+ while (domain.endsWith(".")) domain = domain.substring(0, domain.length() - 1);
sitehash = DigestURI.domhash(domain);
}
int authori = querystring.indexOf("author:");
@@ -343,7 +343,7 @@ public class yacysearch {
if (ftb == -1) ftb = querystring.length();
String domain = querystring.substring(tld + 4, ftb);
querystring = querystring.replace("tld:" + domain, "");
- while(domain.startsWith(".")) domain = domain.substring(1);
+ while (domain.length() > 0 && domain.charAt(0) == '.') domain = domain.substring(1);
if (domain.indexOf(".") < 0) domain = "\\." + domain; // is tld
if (domain.length() > 0) {
if (urlmask == null) {
diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.java
index d302d2d34..838191938 100644
--- a/source/de/anomic/crawler/Balancer.java
+++ b/source/de/anomic/crawler/Balancer.java
@@ -50,8 +50,8 @@ public class Balancer {
// class variables
private final ConcurrentHashMap<String, LinkedList<String>> domainStacks; // a map from domain name part to Lists with url hashs
- private ConcurrentLinkedQueue<String> top;
- private TreeMap<Long, String> delayed;
+ private final ConcurrentLinkedQueue<String> top;
+ private final TreeMap<Long, String> delayed;
protected ObjectIndex urlFileIndex;
private final File cacheStacksPath;
private long minimumLocalDelta;
@@ -397,7 +397,7 @@ public class Balancer {
// put that thing back to omit a delay here
if (!delayed.values().contains(nexthash)) {
//System.out.println("*** delayed +=" + nexthash);
- this.delayed.put(new Long(System.currentTimeMillis() + sleeptime + 1), nexthash);
+ this.delayed.put(Long.valueOf(System.currentTimeMillis() + sleeptime + 1), nexthash);
}
try {
this.urlFileIndex.put(rowEntry);
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index c028807bc..032ef3239 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -211,7 +211,7 @@ public class CrawlQueues {
", robinsonMode=" + ((sb.isRobinsonMode()) ? "on" : "off"));
}
- String queueCheck = crawlIsPossible(NoticedURL.STACK_TYPE_CORE, "Core");
+ String queueCheck = crawlIsPossible(NoticedURL.STACK_TYPE_CORE);
if (queueCheck != null) {
log.logInfo("omitting de-queue/local: " + queueCheck);
return false;
@@ -311,10 +311,9 @@ public class CrawlQueues {
/**
* Checks if crawl queue has elements and new crawl will not exceed thread-limit
* @param stackType
- * @param type
* @return
*/
- private String crawlIsPossible(int stackType, final String type) {
+ private String crawlIsPossible(int stackType) {
//System.out.println("stacksize = " + noticeURL.stackSize(stackType));
if (noticeURL.stackSize(stackType) == 0) {
//log.logDebug("GlobalCrawl: queue is empty");
@@ -485,7 +484,7 @@ public class CrawlQueues {
// do nothing if either there are private processes to be done
// or there is no global crawl on the stack
- String queueCheck = crawlIsPossible(NoticedURL.STACK_TYPE_REMOTE, "Global");
+ String queueCheck = crawlIsPossible(NoticedURL.STACK_TYPE_REMOTE);
if (queueCheck != null) {
if (log.isFinest()) log.logFinest("omitting de-queue/remote: " + queueCheck);
return false;
diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.java
index 61c68a172..f662625d4 100644
--- a/source/de/anomic/crawler/CrawlStacker.java
+++ b/source/de/anomic/crawler/CrawlStacker.java
@@ -45,15 +45,16 @@ import de.anomic.yacy.yacySeedDB;
public final class CrawlStacker {
- private Log log = new Log("STACKCRAWL");
+ private final Log log = new Log("STACKCRAWL");
- private WorkflowProcessor<Request> fastQueue, slowQueue;
- private long dnsHit, dnsMiss;
- private CrawlQueues nextQueue;
- private CrawlSwitchboard crawler;
- private Segment indexSegment;
- private yacySeedDB peers;
- private boolean acceptLocalURLs, acceptGlobalURLs;
+ private final WorkflowProcessor<Request> fastQueue, slowQueue;
+ //private long dnsHit;
+ private long dnsMiss;
+ private final CrawlQueues nextQueue;
+ private final CrawlSwitchboard crawler;
+ private final Segment indexSegment;
+ private final yacySeedDB peers;
+ private final boolean acceptLocalURLs, acceptGlobalURLs;
// this is the process that checks url for double-occurrences and for allowance/disallowance by robots.txt
@@ -68,7 +69,7 @@ public final class CrawlStacker {
this.crawler = cs;
this.indexSegment = indexSegment;
this.peers = peers;
- this.dnsHit = 0;
+ //this.dnsHit = 0;
this.dnsMiss = 0;
this.acceptLocalURLs = acceptLocalURLs;
this.acceptGlobalURLs = acceptGlobalURLs;
@@ -158,7 +159,7 @@ public final class CrawlStacker {
if (prefetchHost(entry.url().getHost())) {
try {
this.fastQueue.enQueue(entry);
- this.dnsHit++;
+ //this.dnsHit++;
} catch (InterruptedException e) {
Log.logException(e);
}
diff --git a/source/de/anomic/crawler/Latency.java b/source/de/anomic/crawler/Latency.java
index 990a8e5f9..0f9cbeab1 100644
--- a/source/de/anomic/crawler/Latency.java
+++ b/source/de/anomic/crawler/Latency.java
@@ -231,7 +231,7 @@ public class Latency {
private long timeacc;
private long lastacc;
private int count;
- private String host;
+ private final String host;
private long robotsMinDelay;
public Host(String host, long time) {
this.host = host;
diff --git a/source/de/anomic/crawler/RobotsEntry.java b/source/de/anomic/crawler/RobotsEntry.java
index 041007e2c..47029824e 100644
--- a/source/de/anomic/crawler/RobotsEntry.java
+++ b/source/de/anomic/crawler/RobotsEntry.java
@@ -147,7 +147,7 @@ public class RobotsEntry {
public Date getLoadedDate() {
if (this.mem.containsKey(LOADED_DATE)) {
- return new Date(Long.valueOf(this.mem.get(LOADED_DATE)).longValue());
+ return new Date(Long.parseLong(this.mem.get(LOADED_DATE)));
}
return null;
}
@@ -160,7 +160,7 @@ public class RobotsEntry {
public Date getModDate() {
if (this.mem.containsKey(MOD_DATE)) {
- return new Date(Long.valueOf(this.mem.get(MOD_DATE)).longValue());
+ return new Date(Long.parseLong(this.mem.get(MOD_DATE)));
}
return null;
}
diff --git a/source/de/anomic/crawler/SitemapImporter.java b/source/de/anomic/crawler/SitemapImporter.java
index 368f4224e..9aa04ac4f 100644
--- a/source/de/anomic/crawler/SitemapImporter.java
+++ b/source/de/anomic/crawler/SitemapImporter.java
@@ -31,8 +31,8 @@ import de.anomic.search.Switchboard;
public class SitemapImporter extends AbstractImporter implements Importer {
- private SitemapParser parser = null;
- private DigestURI sitemapURL = null;
+ private final SitemapParser parser;
+ private final DigestURI sitemapURL;
private final ImporterManager superviser;
public SitemapImporter(final Switchboard sb, final ImporterManager importManager, final DigestURI sitemapURL, final CrawlProfile.entry profileEntry) throws ImporterException {
diff --git a/source/de/anomic/crawler/ZURL.java b/source/de/anomic/crawler/ZURL.java
index 60e060e55..935baeffd 100755
--- a/source/de/anomic/crawler/ZURL.java
+++ b/source/de/anomic/crawler/ZURL.java
@@ -149,7 +149,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
}
private class EntryIterator implements Iterator<ZURL.Entry> {
- private Iterator<String> hi;
+ private final Iterator<String> hi;
public EntryIterator() {
this.hi = stack.iterator();
}
diff --git a/source/de/anomic/data/DidYouMeanLibrary.java b/source/de/anomic/data/DidYouMeanLibrary.java
index 94dcc8798..88e8461ee 100644
--- a/source/de/anomic/data/DidYouMeanLibrary.java
+++ b/source/de/anomic/data/DidYouMeanLibrary.java
@@ -46,7 +46,7 @@ import net.yacy.kelondro.logging.Log;
*/
public class DidYouMeanLibrary {
- private File dictionaryPath;
+ private final File dictionaryPath;
private TreeSet<String> dict, tcid;
/**
diff --git a/source/de/anomic/data/URLAnalysis.java b/source/de/anomic/data/URLAnalysis.java
index be67563e7..62f2db406 100644
--- a/source/de/anomic/data/URLAnalysis.java
+++ b/source/de/anomic/data/URLAnalysis.java
@@ -239,7 +239,7 @@ public class URLAnalysis {
for (Map.Entry<String, Integer> e: results.entrySet()) {
os.write(e.getKey().getBytes());
os.write(new byte[]{'\t'});
- os.write(("" + e.getValue()).getBytes());
+ os.write(Integer.toString(e.getValue()).getBytes());
os.write(new byte[]{'\n'});
count++;
if (System.currentTimeMillis() - time > 10000) {
diff --git a/source/de/anomic/data/URLLicense.java b/source/de/anomic/data/URLLicense.java
index 6ed63a839..9a42a37de 100644
--- a/source/de/anomic/data/URLLicense.java
+++ b/source/de/anomic/data/URLLicense.java
@@ -44,7 +44,7 @@ public class URLLicense {
private final ConcurrentHashMap<String, DigestURI> permissions;
private final ConcurrentLinkedQueue<String> aging;
private long lastCheck;
- private int keylen;
+ private final int keylen;
public URLLicense(final int keylen) {
this.permissions = new ConcurrentHashMap<String, DigestURI>();
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index cea73882a..d9ab13452 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -165,7 +165,7 @@ public class bookmarksDB {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
Log.logInfo("BOOKMARKS", "autoReCrawl - reading schedules from " + f);
while( null != (s = in.readLine()) ) {
- if (!s.startsWith("#") && s.length()>0) {
+ if (s.length() > 0 && s.charAt(0) != '#') {
String parser[] = s.split("\t");
if (parser.length == 13) {
folderReCrawl(Long.parseLong(parser[0]), parser[1], parser[2], Integer.parseInt(parser[3]), Long.parseLong(parser[4]),
@@ -355,7 +355,7 @@ public class bookmarksDB {
public static String cleanTagsString(String tagsString){
// get rid of heading, trailing and double commas since they are useless
- while (tagsString.startsWith(",")) {
+ while (tagsString.length() > 0 && tagsString.charAt(0) == ',') {
tagsString = tagsString.substring(1);
}
while (tagsString.endsWith(",")) {
diff --git a/source/de/anomic/data/translator.java b/source/de/anomic/data/translator.java
index fc00e0e0c..8eddc6aa0 100644
--- a/source/de/anomic/data/translator.java
+++ b/source/de/anomic/data/translator.java
@@ -95,24 +95,24 @@ public class translator {
while(it.hasNext()){
line = it.next();
- if(! line.startsWith("#")){
+ if (line.length() == 0 || line.charAt(0) != '#'){
splitted = line.split("==", 2);
- if(splitted.length == 2){
+ if (splitted.length == 2) {
translationList.put(splitted[0], splitted[1]);
//}else{ //Invalid line
}
- }else if(line.startsWith("#File: ")){
- if(!forFile.equals("")){
- lists.put(forFile, translationList);
+ } else if (line.startsWith("#File: ")) {
+ if (!forFile.equals("")){
+ lists.put(forFile, translationList);
}
- if(line.charAt(6)==' '){
+ if (line.charAt(6)==' ') {
forFile=line.substring(7);
- }else{
+ } else {
forFile=line.substring(6);
}
- if(lists.containsKey(forFile)){
+ if (lists.containsKey(forFile)) {
translationList=lists.get(forFile);
- }else{
+ } else {
translationList=new Hashtable<String, String>();
}
}
diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java
index 0469b4dc9..080a4ce7a 100644
--- a/source/de/anomic/data/userDB.java
+++ b/source/de/anomic/data/userDB.java
@@ -370,7 +370,7 @@ public final class userDB {
public long getTimeUsed() {
if (this.mem.containsKey(TIME_USED)) {
try{
- return Long.valueOf(this.mem.get(TIME_USED)).longValue();
+ return Long.parseLong(this.mem.get(TIME_USED));
}catch(final NumberFormatException e){
return 0;
}
@@ -386,7 +386,7 @@ public final class userDB {
public long getTimeLimit() {
if (this.mem.containsKey(TIME_LIMIT)) {
try{
- return Long.valueOf(this.mem.get(TIME_LIMIT)).longValue();
+ return Long.parseLong(this.mem.get(TIME_LIMIT));
}catch(final NumberFormatException e){
return 0;
}
@@ -401,7 +401,7 @@ public final class userDB {
public long getTrafficSize() {
if (this.mem.containsKey(TRAFFIC_SIZE)) {
- return Long.valueOf(this.mem.get(TRAFFIC_SIZE)).longValue();
+ return Long.parseLong(this.mem.get(TRAFFIC_SIZE));
}
try {
this.setProperty(TRAFFIC_SIZE,"0");
@@ -434,7 +434,7 @@ public final class userDB {
public int surfRight(){
final long timeUsed=this.updateLastAccess(true);
- if(this.hasProxyRight() == false)
+ if (!this.hasProxyRight())
return PROXY_NORIGHT;
if(! (this.getTimeLimit() <= 0 || ( timeUsed < this.getTimeLimit())) ){ //no timelimit or timelimit not reached
diff --git a/source/de/anomic/data/wiki/wikiCode.java b/source/de/anomic/data/wiki/wikiCode.java
index a597d5745..bbfb1c2c3 100644
--- a/source/de/anomic/data/wiki/wikiCode.java
+++ b/source/de/anomic/data/wiki/wikiCode.java
@@ -579,7 +579,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
anchorext = "_" + (doubles + 1);
}
- if (element.startsWith("3")) {
+ if (element.length() > 0 && element.charAt(0) == '3') {
if (level < 3) {
level = 3;
level3 = 0;
@@ -593,7 +593,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
directory.append("\" class=\"WikiTOC\">");
directory.append(element);
directory.append("</a><br />\n");
- } else if (element.startsWith("2")) {
+ } else if (element.length() > 0 && element.charAt(0) == '2') {
if (level == 1) {
level2 = 0;
level = 2;
@@ -610,7 +610,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
directory.append("\" class=\"WikiTOC\">");
directory.append(element);
directory.append("</a><br />\n");
- } else if (element.startsWith("1")) {
+ } else if (element.length() > 0 && element.charAt(0) == '1') {
if (level > 1) {
level = 1;
level2 = 0;
@@ -712,7 +712,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
result = processTable(result);
// format lines
- if (result.startsWith(" ")) {
+ if (result.length() > 0 && result.charAt(0) == ' ') {
result = "<tt>" + result.substring(1) + "</tt>";
}
if (result.startsWith("----")) {
@@ -720,10 +720,10 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
}
// citings contributed by [MN]
- if (result.startsWith(":")) {
+ if (result.length() > 0 && result.charAt(0) == ':') {
String head = "";
String tail = "";
- while (result.startsWith(":")) {
+ while (result.length() > 0 && result.charAt(0) == ':') {
head = head + "<blockquote>";
tail = tail + "</blockquote>";
result = result.substring(1);
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index f130520ed..bb72f6db6 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -396,7 +396,7 @@ public final class HTTPDFileHandler {
File targetClass=null;
// locate the file
- if (!path.startsWith("/") && !path.startsWith("\\")) path = "/" + path; // attach leading slash
+ if (path.length() > 0 && path.charAt(0) != '/' && path.charAt(0) != '\\') path = "/" + path; // attach leading slash
// a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the locale.language
String localeSelection = switchboard.getConfig("locale.language","default");
@@ -691,7 +691,7 @@ public final class HTTPDFileHandler {
HTTPDemon.sendRespondHeader(conProp, out, httpVersion, statusCode, null, mimeType, cgiBody.length(), targetDate, null, null, null, null, nocache);
out.write(cgiBody.getBytes());
} else {
- HTTPDemon.sendRespondError(conProp, out, exitValue, statusCode, null, HeaderFramework.http1_1.get(statusCode + ""), null);
+ HTTPDemon.sendRespondError(conProp, out, exitValue, statusCode, null, HeaderFramework.http1_1.get(Integer.toString(statusCode)), null);
}
@@ -955,7 +955,7 @@ public final class HTTPDFileHandler {
final String rangesVal = rangeHeaderVal.substring("bytes=".length());
final String[] ranges = rangesVal.split(",");
if ((ranges.length == 1)&&(ranges[0].endsWith("-"))) {
- rangeStartOffset = Integer.valueOf(ranges[0].substring(0,ranges[0].length()-1)).intValue();
+ rangeStartOffset = Integer.parseInt(ranges[0].substring(0,ranges[0].length()-1));
statusCode = 206;
if (header == null) header = new ResponseHeader();
header.put(HeaderFramework.CONTENT_RANGE, "bytes " + rangeStartOffset + "-" + (targetFile.length()-1) + "/" + targetFile.length());
diff --git a/source/de/anomic/http/server/HTTPDProxyHandler.java b/source/de/anomic/http/server/HTTPDProxyHandler.java
index 44fa8f9c7..b4493e2e5 100644
--- a/source/de/anomic/http/server/HTTPDProxyHandler.java
+++ b/source/de/anomic/http/server/HTTPDProxyHandler.java
@@ -194,7 +194,7 @@ public final class HTTPDProxyHandler {
}
final String redirectorPath = sb.getConfig("externalRedirector", "");
- if (redirectorPath.length() > 0 && redirectorEnabled == false){
+ if (redirectorPath.length() > 0 && !redirectorEnabled) {
try {
redirectorProcess=Runtime.getRuntime().exec(redirectorPath);
redirectorWriter = new PrintWriter(redirectorProcess.getOutputStream());
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.java
index a8cbc55ce..57b263d73 100644
--- a/source/de/anomic/http/server/HTTPDemon.java
+++ b/source/de/anomic/http/server/HTTPDemon.java
@@ -161,7 +161,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
this.clientIP = null;
// configuring keep alive support
- keepAliveSupport = Boolean.valueOf(switchboard.getConfig("connectionKeepAliveSupport","false")).booleanValue();
+ keepAliveSupport = Boolean.parseBoolean(switchboard.getConfig("connectionKeepAliveSupport","false"));
}
public Properties getConProp() {
diff --git a/source/de/anomic/http/server/HeaderFramework.java b/source/de/anomic/http/server/HeaderFramework.java
index 477f5ff51..db0625a34 100644
--- a/source/de/anomic/http/server/HeaderFramework.java
+++ b/source/de/anomic/http/server/HeaderFramework.java
@@ -349,7 +349,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
final String param = parts[i].trim();
if (param.startsWith("charset=")) {
String charset = param.substring("charset=".length()).trim();
- if (charset.startsWith("\"") || charset.startsWith("'")) charset = charset.substring(1);
+ if (charset.length() > 0 && (charset.charAt(0) == '\"' || charset.charAt(0) == '\'')) charset = charset.substring(1);
if (charset.endsWith("\"") || charset.endsWith("'")) charset = charset.substring(0,charset.length()-1);
return charset.trim();
}
diff --git a/source/de/anomic/http/server/RequestHeader.java b/source/de/anomic/http/server/RequestHeader.java
index 37e943588..cbf436955 100755
--- a/source/de/anomic/http/server/RequestHeader.java
+++ b/source/de/anomic/http/server/RequestHeader.java
@@ -202,7 +202,7 @@ public class RequestHeader extends HeaderFramework {
}
} else {
// no host in url. set path
- if (args.startsWith("/")) {
+ if (args.length() > 0 && args.charAt(0) == '/') {
// thats also fine, its a perfect localhost access
// in this case, we simulate a
// http://localhost/s
diff --git a/source/de/anomic/net/ftpc.java b/source/de/anomic/net/ftpc.java
index 9181a8b10..df65810c2 100644
--- a/source/de/anomic/net/ftpc.java
+++ b/source/de/anomic/net/ftpc.java
@@ -1980,7 +1980,7 @@ public class ftpc {
if (pattern.equals("*")) {
return true;
}
- if ((pattern.startsWith("*")) && (pattern.endsWith("*"))) {
+ if (pattern.length() > 0 && pattern.charAt(0) == '*' && pattern.endsWith("*")) {
return // avoid recursion deadlock
((matches(name, pattern.substring(1))) || (matches(name, pattern.substring(0, pattern.length() - 1))));
}
@@ -2310,7 +2310,7 @@ public class ftpc {
+ (((stop - start) < 2000) ? (stop - start) + " milliseconds"
: (((int) ((stop - start) / 100)) / 10) + " seconds"));
if (start == stop) {
- errPrintln(logPrefix + "");
+ errPrintln(logPrefix);
} else {
outPrintln(" (" + (length * 1000 / 1024 / (stop - start)) + " kbytes/second)");
}
@@ -2602,7 +2602,7 @@ public class ftpc {
sys();
}
final String base = "ftp://" + ((account.equals("anonymous")) ? "" : (account + ":" + password + "@"))
- + host + ((port == 21) ? "" : (":" + port)) + ((remotePath.charAt(0) == '/') ? "" : pwd() + "/")
+ + host + ((port == 21) ? "" : (":" + port)) + ((remotePath.length() > 0 && remotePath.charAt(0) == '/') ? "" : pwd() + "/")
+ remotePath;
return dirhtml(base, remotemessage, remotegreeting, remotesystem, list);
@@ -2805,7 +2805,7 @@ public class ftpc {
private static void printHelp() {
System.out.println(logPrefix + "ftp help");
System.out.println(logPrefix + "----------");
- System.out.println(logPrefix + "");
+ System.out.println(logPrefix);
System.out.println(logPrefix + "The following commands are supported");
System.out.println(logPrefix
+ "java ftp -- (without arguments) starts the shell. Thy 'help' then for shell commands.");
@@ -2815,14 +2815,14 @@ public class ftpc {
System.out.println(logPrefix
+ "java ftp -get <host>[':'<port>] <remoteFile> <localPath> [<account> <password>]");
System.out.println(logPrefix + "java ftp -put <host>[':'<port>] <localFile> <remotePath> <account> <password>");
- System.out.println(logPrefix + "");
+ System.out.println(logPrefix);
}
public static void main(final String[] args) {
System.out.println(logPrefix + "WELCOME TO THE ANOMIC FTP CLIENT v" + vDATE);
System.out.println(logPrefix + "Visit http://www.anomic.de and support shareware!");
System.out.println(logPrefix + "try -h for command line options");
- System.out.println(logPrefix + "");
+ System.out.println(logPrefix);
if (args.length == 0) {
(new ftpc()).shell(null);
} else if (args.length == 1) {
diff --git a/source/de/anomic/search/MetadataRepository.java b/source/de/anomic/search/MetadataRepository.java
index fb1b153d6..5c07c8bdd 100644
--- a/source/de/anomic/search/MetadataRepository.java
+++ b/source/de/anomic/search/MetadataRepository.java
@@ -455,7 +455,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
private String failure;
private final int format;
private final boolean dom;
- private HandleSet set;
+ private final HandleSet set;
public Export(final File f, final String filter, HandleSet set, final int format, boolean dom) {
// format: 0=text, 1=html, 2=rss/xml
diff --git a/source/de/anomic/search/QueryParams.java b/source/de/anomic/search/QueryParams.java
index 4d4de5ae3..2fec27d65 100644
--- a/source/de/anomic/search/QueryParams.java
+++ b/source/de/anomic/search/QueryParams.java
@@ -75,7 +75,7 @@ public final class QueryParams {
public boolean allofconstraint;
public boolean onlineSnippetFetch;
public RankingProfile ranking;
- private Segment indexSegment;
+ private final Segment indexSegment;
public String host; // this is the client host that starts the query, not a site operator
public String sitehash; // this is a domain hash, 6 bytes long or null
public String authorhash;
diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.java
index 3b872ef04..a8339a43b 100644
--- a/source/de/anomic/search/RankingProcess.java
+++ b/source/de/anomic/search/RankingProcess.java
@@ -70,7 +70,7 @@ public final class RankingProcess extends Thread {
private final ConcurrentHashMap<String, Integer> urlhashes; // map for double-check; String/Long relation, addresses ranking number (backreference for deletion)
private final int[] flagcount; // flag counter
private final TreeSet<String> misses; // contains url-hashes that could not been found in the LURL-DB
- private final int[] domZones;
+ //private final int[] domZones;
private HashMap<byte[], ReferenceContainer<WordReference>> localSearchInclusion;
private int remote_peerCount, remote_indexCount, remote_resourceSize, local_resourceSize;
@@ -106,8 +106,8 @@ public final class RankingProcess extends Thread {
this.hostNavigator = new ConcurrentHashMap<String, HostInfo>();
this.authorNavigator = new ConcurrentHashMap<String, AuthorInfo>();
this.ref = new ConcurrentHashMap<String, Integer>();
- this.domZones = new int[8];
- for (int i = 0; i < 8; i++) {this.domZones[i] = 0;}
+ //this.domZones = new int[8];
+ //for (int i = 0; i < 8; i++) {this.domZones[i] = 0;}
this.feeders = concurrency;
assert this.feeders >= 1;
}
@@ -211,7 +211,7 @@ public final class RankingProcess extends Thread {
}
// count domZones
- this.domZones[DigestURI.domDomain(iEntry.metadataHash())]++;
+ //this.domZones[DigestURI.domDomain(iEntry.metadataHash())]++;
// get statistics for host navigator
if (nav_hosts) {
diff --git a/source/de/anomic/search/RankingProfile.java b/source/de/anomic/search/RankingProfile.java
index 930ce83f3..6124a2d30 100644
--- a/source/de/anomic/search/RankingProfile.java
+++ b/source/de/anomic/search/RankingProfile.java
@@ -122,7 +122,7 @@ public class RankingProfile {
if ((profile != null) && (profile.length() > 0)) {
//parse external form
final HashMap<String, Integer> coeff = new HashMap<String, Integer>(40);
- final String[] elts = ((profile.startsWith("{") && (profile.endsWith("}"))) ? profile.substring(1, profile.length() - 1) : profile).split(",");
+ final String[] elts = ((profile.length() > 0 && profile.charAt(0) == '{' && profile.endsWith("}")) ? profile.substring(1, profile.length() - 1) : profile).split(",");
int p;
final int s = (prefix == null) ? 0 : prefix.length();
String e;
diff --git a/source/de/anomic/search/ReferenceOrder.java b/source/de/anomic/search/ReferenceOrder.java
index 340ec015a..f8294fce6 100644
--- a/source/de/anomic/search/ReferenceOrder.java
+++ b/source/de/anomic/search/ReferenceOrder.java
@@ -62,8 +62,8 @@ public class ReferenceOrder {
public class Normalizer extends Thread {
- private ReferenceContainer<WordReference> container;
- private BlockingQueue<WordReferenceVars> decodedEntries;
+ private final ReferenceContainer<WordReference> container;
+ private final BlockingQueue<WordReferenceVars> decodedEntries;
public Normalizer(final ReferenceContainer<WordReference> container) {
// normalize ranking: find minimum and maximum of separate ranking criteria
diff --git a/source/de/anomic/search/ResultFetcher.java b/source/de/anomic/search/ResultFetcher.java
index 4f370323e..4ca9d19fc 100644
--- a/source/de/anomic/search/ResultFetcher.java
+++ b/source/de/anomic/search/ResultFetcher.java
@@ -130,8 +130,8 @@ public class ResultFetcher {
private final long timeout; // the date until this thread should try to work
private long lastLifeSign; // when the last time the run()-loop was executed
private final int id;
- private int snippetMode;
- private int neededResults;
+ private final int snippetMode;
+ private final int neededResults;
public Worker(final int id, final long maxlifetime, int snippetMode, int neededResults) {
this.id = id;
diff --git a/source/de/anomic/search/SearchEvent.java b/source/de/anomic/search/SearchEvent.java
index 62fc261da..3f5a67d74 100644
--- a/source/de/anomic/search/SearchEvent.java
+++ b/source/de/anomic/search/SearchEvent.java
@@ -74,10 +74,10 @@ public final class SearchEvent {
// class variables for remote searches
private yacySearch[] primarySearchThreads, secondarySearchThreads;
private final TreeMap<byte[], String> preselectedPeerHashes;
- private ResultURLs crawlResults;
- private Thread localSearchThread;
- private TreeMap<byte[], String> IAResults;
- private TreeMap<byte[], Integer> IACount;
+ private final ResultURLs crawlResults;
+ private final Thread localSearchThread;
+ private final TreeMap<byte[], String> IAResults;
+ private final TreeMap<byte[], Integer> IACount;
private byte[] IAmaxcounthash, IAneardhthash;
private final ReferenceOrder order;
diff --git a/source/de/anomic/search/Segment.java b/source/de/anomic/search/Segment.java
index c233a378b..c3f1e2813 100644
--- a/source/de/anomic/search/Segment.java
+++ b/source/de/anomic/search/Segment.java
@@ -463,7 +463,7 @@ public class Segment {
urlHashs.add(entry.metadataHash());
} else {
url = ue.metadata().url();
- if ((url == null) || (Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_CRAWLER, url) == true)) {
+ if (url == null || Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_CRAWLER, url)) {
urlHashs.add(entry.metadataHash());
}
}
diff --git a/source/de/anomic/search/Segments.java b/source/de/anomic/search/Segments.java
index f93cebba3..793c84068 100644
--- a/source/de/anomic/search/Segments.java
+++ b/source/de/anomic/search/Segments.java
@@ -69,7 +69,7 @@ public class Segments implements Iterable<Segment> {
private final int entityCacheMaxSize;
private final long maxFileSize;
private HashMap<String, Segment> segments;
- private HashMap<Process, String> process_assignment;
+ private final HashMap<Process, String> process_assignment;
private final boolean useTailCache;
private final boolean exceed134217727;
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index 6c76e8723..7e1c871e0 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -201,10 +201,10 @@ public final class Switchboard extends serverSwitch {
// load slots
public static int xstackCrawlSlots = 2000;
- private int dhtMaxContainerCount = 500;
- private int dhtMaxReferenceCount = 1000;
public static long lastPPMUpdate = System.currentTimeMillis()- 30000;
-
+ private final int dhtMaxContainerCount = 500;
+ private int dhtMaxReferenceCount = 1000;
+
// colored list management
public static TreeSet<String> badwords = new TreeSet<String>(NaturalOrder.naturalComparator);
public static TreeSet<String> stopwords = new TreeSet<String>(NaturalOrder.naturalComparator);
@@ -703,7 +703,7 @@ public final class Switchboard extends serverSwitch {
setConfig(Switchboard.loadHashMap(new DigestURI(networkUnitDefinition, null)));
} catch (final MalformedURLException e) { }
} else {
- final File networkUnitDefinitionFile = (networkUnitDefinition.startsWith("/")) ? new File(networkUnitDefinition) : new File(getRootPath(), networkUnitDefinition);
+ final File networkUnitDefinitionFile = (networkUnitDefinition.length() > 0 && networkUnitDefinition.charAt(0) == '/') ? new File(networkUnitDefinition) : new File(getRootPath(), networkUnitDefinition);
if (networkUnitDefinitionFile.exists()) {
initProps = FileUtils.loadMap(networkUnitDefinitionFile);
setConfig(initProps);
diff --git a/source/de/anomic/server/serverAccessTracker.java b/source/de/anomic/server/serverAccessTracker.java
index 2cc447bf0..7ce7226c1 100644
--- a/source/de/anomic/server/serverAccessTracker.java
+++ b/source/de/anomic/server/serverAccessTracker.java
@@ -31,11 +31,11 @@ import net.yacy.kelondro.logging.Log;
public class serverAccessTracker {
- private long cleanupCycle = 60000; // 1 minute
+ private static final long cleanupCycle = 60000; // 1 minute
- private long maxTrackingTime;
- private int maxTrackingCount;
- private int maxHostCount;
+ private final long maxTrackingTime;
+ private final int maxTrackingCount;
+ private final int maxHostCount;
private final ConcurrentHashMap<String, SortedMap<Long, String>> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entries
private long lastCleanup;
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index 03f4a7f17..f23154ded 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -199,7 +199,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
this.sslSocketFactory = initSSLFactory();
// init session parameter
- this.maxBusySessions = Math.max(1, Integer.valueOf(switchboard.getConfig("httpdMaxBusySessions","100")).intValue());
+ this.maxBusySessions = Math.max(1, Integer.parseInt(switchboard.getConfig("httpdMaxBusySessions","100")));
this.lastAutoTermination = System.currentTimeMillis();
@@ -260,7 +260,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
bindIP = extendedPortString.substring(0,pos).trim();
extendedPortString = extendedPortString.substring(pos+1);
- if (bindIP.startsWith("#")) {
+ if (bindIP.length() > 0 && bindIP.charAt(0) == '#') {
final String interfaceName = bindIP.substring(1);
String hostName = null;
if (this.log.isFine()) this.log.logFine("Trying to determine IP address of interface '" + interfaceName + "'.");
@@ -773,7 +773,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
log.logSevere("command execution, method exception " + e.getMessage() + " for client " + this.userAddress.getHostAddress(), e);
if (!this.userAddress.isSiteLocalAddress()) {
if (denyHost != null) {
- denyHost.put((""+this.userAddress.getHostAddress()), "deny"); // block client: hacker attempt
+ denyHost.put(this.userAddress.getHostAddress(), "deny"); // block client: hacker attempt
}
}
break;
diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java
index d81eeb109..bcffeb790 100644
--- a/source/de/anomic/server/serverSwitch.java
+++ b/source/de/anomic/server/serverSwitch.java
@@ -272,7 +272,7 @@ public class serverSwitch {
}
public boolean getConfigBool(final String key, final boolean dflt) {
- return Boolean.valueOf(getConfig(key, Boolean.toString(dflt))).booleanValue();
+ return Boolean.parseBoolean(getConfig(key, Boolean.toString(dflt)));
}
/**
diff --git a/source/de/anomic/tools/CryptoLib.java b/source/de/anomic/tools/CryptoLib.java
index fad015881..7979ab954 100644
--- a/source/de/anomic/tools/CryptoLib.java
+++ b/source/de/anomic/tools/CryptoLib.java
@@ -75,8 +75,8 @@ public class CryptoLib {
public static final int bitkey = 1024;
public static final String signAlgorithm = "SHA1with"+algorithm;
- private KeyFactory keyFact;
- private Signature sign;
+ private final KeyFactory keyFact;
+ private final Signature sign;
public CryptoLib() throws NoSuchAlgorithmException {
keyFact = KeyFactory.getInstance(algorithm);
diff --git a/source/de/anomic/yacy/dht/Dispatcher.java b/source/de/anomic/yacy/dht/Dispatcher.java
index 95c8c4701..6571260b1 100755
--- a/source/de/anomic/yacy/dht/Dispatcher.java
+++ b/source/de/anomic/yacy/dht/Dispatcher.java
@@ -84,19 +84,19 @@ public class Dispatcher {
private Map<ByteArray, Transmission.Chunk> transmissionCloud;
// the segment backend is used to store the remaining indexContainers in case that the object is closed
- private Segment segment;
+ private final Segment segment;
// the seed database
- private yacySeedDB seeds;
+ private final yacySeedDB seeds;
// the log
- private Log log;
+ private final Log log;
// transmission process
private WorkflowProcessor<Transmission.Chunk> indexingTransmissionProcessor;
// transmission object
- private Transmission transmission;
+ private final Transmission transmission;
public Dispatcher(
final Segment segment,
diff --git a/source/de/anomic/yacy/dht/PeerSelection.java b/source/de/anomic/yacy/dht/PeerSelection.java
index c19e3df58..9b7b5f0e7 100755
--- a/source/de/anomic/yacy/dht/PeerSelection.java
+++ b/source/de/anomic/yacy/dht/PeerSelection.java
@@ -77,43 +77,15 @@ public class PeerSelection {
}
private static int guessedOwn = 0;
- //private static int guessedNotOwn = 0;
- private static int verifiedOwn = 0;
- private static int verifiedNotOwn = 0;
public static boolean shallBeOwnWord(final yacySeedDB seedDB, final byte[] wordhash, String urlhash, int redundancy) {
// the guessIfOwnWord is a fast method that should only fail in case that a 'true' may be incorrect, but a 'false' shall always be correct
if (guessIfOwnWord(seedDB, wordhash, urlhash)) {
// this case must be verified, because it can be wrong.
guessedOwn++;
- if (verifyIfOwnWord(seedDB, wordhash, urlhash, redundancy)) {
- // this is the correct case, but does not need to be an average case
- verifiedOwn++;
- //System.out.println("*** DEBUG shallBeOwnWord: true. guessed: true. verified/guessed ration = " + verifiedOwn + "/" + guessedOwn);
- return true;
- } else {
- // this may happen, but can be corrected
- verifiedNotOwn++;
- //System.out.println("*** DEBUG shallBeOwnWord: false. guessed: true. verified/guessed ration = " + verifiedNotOwn + "/" + guessedNotOwn);
- return false;
- }
+ return verifyIfOwnWord(seedDB, wordhash, urlhash, redundancy);
} else {
return false;
- /*
- // this should mean that the guessing should not be wrong
- guessedNotOwn++;
- if (yacyPeerSelection.verifyIfOwnWord(seedDB, wordhash, redundancy)) {
- // this should never happen
- verifiedOwn++;
- System.out.println("*** DEBUG shallBeOwnWord: true. guessed: false. verified/guessed ration = " + verifiedOwn + "/" + guessedOwn);
- return true;
- } else {
- // this should always happen
- verifiedNotOwn++;
- //System.out.println("*** DEBUG shallBeOwnWord: false. guessed: false. verified/guessed ration = " + verifiedNotOwn + "/" + guessedNotOwn);
- return false;
- }
- */
}
}
@@ -176,10 +148,10 @@ public class PeerSelection {
private static class acceptRemoteIndexSeedEnum implements Iterator<yacySeed> {
- private Iterator<yacySeed> se;
+ private final Iterator<yacySeed> se;
private yacySeed nextSeed;
- private yacySeedDB seedDB;
- private HashSet<String> doublecheck;
+ private final yacySeedDB seedDB;
+ private final HashSet<String> doublecheck;
private int remaining;
private boolean alsoMyOwn;
diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.java
index 13af4fd5b..bc4c72a3d 100644
--- a/source/de/anomic/yacy/dht/Transmission.java
+++ b/source/de/anomic/yacy/dht/Transmission.java
@@ -82,11 +82,11 @@ public class Transmission {
* - a set of yacy seeds which will shrink as the containers are transmitted to them
* - a counter that gives the number of sucessful and unsuccessful transmissions so far
*/
- private byte[] primaryTarget;
- private ReferenceContainerCache<WordReference> containers;
- private HashMap<String, URIMetadataRow> references;
- private HashSet<String> badReferences;
- private ArrayList<yacySeed> targets;
+ private final byte[] primaryTarget;
+ private final ReferenceContainerCache<WordReference> containers;
+ private final HashMap<String, URIMetadataRow> references;
+ private final HashSet<String> badReferences;
+ private final ArrayList<yacySeed> targets;
private int hit, miss;
/**
diff --git a/source/de/anomic/yacy/graphics/NetworkGraph.java b/source/de/anomic/yacy/graphics/NetworkGraph.java
index 8e1cd11de..28724d6c6 100644
--- a/source/de/anomic/yacy/graphics/NetworkGraph.java
+++ b/source/de/anomic/yacy/graphics/NetworkGraph.java
@@ -407,7 +407,7 @@ public class NetworkGraph {
//[MN]
private static String addBlanksAndDots(final long input, final int length) {
- return addBlanksAndDots(input + "", length);
+ return addBlanksAndDots(Long.toString(input), length);
}
//[MN]
diff --git a/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java b/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java
index b669da8a9..080907dc4 100644
--- a/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java
+++ b/source/de/anomic/yacy/seedUpload/yacySeedUploadScp.java
@@ -75,7 +75,7 @@ public class yacySeedUploadScp implements yacySeedUploader {
throw new Exception("Seed SCP upload settings not configured properly. Server port must not be null or empty.");
int port = 22;
try {
- port = Integer.valueOf(seedScpServerPort).intValue();
+ port = Integer.parseInt(seedScpServerPort);
} catch (final NumberFormatException ex) {
throw new Exception("Seed SCP upload settings not configured properly. Server port is not a vaild integer.");
}
diff --git a/source/de/anomic/yacy/yacyBuildProperties.java b/source/de/anomic/yacy/yacyBuildProperties.java
index e0be04f52..577b45d15 100644
--- a/source/de/anomic/yacy/yacyBuildProperties.java
+++ b/source/de/anomic/yacy/yacyBuildProperties.java
@@ -6,7 +6,7 @@ import de.anomic.yacy.yacyBuildProperties;
/**
* Properties set when compiling this release/version
*/
-public class yacyBuildProperties {
+public final class yacyBuildProperties {
private yacyBuildProperties() {
}
diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.java
index d03179b85..07e41dd61 100644
--- a/source/de/anomic/yacy/yacyVersion.java
+++ b/source/de/anomic/yacy/yacyVersion.java
@@ -24,11 +24,11 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
public static double latestRelease = 0.1; //
private float releaseNr;
- private String dateStamp;
+ private final String dateStamp;
private int svn;
- private boolean mainRelease;
+ private final boolean mainRelease;
- private String name;
+ private final String name;
/**
* parse a release file name
diff --git a/source/net/sbbi/upnp/DiscoveryAdvertisement.java b/source/net/sbbi/upnp/DiscoveryAdvertisement.java
index 5986440f4..10dffdb1b 100644
--- a/source/net/sbbi/upnp/DiscoveryAdvertisement.java
+++ b/source/net/sbbi/upnp/DiscoveryAdvertisement.java
@@ -72,7 +72,7 @@ import org.apache.commons.logging.LogFactory;
* @version 1.0
*/
@SuppressWarnings("unchecked")
-public class DiscoveryAdvertisement implements Runnable {
+public final class DiscoveryAdvertisement implements Runnable {
private final static Log log = LogFactory.getLog( DiscoveryAdvertisement.class );
@@ -92,9 +92,9 @@ public class DiscoveryAdvertisement implements Runnable {
private final static String NTS_SSDP_BYE_BYE = "ssdp:byebye";
private final static String NT_ALL_EVENTS = "DiscoveryAdvertisement:nt:allevents";
- private Map byeByeRegistered = new HashMap();
- private Map aliveRegistered = new HashMap();
- private Map USNPerIP = new HashMap();
+ private final Map byeByeRegistered = new HashMap();
+ private final Map aliveRegistered = new HashMap();
+ private final Map USNPerIP = new HashMap();
private final Object REGISTRATION_PROCESS = new Object();
diff --git a/source/net/sbbi/upnp/DiscoveryListener.java b/source/net/sbbi/upnp/DiscoveryListener.java
index f62daed5f..da5ec04eb 100644
--- a/source/net/sbbi/upnp/DiscoveryListener.java
+++ b/source/net/sbbi/upnp/DiscoveryListener.java
@@ -69,7 +69,7 @@ import org.apache.commons.logging.LogFactory;
* @version 1.0
*/
@SuppressWarnings("unchecked")
-public class DiscoveryListener implements Runnable {
+public final class DiscoveryListener implements Runnable {
private final static Log log = LogFactory.getLog( DiscoveryListener.class );
@@ -82,7 +82,7 @@ public class DiscoveryListener implements Runnable {
private static final int DEFAULT_TIMEOUT = 250;
- private Map registeredHandlers = new HashMap();
+ private final Map registeredHandlers = new HashMap();
private final Object REGISTRATION_PROCESS = new Object();
diff --git a/source/net/sbbi/upnp/HttpResponse.java b/source/net/sbbi/upnp/HttpResponse.java
index 9fb6ee34b..dbcd20534 100644
--- a/source/net/sbbi/upnp/HttpResponse.java
+++ b/source/net/sbbi/upnp/HttpResponse.java
@@ -59,8 +59,8 @@ import java.util.StringTokenizer;
@SuppressWarnings("unchecked")
public class HttpResponse {
- private String header;
- private Map fields;
+ private final String header;
+ private final Map fields;
private String body;
diff --git a/source/net/sbbi/upnp/JXPathParser.java b/source/net/sbbi/upnp/JXPathParser.java
index d0aa8a37d..4be108a7d 100644
--- a/source/net/sbbi/upnp/JXPathParser.java
+++ b/source/net/sbbi/upnp/JXPathParser.java
@@ -68,7 +68,7 @@ public class JXPathParser implements XMLParser {
private final static Log log = LogFactory.getLog( JXPathParser.class );
- private char buggyChar = (char)0;
+ private final char buggyChar = (char)0;
public Object parseXML( InputStream in ){
StringBuffer xml = new StringBuffer();
diff --git a/source/net/sbbi/upnp/ServiceEventMessageParser.java b/source/net/sbbi/upnp/ServiceEventMessageParser.java
index 51d4de707..b2e422ddf 100644
--- a/source/net/sbbi/upnp/ServiceEventMessageParser.java
+++ b/source/net/sbbi/upnp/ServiceEventMessageParser.java
@@ -64,7 +64,7 @@ public class ServiceEventMessageParser extends org.xml.sax.helpers.DefaultHandle
private String currentPropName = null;
- private Map changedStateVars = new HashMap();
+ private final Map changedStateVars = new HashMap();
protected ServiceEventMessageParser() {
}
diff --git a/source/net/sbbi/upnp/ServiceEventSubscription.java b/source/net/sbbi/upnp/ServiceEventSubscription.java
index 8fbfa3b7f..dbbf9699f 100644
--- a/source/net/sbbi/upnp/ServiceEventSubscription.java
+++ b/source/net/sbbi/upnp/ServiceEventSubscription.java
@@ -59,12 +59,12 @@ import java.net.URL;
public class ServiceEventSubscription {
- private String serviceType = null;
- private String serviceId = null;
- private URL serviceURL = null;
- private String SID = null;
- private InetAddress deviceIp = null;
- private int durationTime = 0;
+ private final String serviceType;
+ private final String serviceId;
+ private final URL serviceURL;
+ private final String SID;
+ private final InetAddress deviceIp;
+ private final int durationTime;
public ServiceEventSubscription( String serviceType, String serviceId, URL serviceURL,
String sid, InetAddress deviceIp, int durationTime ) {
diff --git a/source/net/sbbi/upnp/impls/InternetGatewayDevice.java b/source/net/sbbi/upnp/impls/InternetGatewayDevice.java
index ee607439a..d7b69ee79 100644
--- a/source/net/sbbi/upnp/impls/InternetGatewayDevice.java
+++ b/source/net/sbbi/upnp/impls/InternetGatewayDevice.java
@@ -439,7 +439,7 @@ public class InternetGatewayDevice {
StateVariableMessage natTableSize = msgFactory.getStateVariableMessage( "PortMappingNumberOfEntries" );
try {
StateVariableResponse resp = natTableSize.service();
- rtrval = new Integer( resp.getStateVariableValue() );
+ rtrval = Integer.valueOf( resp.getStateVariableValue() );
} catch ( UPNPResponseException ex ) {
// 404 can happen if device do not implement state variables queries
if ( ex.getDetailErrorCode() != 404 ) {
@@ -492,7 +492,7 @@ public class InternetGatewayDevice {
throw ex;
}
}
- return new Integer( size );
+ return Integer.valueOf( size );
}
private void checkPortMappingProtocol( String prot ) throws IllegalArgumentException {
diff --git a/source/net/sbbi/upnp/messages/ActionMessage.java b/source/net/sbbi/upnp/messages/ActionMessage.java
index 806598bad..551dc8de2 100644
--- a/source/net/sbbi/upnp/messages/ActionMessage.java
+++ b/source/net/sbbi/upnp/messages/ActionMessage.java
@@ -71,8 +71,8 @@ public class ActionMessage {
private final static Log log = LogFactory.getLog( ActionMessage.class );
- private UPNPService service;
- private ServiceAction serviceAction;
+ private final UPNPService service;
+ private final ServiceAction serviceAction;
private List inputParameters;
/**
diff --git a/source/net/sbbi/upnp/messages/ActionMessageResponseParser.java b/source/net/sbbi/upnp/messages/ActionMessageResponseParser.java
index ce9e29392..4aa9ae7d1 100644
--- a/source/net/sbbi/upnp/messages/ActionMessageResponseParser.java
+++ b/source/net/sbbi/upnp/messages/ActionMessageResponseParser.java
@@ -65,8 +65,8 @@ public class ActionMessageResponseParser extends org.xml.sax.helpers.DefaultHand
private final static String SOAP_FAULT_EL = "Fault";
- private ServiceAction serviceAction;
- private String bodyElementName;
+ private final ServiceAction serviceAction;
+ private final String bodyElementName;
private boolean faultResponse = false;
private UPNPResponseException msgEx;
diff --git a/source/net/sbbi/upnp/messages/ActionResponse.java b/source/net/sbbi/upnp/messages/ActionResponse.java
index 570f01646..9853a45f8 100644
--- a/source/net/sbbi/upnp/messages/ActionResponse.java
+++ b/source/net/sbbi/upnp/messages/ActionResponse.java
@@ -59,8 +59,8 @@ import java.util.*;
@SuppressWarnings("unchecked")
public class ActionResponse {
- private Map outArguments = new HashMap();
- private Map outArgumentsVals = new HashMap();
+ private final Map outArguments = new HashMap();
+ private final Map outArgumentsVals = new HashMap();
protected ActionResponse() {
}
diff --git a/source/net/sbbi/upnp/messages/StateVariableMessage.java b/source/net/sbbi/upnp/messages/StateVariableMessage.java
index 89fdf4b5d..93fe1546e 100644
--- a/source/net/sbbi/upnp/messages/StateVariableMessage.java
+++ b/source/net/sbbi/upnp/messages/StateVariableMessage.java
@@ -69,8 +69,8 @@ public class StateVariableMessage {
private final static Log log = LogFactory.getLog( StateVariableMessage.class );
- private UPNPService service;
- private ServiceStateVariable serviceStateVar;
+ private final UPNPService service;
+ private final ServiceStateVariable serviceStateVar;
protected StateVariableMessage( UPNPService service, ServiceStateVariable serviceStateVar ) {
this.service = service;
diff --git a/source/net/sbbi/upnp/messages/UPNPMessageFactory.java b/source/net/sbbi/upnp/messages/UPNPMessageFactory.java
index 9880582dc..9d40ab372 100644
--- a/source/net/sbbi/upnp/messages/UPNPMessageFactory.java
+++ b/source/net/sbbi/upnp/messages/UPNPMessageFactory.java
@@ -56,9 +56,9 @@ import net.sbbi.upnp.services.*;
* @version 1.0
*/
-public class UPNPMessageFactory {
+public final class UPNPMessageFactory {
- private UPNPService service;
+ private final UPNPService service;
/**
* Private constructor since this is a factory.
diff --git a/source/net/sbbi/upnp/services/ServiceStateVariable.java b/source/net/sbbi/upnp/services/ServiceStateVariable.java
index b3e01a4eb..5a3fb93b1 100644
--- a/source/net/sbbi/upnp/services/ServiceStateVariable.java
+++ b/source/net/sbbi/upnp/services/ServiceStateVariable.java
@@ -228,19 +228,19 @@ public class ServiceStateVariable implements ServiceStateVariableTypes {
if ( value == null ) throw new Exception( "null value" );
if ( dataType == null ) throw new Exception( "null dataType" );
int hash = dataType.hashCode();
- if ( hash == UI1_INT ) return new Short( value );
- else if ( hash == UI2_INT ) return new Integer( value );
- else if ( hash == UI4_INT ) return new Long( value );
- else if ( hash == I1_INT ) return new Byte( value );
- else if ( hash == I2_INT ) return new Short( value );
- else if ( hash == I4_INT ) return new Integer( value );
- else if ( hash == INT_INT ) return new Integer( value );
- else if ( hash == R4_INT ) return new Float( value );
- else if ( hash == R8_INT ) return new Double( value );
- else if ( hash == NUMBER_INT ) return new Double( value );
- else if ( hash == FIXED_14_4_INT ) return new Double( value );
- else if ( hash == FLOAT_INT ) return new Float( value );
- else if ( hash == CHAR_INT) return new Character( value.charAt( 0 ) );
+ if ( hash == UI1_INT ) return Short.valueOf( value );
+ else if ( hash == UI2_INT ) return Integer.valueOf( value );
+ else if ( hash == UI4_INT ) return Long.valueOf( value );
+ else if ( hash == I1_INT ) return Byte.valueOf( value );
+ else if ( hash == I2_INT ) return Short.valueOf( value );
+ else if ( hash == I4_INT ) return Integer.valueOf( value );
+ else if ( hash == INT_INT ) return Integer.valueOf( value );
+ else if ( hash == R4_INT ) return Float.valueOf( value );
+ else if ( hash == R8_INT ) return Double.valueOf( value );
+ else if ( hash == NUMBER_INT ) return Double.valueOf( value );
+ else if ( hash == FIXED_14_4_INT ) return Double.valueOf( value );
+ else if ( hash == FLOAT_INT ) return Float.valueOf( value );
+ else if ( hash == CHAR_INT) return Character.valueOf( value.charAt( 0 ) );
else if ( hash == STRING_INT ) return value;
else if ( hash == DATE_INT ) return ISO8601Date.parse( value );
else if ( hash == DATETIME_INT ) return ISO8601Date.parse( value );
diff --git a/source/net/yacy/ai/example/ConnectFour.java b/source/net/yacy/ai/example/ConnectFour.java
index d16571fe0..446c702dc 100755
--- a/source/net/yacy/ai/example/ConnectFour.java
+++ b/source/net/yacy/ai/example/ConnectFour.java
@@ -58,7 +58,7 @@ public class ConnectFour {
}
public static class Move extends AbstractFinding<Coin> implements Finding<Coin> {
- private int column;
+ private final int column;
public Move(Coin role, int column) {
super(role, (column > (width / 2)) ? (width - column - 1) : column);
this.column = column;
diff --git a/source/net/yacy/ai/greedy/AbstractFinding.java b/source/net/yacy/ai/greedy/AbstractFinding.java
index f8969c3c2..d8fe6ade2 100755
--- a/source/net/yacy/ai/greedy/AbstractFinding.java
+++ b/source/net/yacy/ai/greedy/AbstractFinding.java
@@ -30,7 +30,7 @@ import java.util.Comparator;
public abstract class AbstractFinding<SpecificRole extends Role> implements Finding<SpecificRole>, Comparator<Finding<SpecificRole>>, Comparable<Finding<SpecificRole>>, Cloneable {
- private SpecificRole role;
+ private final SpecificRole role;
private int priority;
/**
diff --git a/source/net/yacy/ai/greedy/Agent.java b/source/net/yacy/ai/greedy/Agent.java
index 8915c7515..b5b44fc4c 100755
--- a/source/net/yacy/ai/greedy/Agent.java
+++ b/source/net/yacy/ai/greedy/Agent.java
@@ -53,12 +53,12 @@ public class Agent<
Comparator<Agent<SpecificRole, SpecificFinding, SpecificModel>>,
Comparable<Agent<SpecificRole, SpecificFinding, SpecificModel>> {
- private Context<SpecificRole, SpecificFinding, SpecificModel> context;
- private SpecificModel model;
- private SpecificFinding finding;
+ private final Context<SpecificRole, SpecificFinding, SpecificModel> context;
+ private final SpecificModel model;
+ private final SpecificFinding finding;
private boolean findingFail; // a flag set by child nodes that signal that a specific role has terminated the branch below the current node
- private Agent<SpecificRole, SpecificFinding, SpecificModel> parentAgent; // the next parent node
- private int pathlength;
+ private final Agent<SpecificRole, SpecificFinding, SpecificModel> parentAgent; // the next parent node
+ private final int pathlength;
/**
* create a poison agent
diff --git a/source/net/yacy/ai/greedy/Asset.java b/source/net/yacy/ai/greedy/Asset.java
index 09dcfb35d..d19056d11 100755
--- a/source/net/yacy/ai/greedy/Asset.java
+++ b/source/net/yacy/ai/greedy/Asset.java
@@ -32,8 +32,8 @@ public class Asset<
SpecificModel extends Model<SpecificRole, SpecificFinding>
> {
- private SpecificModel model;
- private SpecificFinding finding;
+ private final SpecificModel model;
+ private final SpecificFinding finding;
public Asset(SpecificModel model, SpecificFinding finding) {
this.model = model;
diff --git a/source/net/yacy/ai/greedy/Challenge.java b/source/net/yacy/ai/greedy/Challenge.java
index 2e0951347..5d634d151 100755
--- a/source/net/yacy/ai/greedy/Challenge.java
+++ b/source/net/yacy/ai/greedy/Challenge.java
@@ -36,8 +36,8 @@ public class Challenge<
Comparator<Challenge<SpecificRole, SpecificFinding, SpecificModel>>,
Comparable<Challenge<SpecificRole, SpecificFinding, SpecificModel>> {
- private Agent<SpecificRole,SpecificFinding,SpecificModel> agent;
- private SpecificFinding finding;
+ private final Agent<SpecificRole,SpecificFinding,SpecificModel> agent;
+ private final SpecificFinding finding;
public Challenge() {
this.agent = null;
diff --git a/source/net/yacy/ai/greedy/Context.java b/source/net/yacy/ai/greedy/Context.java
index 4cd19a58d..340759410 100755
--- a/source/net/yacy/ai/greedy/Context.java
+++ b/source/net/yacy/ai/greedy/Context.java
@@ -40,18 +40,18 @@ public class Context<
>{
private static final Object PRESENT = new Object();
- private Goal<SpecificRole, SpecificFinding, SpecificModel> goal;
- private SpecificModel initialModel;
- private SpecificRole initialRole;
- private PriorityBlockingQueue<Challenge<SpecificRole, SpecificFinding, SpecificModel>> result;
- private ConcurrentHashMap<SpecificModel, Object> models; // caches all observed models for a double-check
- private ConcurrentHashMap<SpecificRole, Integer> bestMove;
- private AtomicInteger instances;
- private long timeoutForSnapshot;
+ private final Goal<SpecificRole, SpecificFinding, SpecificModel> goal;
+ private final SpecificModel initialModel;
+ private final SpecificRole initialRole;
+ private final PriorityBlockingQueue<Challenge<SpecificRole, SpecificFinding, SpecificModel>> result;
+ private final ConcurrentHashMap<SpecificModel, Object> models; // caches all observed models for a double-check
+ private final ConcurrentHashMap<SpecificRole, Integer> bestMove;
+ private final AtomicInteger instances;
+ private final long timeoutForSnapshot;
+ private final Semaphore termination;
+ private final boolean feedAssetCache, useAssetCache;
private long startTime;
private boolean fullfilled;
- private Semaphore termination;
- private boolean feedAssetCache, useAssetCache;
protected Context(
Goal<SpecificRole, SpecificFinding, SpecificModel> goal,
diff --git a/source/net/yacy/ai/greedy/ContextFactory.java b/source/net/yacy/ai/greedy/ContextFactory.java
index 4cd7332da..d89f53633 100644
--- a/source/net/yacy/ai/greedy/ContextFactory.java
+++ b/source/net/yacy/ai/greedy/ContextFactory.java
@@ -32,9 +32,9 @@ public class ContextFactory<
SpecificModel extends Model<SpecificRole, SpecificFinding>
>{
- private Goal<SpecificRole, SpecificFinding, SpecificModel> goal;
- private long timeoutForSnapshot;
- private boolean feedAssetCache, useAssetCache;
+ private final Goal<SpecificRole, SpecificFinding, SpecificModel> goal;
+ private final long timeoutForSnapshot;
+ private final boolean feedAssetCache, useAssetCache;
public ContextFactory(
Goal<SpecificRole, SpecificFinding, SpecificModel> goal,
diff --git a/source/net/yacy/ai/greedy/Engine.java b/source/net/yacy/ai/greedy/Engine.java
index 1abb39425..7ae787097 100755
--- a/source/net/yacy/ai/greedy/Engine.java
+++ b/source/net/yacy/ai/greedy/Engine.java
@@ -37,13 +37,13 @@ public class Engine<
SpecificModel extends Model<SpecificRole, SpecificFinding>
> {
- private PriorityBlockingQueue<Agent<SpecificRole, SpecificFinding, SpecificModel>> agentQueue;
- private PriorityBlockingQueue<Challenge<SpecificRole, SpecificFinding, SpecificModel>> challengeQueue;
- private Agent<SpecificRole, SpecificFinding, SpecificModel> poisonAgent;
- private Challenge<SpecificRole, SpecificFinding, SpecificModel> poisonChallenge;
- private ConcurrentHashMap<SpecificModel, List<SpecificFinding>> settings;
- private ConcurrentHashMap<Asset<SpecificRole, SpecificFinding, SpecificModel>, SpecificModel> assets;
- private int cores;
+ private final PriorityBlockingQueue<Agent<SpecificRole, SpecificFinding, SpecificModel>> agentQueue;
+ private final PriorityBlockingQueue<Challenge<SpecificRole, SpecificFinding, SpecificModel>> challengeQueue;
+ private final Agent<SpecificRole, SpecificFinding, SpecificModel> poisonAgent;
+ private final Challenge<SpecificRole, SpecificFinding, SpecificModel> poisonChallenge;
+ private final ConcurrentHashMap<SpecificModel, List<SpecificFinding>> settings;
+ private final ConcurrentHashMap<Asset<SpecificRole, SpecificFinding, SpecificModel>, SpecificModel> assets;
+ private final int cores;
public Engine(int cores) {
diff --git a/source/net/yacy/dbtest.java b/source/net/yacy/dbtest.java
index 6c0778399..ba5e04b06 100644
--- a/source/net/yacy/dbtest.java
+++ b/source/net/yacy/dbtest.java
@@ -74,7 +74,7 @@ public class dbtest {
public boolean isValid() {
final String s = new String(this.value).trim();
if (s.length() == 0) return false;
- final long source = Long.valueOf(s).longValue();
+ final long source = Long.parseLong(s);
return new String(this.key).equals(new String(randomHash(source, source)));
}
diff --git a/source/net/yacy/document/AbstractParser.java b/source/net/yacy/document/AbstractParser.java
index 85db1f3e7..dd842f7d0 100644
--- a/source/net/yacy/document/AbstractParser.java
+++ b/source/net/yacy/document/AbstractParser.java
@@ -55,7 +55,7 @@ public abstract class AbstractParser implements Idiom {
/**
* Parser name
*/
- private String parserName;
+ private final String parserName;
/**
* The source file file size in bytes if the source document was passed
diff --git a/source/net/yacy/document/content/SurrogateReader.java b/source/net/yacy/document/content/SurrogateReader.java
index c62b8b47e..3b3682044 100644
--- a/source/net/yacy/document/content/SurrogateReader.java
+++ b/source/net/yacy/document/content/SurrogateReader.java
@@ -51,9 +51,9 @@ public class SurrogateReader extends DefaultHandler implements Runnable {
private boolean parsingValue;
private DCEntry surrogate;
private String elementName;
- private BlockingQueue<DCEntry> surrogates;
+ private final BlockingQueue<DCEntry> surrogates;
private SAXParser saxParser;
- private InputStream stream;
+ private final InputStream stream;
public SurrogateReader(final InputStream stream, int queueSize) throws IOException {
this.buffer = new StringBuilder();
diff --git a/source/net/yacy/document/content/dao/PhpBB3Dao.java b/source/net/yacy/document/content/dao/PhpBB3Dao.java
index 6c47f05df..f4c34be2c 100644
--- a/source/net/yacy/document/content/dao/PhpBB3Dao.java
+++ b/source/net/yacy/document/content/dao/PhpBB3Dao.java
@@ -47,8 +47,8 @@ import net.yacy.kelondro.logging.Log;
public class PhpBB3Dao implements Dao {
protected DatabaseConnection conn = null;
- private String urlstub, prefix;
- private HashMap<Integer, String> users;
+ private final String urlstub, prefix;
+ private final HashMap<Integer, String> users;
public PhpBB3Dao(
String urlstub,
diff --git a/source/net/yacy/document/geolocalization/Coordinates.java b/source/net/yacy/document/geolocalization/Coordinates.java
index 86a45e9e0..abf17a886 100644
--- a/source/net/yacy/document/geolocalization/Coordinates.java
+++ b/source/net/yacy/document/geolocalization/Coordinates.java
@@ -32,7 +32,7 @@ public class Coordinates implements Comparable<Coordinates>, Comparator<Coordina
private static final double tenmeter = 90.0 / 1.0e6;
- private double lon, lat;
+ private final double lon, lat;
public Coordinates(double lon, double lat) {
this.lon = lon;
diff --git a/source/net/yacy/document/geolocalization/OpenGeoDB.java b/source/net/yacy/document/geolocalization/OpenGeoDB.java
index 3c4156329..897ca242a 100644
--- a/source/net/yacy/document/geolocalization/OpenGeoDB.java
+++ b/source/net/yacy/document/geolocalization/OpenGeoDB.java
@@ -68,13 +68,13 @@ public class OpenGeoDB {
insensitiveCollator.setDecomposition(Collator.NO_DECOMPOSITION);
}
- private HashMap<Integer, String> locTypeHash2locType;
- private HashMap<Integer, Location> id2loc;
- private HashMap<Integer, Integer> id2locTypeHash;
- private TreeMap<String, List<Integer>> locationName2ids;
- private TreeMap<String, List<Integer>> kfz2ids;
- private HashMap<String, List<Integer>> predial2ids;
- private HashMap<String, Integer> zip2id;
+ private final HashMap<Integer, String> locTypeHash2locType;
+ private final HashMap<Integer, Location> id2loc;
+ private final HashMap<Integer, Integer> id2locTypeHash;
+ private final TreeMap<String, List<Integer>> locationName2ids;
+ private final TreeMap<String, List<Integer>> kfz2ids;
+ private final HashMap<String, List<Integer>> predial2ids;
+ private final HashMap<String, Integer> zip2id;
public OpenGeoDB(final File file) {
@@ -157,7 +157,7 @@ public class OpenGeoDB {
}
private static final String removeQuotes(String s) {
- if (s.charAt(0) != '\'') return s;
+ if (s.length() > 0 && s.charAt(0) != '\'') return s;
if (s.charAt(s.length() - 1) != '\'') return s;
s = s.substring(1, s.length() - 1);
return s;
diff --git a/source/net/yacy/document/importer/MediawikiImporter.java b/source/net/yacy/document/importer/MediawikiImporter.java
index 5daa93080..29366218f 100644
--- a/source/net/yacy/document/importer/MediawikiImporter.java
+++ b/source/net/yacy/document/importer/MediawikiImporter.java
@@ -89,8 +89,8 @@ public class MediawikiImporter extends Thread implements Importer {
public File targetdir;
public int count;
private long start;
- private long docsize;
- private int approxdocs;
+ private final long docsize;
+ private final int approxdocs;
public MediawikiImporter(File sourcefile, File targetdir, String baseURL) throws MalformedURLException {
@@ -332,7 +332,7 @@ public class MediawikiImporter extends Thread implements Importer {
private static class indexProducer implements Callable<Integer> {
- private BlockingQueue<wikisourcerecord> entries;
+ private final BlockingQueue<wikisourcerecord> entries;
PrintWriter out;
protected static wikisourcerecord poison = new wikisourcerecord("", 0, 0);
int count;
@@ -381,9 +381,9 @@ public class MediawikiImporter extends Thread implements Importer {
private static class wikiConsumer implements Callable<Integer> {
- private BlockingQueue<wikiraw> entries;
+ private final BlockingQueue<wikiraw> entries;
protected static wikiraw poison = new wikiraw(new byte[0], 0, 0);
- private indexProducer producer;
+ private final indexProducer producer;
private int count;
public wikiConsumer(int bufferCount, indexProducer producer) {
@@ -511,7 +511,7 @@ public class MediawikiImporter extends Thread implements Importer {
private static class PositionAwareReader {
- private InputStream is;
+ private final InputStream is;
private long seekpos;
private ByteBuffer bb;
@@ -608,8 +608,8 @@ public class MediawikiImporter extends Thread implements Importer {
private static class convertConsumer implements Callable<Integer> {
- private BlockingQueue<wikiparserrecord> in, out;
- private wikiparserrecord poison;
+ private final BlockingQueue<wikiparserrecord> in, out;
+ private final wikiparserrecord poison;
public convertConsumer(BlockingQueue<wikiparserrecord> in, BlockingQueue<wikiparserrecord> out, wikiparserrecord poison) {
this.poison = poison;
@@ -650,11 +650,11 @@ public class MediawikiImporter extends Thread implements Importer {
private static class convertWriter implements Callable<Integer> {
- private BlockingQueue<wikiparserrecord> in;
- private wikiparserrecord poison;
+ private final BlockingQueue<wikiparserrecord> in;
+ private final wikiparserrecord poison;
private OutputStreamWriter osw;
- private String targetstub;
- private File targetdir;
+ private final String targetstub;
+ private final File targetdir;
private int fc, rc;
private String outputfilename;
diff --git a/source/net/yacy/document/importer/OAIPMHImporter.java b/source/net/yacy/document/importer/OAIPMHImporter.java
index d247679b5..66b6a093f 100644
--- a/source/net/yacy/document/importer/OAIPMHImporter.java
+++ b/source/net/yacy/document/importer/OAIPMHImporter.java
@@ -68,13 +68,14 @@ public class OAIPMHImporter extends Thread implements Importer, Comparable<OAIPM
public static TreeSet<OAIPMHImporter> runningJobs = new TreeSet<OAIPMHImporter>();
public static TreeSet<OAIPMHImporter> finishedJobs = new TreeSet<OAIPMHImporter>();
- private LoaderDispatcher loader;
+ private final LoaderDispatcher loader;
private DigestURI source;
private int recordsCount, chunkCount;
- private long startTime, finishTime;
- private ResumptionToken resumptionToken;
+ private final long startTime;
+ private long finishTime;
+ private final ResumptionToken resumptionToken;
private String message;
- private int serialNumber;
+ private final int serialNumber;
public OAIPMHImporter(LoaderDispatcher loader, DigestURI source) {
this.serialNumber = importerCounter--;
diff --git a/source/net/yacy/document/importer/OAIPMHReader.java b/source/net/yacy/document/importer/OAIPMHReader.java
index 2023b066d..7bd071625 100644
--- a/source/net/yacy/document/importer/OAIPMHReader.java
+++ b/source/net/yacy/document/importer/OAIPMHReader.java
@@ -46,8 +46,8 @@ import de.anomic.crawler.retrieval.Response;
public class OAIPMHReader {
- private DigestURI source;
- private ResumptionToken resumptionToken;
+ private final DigestURI source;
+ private final ResumptionToken resumptionToken;
public OAIPMHReader(LoaderDispatcher loader, DigestURI source, File targetDir, String filePrefix) throws IOException {
this.source = source;
diff --git a/source/net/yacy/document/language/Identificator.java b/source/net/yacy/document/language/Identificator.java
index e7fef8c43..787ce7e7e 100644
--- a/source/net/yacy/document/language/Identificator.java
+++ b/source/net/yacy/document/language/Identificator.java
@@ -37,7 +37,7 @@ public final class Identificator {
private static final LanguageStatisticsHolder languages = LanguageStatisticsHolder.getInstance();
- private HashMap<Character, Integer> letter;
+ private final HashMap<Character, Integer> letter;
private int letters;
private String language;
diff --git a/source/net/yacy/document/language/LanguageStatisticsHolder.java b/source/net/yacy/document/language/LanguageStatisticsHolder.java
index 3de650a0d..0581e4896 100644
--- a/source/net/yacy/document/language/LanguageStatisticsHolder.java
+++ b/source/net/yacy/document/language/LanguageStatisticsHolder.java
@@ -36,7 +36,7 @@ import net.yacy.kelondro.logging.Log;
* It has been implemented as a Singleton since it has to access several
* files on instanciation which should be avoided since it is very slow.
*/
-public class LanguageStatisticsHolder extends Vector<LanguageStatistics> {
+public final class LanguageStatisticsHolder extends Vector<LanguageStatistics> {
private static final long serialVersionUID = -887517724227204705L;
diff --git a/source/net/yacy/document/parser/html/ContentTransformer.java b/source/net/yacy/document/parser/html/ContentTransformer.java
index c2d1979e4..cf9aa9d72 100644
--- a/source/net/yacy/document/parser/html/ContentTransformer.java
+++ b/source/net/yacy/document/parser/html/ContentTransformer.java
@@ -72,7 +72,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.startsWith("#") && s.length() > 0) bluelist.add(s.toLowerCase());
+ if (s.length() > 0 && s.charAt(0) != '#') 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 0316abffb..369039b0e 100644
--- a/source/net/yacy/document/parser/html/ScraperInputStream.java
+++ b/source/net/yacy/document/parser/html/ScraperInputStream.java
@@ -92,7 +92,7 @@ public class ScraperInputStream extends InputStream implements ScraperListener {
final String param = parts[i].trim();
if (param.startsWith("charset=")) {
String charset = param.substring("charset=".length()).trim();
- if (charset.startsWith("\"") || charset.startsWith("'")) charset = charset.substring(1);
+ if (charset.length() > 0 && (charset.charAt(0) == '\"' || charset.charAt(0) == '\'')) charset = charset.substring(1);
if (charset.endsWith("\"") || charset.endsWith("'")) charset = charset.substring(0,charset.length()-1);
return charset.trim();
}
diff --git a/source/net/yacy/document/parser/html/TransformerWriter.java b/source/net/yacy/document/parser/html/TransformerWriter.java
index 5564bb2ad..8bf05c9cd 100644
--- a/source/net/yacy/document/parser/html/TransformerWriter.java
+++ b/source/net/yacy/document/parser/html/TransformerWriter.java
@@ -367,7 +367,7 @@ public final class TransformerWriter extends Writer {
buffer.append(c);
if (c == singlequote) inSingleQuote = false;
// check error cases
- if ((c == rb) && (buffer.charAt(0) == lb)) {
+ if ((c == rb) && (buffer.length() > 0 && buffer.charAt(0) == lb)) {
inSingleQuote = false;
// the tag ends here. after filtering: pass on
filtered = filterSentence(buffer.getChars(), singlequote);
@@ -379,7 +379,7 @@ public final class TransformerWriter extends Writer {
buffer.append(c);
if (c == doublequote) inDoubleQuote = false;
// check error cases
- if (c == rb && buffer.charAt(0) == lb) {
+ if (c == rb && buffer.length() > 0 && buffer.charAt(0) == lb) {
inDoubleQuote = false;
// the tag ends here. after filtering: pass on
filtered = filterSentence(buffer.getChars(), doublequote);
@@ -441,7 +441,7 @@ public final class TransformerWriter extends Writer {
} else {
buffer.append(c);
}
- } else if (buffer.charAt(0) == lb) {
+ } else if (buffer.length() > 0 && buffer.charAt(0) == lb) {
if (c == singlequote) inSingleQuote = true;
if (c == doublequote) inDoubleQuote = true;
// fill in tag text
diff --git a/source/net/yacy/document/parser/psParser.java b/source/net/yacy/document/parser/psParser.java
index fb704a865..afb2f29c1 100644
--- a/source/net/yacy/document/parser/psParser.java
+++ b/source/net/yacy/document/parser/psParser.java
@@ -161,7 +161,7 @@ public class psParser extends AbstractParser implements Idiom {
boolean isComment = false;
boolean isText = false;
- if (version.startsWith("2")) {
+ if (version.length() > 0 && version.charAt(0) == '2') {
boolean isConnector = false;
while ((ichar = reader.read()) > 0) {
@@ -184,7 +184,7 @@ public class psParser extends AbstractParser implements Idiom {
}
}
- } else if (version.startsWith("3")) {
+ } else if (version.length() > 0 && version.charAt(0) == '3') {
final StringBuilder stmt = new StringBuilder();
boolean isBMP = false;
boolean isStore = false;
diff --git a/source/net/yacy/document/parser/xml/ODContentHandler.java b/source/net/yacy/document/parser/xml/ODContentHandler.java
index 39a5603e9..684de9b55 100644
--- a/source/net/yacy/document/parser/xml/ODContentHandler.java
+++ b/source/net/yacy/document/parser/xml/ODContentHandler.java
@@ -41,7 +41,7 @@ import org.xml.sax.helpers.DefaultHandler;
*
*/
public class ODContentHandler extends DefaultHandler {
- private Writer out;
+ private final Writer out;
public ODContentHandler(Writer out) {
this.out = out;
}
diff --git a/source/net/yacy/document/parser/xml/ODMetaHandler.java b/source/net/yacy/document/parser/xml/ODMetaHandler.java
index 5210cb68f..b068548c4 100644
--- a/source/net/yacy/document/parser/xml/ODMetaHandler.java
+++ b/source/net/yacy/document/parser/xml/ODMetaHandler.java
@@ -31,7 +31,7 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class ODMetaHandler extends DefaultHandler {
- private StringBuilder buffer = new StringBuilder();
+ private final StringBuilder buffer = new StringBuilder();
private String docCreator = null;
private String docLanguage = null;
diff --git a/source/net/yacy/kelondro/blob/ArrayStack.java b/source/net/yacy/kelondro/blob/ArrayStack.java
index e14ccc28d..818277055 100755
--- a/source/net/yacy/kelondro/blob/ArrayStack.java
+++ b/source/net/yacy/kelondro/blob/ArrayStack.java
@@ -80,19 +80,19 @@ public class ArrayStack implements BLOB {
public static final long oneMonth = 1000L * 60L * 60L * 24L * 365L / 12L;
- protected int keylength;
- protected ByteOrder ordering;
- private File heapLocation;
- private long fileAgeLimit;
- private long fileSizeLimit;
- private long repositoryAgeMax;
- private long repositorySizeMax;
- protected List<blobItem> blobs;
- private String prefix;
- private int buffersize;
+ protected int keylength;
+ protected ByteOrder ordering;
+ private final File heapLocation;
+ private long fileAgeLimit;
+ private long fileSizeLimit;
+ private long repositoryAgeMax;
+ private long repositorySizeMax;
+ protected List<blobItem> blobs;
+ private final String prefix;
+ private final int buffersize;
// the thread pool for the keeperOf executor service
- private ExecutorService executor;
+ private final ExecutorService executor;
public ArrayStack(
final File heapLocation,
@@ -608,9 +608,9 @@ public class ArrayStack implements BLOB {
public class BlobValues implements Iterator<byte[]>, Iterable<byte[]> {
- private Iterator<blobItem> bii;
+ private final Iterator<blobItem> bii;
+ private final byte[] key;
private byte[] next;
- private byte[] key;
public BlobValues(byte[] key) {
this.bii = blobs.iterator();
diff --git a/source/net/yacy/kelondro/blob/Compressor.java b/source/net/yacy/kelondro/blob/Compressor.java
index 3a6cc393a..388a413aa 100644
--- a/source/net/yacy/kelondro/blob/Compressor.java
+++ b/source/net/yacy/kelondro/blob/Compressor.java
@@ -49,10 +49,10 @@ public class Compressor implements BLOB {
static byte[] gzipMagic = {(byte) 'z', (byte) '|'}; // magic for gzip-encoded content
static byte[] plainMagic = {(byte) 'p', (byte) '|'}; // magic for plain content (no encoding)
- private BLOB backend;
+ private final BLOB backend;
private HashMap<String, byte[]> buffer; // entries which are not yet compressed, format is RAW (without magic)
private long bufferlength;
- private long maxbufferlength;
+ private final long maxbufferlength;
public Compressor(BLOB backend, long buffersize) {
this.backend = backend;
diff --git a/source/net/yacy/kelondro/blob/Heap.java b/source/net/yacy/kelondro/blob/Heap.java
index 49275299f..e1b32405c 100755
--- a/source/net/yacy/kelondro/blob/Heap.java
+++ b/source/net/yacy/kelondro/blob/Heap.java
@@ -44,7 +44,7 @@ public final class Heap extends HeapModifier implements BLOB {
private HashMap<String, byte[]> buffer; // a write buffer to limit IO to the file; attention: Maps cannot use byte[] as key
private int buffersize; // bytes that are buffered in buffer
- private int buffermax; // maximum size of the buffer
+ private final int buffermax; // maximum size of the buffer
/*
* This class implements a BLOB management based on a sequence of records in a random access file
diff --git a/source/net/yacy/kelondro/blob/HeapReader.java b/source/net/yacy/kelondro/blob/HeapReader.java
index bbd3bb34c..e0f70864d 100644
--- a/source/net/yacy/kelondro/blob/HeapReader.java
+++ b/source/net/yacy/kelondro/blob/HeapReader.java
@@ -497,7 +497,7 @@ public class HeapReader {
DataInputStream is;
int keylen;
- private File blobFile;
+ private final File blobFile;
Map.Entry<String, byte[]> nextEntry;
public entries(final File blobFile, final int keylen) throws IOException {
@@ -569,7 +569,7 @@ public class HeapReader {
}
public static class entry implements Map.Entry<String, byte[]> {
- private String s;
+ private final String s;
private byte[] b;
public entry(final String s, final byte[] b) {
diff --git a/source/net/yacy/kelondro/blob/HeapWriter.java b/source/net/yacy/kelondro/blob/HeapWriter.java
index 8bdd8bc89..30e01844f 100644
--- a/source/net/yacy/kelondro/blob/HeapWriter.java
+++ b/source/net/yacy/kelondro/blob/HeapWriter.java
@@ -40,7 +40,7 @@ import net.yacy.kelondro.util.FileUtils;
public final class HeapWriter {
- private int keylength; // the length of the primary key
+ private final int keylength; // the length of the primary key
private HandleMap index; // key/seek relation for used records
private final File heapFileTMP; // the temporary file of the heap during writing
private final File heapFileREADY; // the final file of the heap when the file is closed
@@ -100,7 +100,7 @@ public final class HeapWriter {
assert index.row().primaryKeyLength == key.length : index.row().primaryKeyLength + "!=" + key.length;
assert index.get(key) < 0 : "index.get(key) = " + index.get(key) + ", index.size() = " + index.size() + ", file.length() = " + this.heapFileTMP.length() + ", key = " + new String(key); // must not occur before
if ((blob == null) || (blob.length == 0)) return;
- index.putUnique(key, seek);
+ index.putUnique(key, this.seek);
int chunkl = key.length + blob.length;
os.writeInt(chunkl);
os.write(key);
diff --git a/source/net/yacy/kelondro/blob/Stack.java b/source/net/yacy/kelondro/blob/Stack.java
index 8ee691dc3..59abf47e0 100644
--- a/source/net/yacy/kelondro/blob/Stack.java
+++ b/source/net/yacy/kelondro/blob/Stack.java
@@ -34,7 +34,7 @@ import net.yacy.kelondro.order.NaturalOrder;
public class Stack {
- private Heap stack;
+ private final Heap stack;
private long lastHandle;
/**
diff --git a/source/net/yacy/kelondro/blob/Stacks.java b/source/net/yacy/kelondro/blob/Stacks.java
index d7cc710ed..9e7277e75 100644
--- a/source/net/yacy/kelondro/blob/Stacks.java
+++ b/source/net/yacy/kelondro/blob/Stacks.java
@@ -36,7 +36,7 @@ public class Stacks {
File stacksLocation;
String stacksPrefix;
- private ConcurrentHashMap<String, StackInstance> stacks;
+ private final ConcurrentHashMap<String, StackInstance> stacks;
/**
* create a stack organizing object.
@@ -69,7 +69,7 @@ public class Stacks {
private class StackInstance {
String name;
- private File location;
+ private final File location;
Stack stack;
public StackInstance(final File location) throws IOException {
diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.java
index aadcb4db5..2d94881f1 100644
--- a/source/net/yacy/kelondro/data/meta/DigestURI.java
+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java
@@ -162,7 +162,7 @@ public class DigestURI implements Serializable {
}
} else {
host = null;
- if (h.startsWith("/")) {
+ if (h.length() > 0 && h.charAt(0) == '/') {
char c = h.charAt(2);
if (c == ':' || c == '|')
path = h.substring(1);
@@ -256,15 +256,15 @@ public class DigestURI implements Serializable {
this.path = baseURL.path;
} else if (relPath.contains(":") && patternMail.matcher(relPath.toLowerCase()).find()) { // discards also any unknown protocol from previous if
throw new MalformedURLException("relative path malformed: " + relPath);
- } else if (relPath.startsWith("/")) {
+ } else if (relPath.length() > 0 && relPath.charAt(0) == '/') {
this.path = relPath;
} else if (baseURL.path.endsWith("/")) {
- if (relPath.startsWith("#") || relPath.startsWith("?")) {
+ if (relPath.length() > 0 && (relPath.charAt(0) == '#' || relPath.charAt(0) == '?')) {
throw new MalformedURLException("relative path malformed: " + relPath);
}
this.path = baseURL.path + relPath;
} else {
- if (relPath.startsWith("#") || relPath.startsWith("?")) {
+ if (relPath.length() > 0 && (relPath.charAt(0) == '#' || relPath.charAt(0) == '?')) {
this.path = baseURL.path + relPath;
} else {
final int q = baseURL.path.lastIndexOf('/');
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
index 9900dbe59..0a07e5000 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java
@@ -292,7 +292,7 @@ public class URIMetadataRow implements URIMetadata {
}
public static URIMetadataRow importEntry(final String propStr) {
- if (propStr == null || !propStr.startsWith("{") || !propStr.endsWith("}")) {
+ if (propStr == null || (propStr.length() > 0 && propStr.charAt(0) != '{') || !propStr.endsWith("}")) {
return null;
}
try {
@@ -368,14 +368,19 @@ public class URIMetadataRow implements URIMetadata {
if (this.comp != null) return this.comp;
// parse elements from comp string;
final Iterator<String> cl = FileUtils.strings(this.entry.getCol("comp", null));
- this.comp = new Components(
- (cl.hasNext()) ? cl.next() : "",
- hash(),
- (cl.hasNext()) ? cl.next() : "",
- (cl.hasNext()) ? cl.next() : "",
- (cl.hasNext()) ? cl.next() : "",
- (cl.hasNext()) ? cl.next() : "");
- return this.comp;
+ try {
+ this.comp = new Components(
+ (cl.hasNext()) ? cl.next() : "",
+ hash(),
+ (cl.hasNext()) ? cl.next() : "",
+ (cl.hasNext()) ? cl.next() : "",
+ (cl.hasNext()) ? cl.next() : "",
+ (cl.hasNext()) ? cl.next() : "");
+ return this.comp;
+ } catch (MalformedURLException e) {
+ Log.logWarning("URLMetadataRow", "corrupted component / url: " + e.getMessage(), e);
+ return null;
+ }
}
public Date moddate() {
@@ -515,15 +520,11 @@ public class URIMetadataRow implements URIMetadata {
}
public class Components {
- private DigestURI url;
+ private final DigestURI url;
private final String dc_title, dc_creator, dc_subject, ETag;
- public Components(final String url, final String urlhash, final String title, final String author, final String tags, final String ETag) {
- try {
- this.url = new DigestURI(url, urlhash);
- } catch (final MalformedURLException e) {
- this.url = null;
- }
+ public Components(final String url, final String urlhash, final String title, final String author, final String tags, final String ETag) throws MalformedURLException {
+ this.url = new DigestURI(url, urlhash);
this.dc_title = title;
this.dc_creator = author;
this.dc_subject = tags;
diff --git a/source/net/yacy/kelondro/index/Cache.java b/source/net/yacy/kelondro/index/Cache.java
index c83811613..713e756d3 100644
--- a/source/net/yacy/kelondro/index/Cache.java
+++ b/source/net/yacy/kelondro/index/Cache.java
@@ -63,7 +63,7 @@ public final class Cache implements ObjectIndex, Iterable<Row.Entry> {
private Row keyrow;
private int readHit, readMiss, writeUnique, writeDouble, cacheDelete, cacheFlush;
private int hasnotHit, hasnotMiss, hasnotUnique, hasnotDouble, hasnotDelete;
- private int hitLimit, missLimit;
+ private final int hitLimit, missLimit;
/**
* create a ObjectIndex cache. The cache may either limited by a number of entries in the hit/miss cache
diff --git a/source/net/yacy/kelondro/index/Column.java b/source/net/yacy/kelondro/index/Column.java
index 190d6a966..a01878fe6 100644
--- a/source/net/yacy/kelondro/index/Column.java
+++ b/source/net/yacy/kelondro/index/Column.java
@@ -63,7 +63,7 @@ public final class Column {
// cut quotes etc.
celldef = celldef.trim();
- if (celldef.charAt(0) == '<') celldef = celldef.substring(1);
+ if (celldef.length() > 0 && celldef.charAt(0) == '<') celldef = celldef.substring(1);
if (celldef.endsWith(">")) celldef = celldef.substring(0, celldef.length() - 1);
// parse type definition
@@ -161,7 +161,7 @@ public final class Column {
) 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.length() > 0 && celldef.charAt(0) == '{') {
p = celldef.indexOf('}');
final String expf = celldef.substring(1, p);
celldef = celldef.substring(p + 1).trim();
@@ -183,7 +183,7 @@ public final class Column {
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.length() > 0 && 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/ConcurrentARC.java b/source/net/yacy/kelondro/index/ConcurrentARC.java
index 46a5b4b87..36aa10f99 100644
--- a/source/net/yacy/kelondro/index/ConcurrentARC.java
+++ b/source/net/yacy/kelondro/index/ConcurrentARC.java
@@ -36,16 +36,17 @@ package net.yacy.kelondro.index;
public final class ConcurrentARC<K, V> implements ARC<K, V> {
- private int mask;
+ private final int mask;
private final ARC<K, V> arc[];
@SuppressWarnings("unchecked")
public ConcurrentARC(final int cacheSize, final int partitions) {
- this.mask = 1;
- while (this.mask < partitions) this.mask = this.mask * 2;
- this.arc = new SimpleARC[mask];
- for (int i = 0; i < this.arc.length; i++) this.arc[i] = new SimpleARC<K, V>(cacheSize / this.mask);
- this.mask -= 1;
+ int m = 1;
+ while (m < partitions) m = m * 2;
+ this.arc = new SimpleARC[m];
+ for (int i = 0; i < this.arc.length; i++) this.arc[i] = new SimpleARC<K, V>(cacheSize / m);
+ m -= 1;
+ this.mask = m;
}
/**
diff --git a/source/net/yacy/kelondro/index/HandleMap.java b/source/net/yacy/kelondro/index/HandleMap.java
index 185b901f0..b17f8720b 100644
--- a/source/net/yacy/kelondro/index/HandleMap.java
+++ b/source/net/yacy/kelondro/index/HandleMap.java
@@ -316,8 +316,8 @@ public final class HandleMap implements Iterable<Row.Entry> {
public final static class initDataConsumer implements Callable<HandleMap> {
- private BlockingQueue<entry> cache;
- private HandleMap map;
+ private final BlockingQueue<entry> cache;
+ private final HandleMap map;
private Future<HandleMap> result;
private boolean sortAtEnd;
diff --git a/source/net/yacy/kelondro/index/Row.java b/source/net/yacy/kelondro/index/Row.java
index c01c13029..b445b6082 100644
--- a/source/net/yacy/kelondro/index/Row.java
+++ b/source/net/yacy/kelondro/index/Row.java
@@ -279,7 +279,7 @@ public final class Row {
public Entry(String external, final boolean decimalCardinal) {
// parse external form
- if (external.charAt(0) == '{') external = external.substring(1, external.length() - 1);
+ if (external.length() > 0 && external.charAt(0) == '{') external = external.substring(1, external.length() - 1);
final String[] elts = external.split(",");
if (nickref == null) genNickRef();
String nick;
diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.java
index 318253c9b..ceeb4d6c7 100644
--- a/source/net/yacy/kelondro/index/RowCollection.java
+++ b/source/net/yacy/kelondro/index/RowCollection.java
@@ -485,7 +485,7 @@ public class RowCollection implements Iterable<Row.Entry> {
public class keyIterator implements Iterator<byte[]> {
private int p;
- private boolean keepOrderWhenRemoving;
+ private final boolean keepOrderWhenRemoving;
public keyIterator(final boolean keepOrderWhenRemoving) {
this.p = 0;
diff --git a/source/net/yacy/kelondro/index/RowSpaceExceededException.java b/source/net/yacy/kelondro/index/RowSpaceExceededException.java
index e428eda77..f8bd12de7 100644
--- a/source/net/yacy/kelondro/index/RowSpaceExceededException.java
+++ b/source/net/yacy/kelondro/index/RowSpaceExceededException.java
@@ -34,8 +34,8 @@ public class RowSpaceExceededException extends Exception {
private static final long serialVersionUID = 9059516027929222151L;
- private String forUsage;
- private long neededRAM, availableRAM, time;
+ private final String forUsage;
+ private final long neededRAM, availableRAM, time;
public RowSpaceExceededException(final long neededRAM, final String forUsage) {
super(Long.toString(neededRAM) + " bytes needed for " + forUsage + ": " + MemoryControl.available() + " free at " + (new Date()).toString());
diff --git a/source/net/yacy/kelondro/io/CachedFileReader.java b/source/net/yacy/kelondro/io/CachedFileReader.java
index 15de29a87..3a26beb9e 100644
--- a/source/net/yacy/kelondro/io/CachedFileReader.java
+++ b/source/net/yacy/kelondro/io/CachedFileReader.java
@@ -33,7 +33,7 @@ public final class CachedFileReader extends AbstractReader implements Reader {
private final RandomAccessFile RAFile;
private byte[] cache;
- private int cachelen;
+ private final int cachelen;
public CachedFileReader(final File file) throws IOException, FileNotFoundException {
this.name = file.getName();
diff --git a/source/net/yacy/kelondro/order/Digest.java b/source/net/yacy/kelondro/order/Digest.java
index 1fd2d5e69..528f37ca0 100644
--- a/source/net/yacy/kelondro/order/Digest.java
+++ b/source/net/yacy/kelondro/order/Digest.java
@@ -200,8 +200,8 @@ public class Digest {
private static class md5FilechunkConsumer implements Callable<MessageDigest> {
- private BlockingQueue<filechunk> empty;
- private BlockingQueue<filechunk> filed;
+ private final BlockingQueue<filechunk> empty;
+ private final BlockingQueue<filechunk> filed;
protected static filechunk poison = new filechunk(0);
private MessageDigest digest;
diff --git a/source/net/yacy/kelondro/order/MergeIterator.java b/source/net/yacy/kelondro/order/MergeIterator.java
index 1893d132d..85b8e9e94 100644
--- a/source/net/yacy/kelondro/order/MergeIterator.java
+++ b/source/net/yacy/kelondro/order/MergeIterator.java
@@ -34,8 +34,9 @@ import net.yacy.kelondro.logging.Log;
public class MergeIterator<E> implements CloneableIterator<E> {
- private Comparator<E> comp;
- private CloneableIterator<E> a, b;
+ private final Comparator<E> comp;
+ private final CloneableIterator<E> a;
+ private final CloneableIterator<E> b;
private E na, nb;
private final Method merger;
private final boolean up;
diff --git a/source/net/yacy/kelondro/order/NaturalOrder.java b/source/net/yacy/kelondro/order/NaturalOrder.java
index e725bfdc1..118942863 100644
--- a/source/net/yacy/kelondro/order/NaturalOrder.java
+++ b/source/net/yacy/kelondro/order/NaturalOrder.java
@@ -243,7 +243,7 @@ public final class NaturalOrder extends AbstractOrder<byte[]> implements ByteOrd
public static class LongIter implements Iterator<Long> {
- private Iterator<byte[]> b256Iterator;
+ private final Iterator<byte[]> b256Iterator;
public LongIter(Iterator<byte[]> b256Iterator) {
this.b256Iterator = b256Iterator;
@@ -257,7 +257,7 @@ public final class NaturalOrder extends AbstractOrder<byte[]> implements ByteOrd
byte[] b = this.b256Iterator.next();
assert (b != null);
if (b == null) return null;
- return new Long(decodeLong(b));
+ return Long.valueOf(decodeLong(b));
}
public void remove() {
diff --git a/source/net/yacy/kelondro/order/StackIterator.java b/source/net/yacy/kelondro/order/StackIterator.java
index 4ef50cda5..beb2e832e 100644
--- a/source/net/yacy/kelondro/order/StackIterator.java
+++ b/source/net/yacy/kelondro/order/StackIterator.java
@@ -29,7 +29,7 @@ import java.util.Iterator;
public class StackIterator<E> implements CloneableIterator<E> {
- private CloneableIterator<E> a, b;
+ private final CloneableIterator<E> a, b;
private E na, nb;
public StackIterator(
diff --git a/source/net/yacy/kelondro/rwi/IODispatcher.java b/source/net/yacy/kelondro/rwi/IODispatcher.java
index 7054725c5..d42b3e2a8 100644
--- a/source/net/yacy/kelondro/rwi/IODispatcher.java
+++ b/source/net/yacy/kelondro/rwi/IODispatcher.java
@@ -50,7 +50,7 @@ import net.yacy.kelondro.util.MemoryControl;
public class IODispatcher extends Thread {
private Semaphore controlQueue;
- private Semaphore termination;
+ private final Semaphore termination;
private ArrayBlockingQueue<MergeJob> mergeQueue;
private ArrayBlockingQueue<DumpJob<? extends Reference>> dumpQueue;
//private ReferenceFactory<ReferenceType> factory;
diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
index 2048388f4..b6ed5336e 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
@@ -201,7 +201,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
// plus the mentioned features
private final boolean rot;
- private ArrayList<ReferenceContainer<ReferenceType>> cachecopy;
+ private final ArrayList<ReferenceContainer<ReferenceType>> cachecopy;
private int p;
private byte[] latestTermHash;
@@ -428,7 +428,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
}
public static class ContainerOrder<ReferenceType extends Reference> implements Comparator<ReferenceContainer<ReferenceType>> {
- private ByteOrder o;
+ private final ByteOrder o;
public ContainerOrder(ByteOrder order) {
this.o = order;
}
diff --git a/source/net/yacy/kelondro/rwi/TermSearch.java b/source/net/yacy/kelondro/rwi/TermSearch.java
index a43da6216..ce7bc7f71 100644
--- a/source/net/yacy/kelondro/rwi/TermSearch.java
+++ b/source/net/yacy/kelondro/rwi/TermSearch.java
@@ -36,7 +36,7 @@ import net.yacy.kelondro.index.RowSpaceExceededException;
public class TermSearch <ReferenceType extends Reference> {
- private ReferenceContainer<ReferenceType> joinResult;
+ private final ReferenceContainer<ReferenceType> joinResult;
HashMap<byte[], ReferenceContainer<ReferenceType>> inclusionContainers;
public TermSearch(
diff --git a/source/net/yacy/kelondro/table/ChunkIterator.java b/source/net/yacy/kelondro/table/ChunkIterator.java
index b41a82248..058b63c4c 100644
--- a/source/net/yacy/kelondro/table/ChunkIterator.java
+++ b/source/net/yacy/kelondro/table/ChunkIterator.java
@@ -53,7 +53,7 @@ public class ChunkIterator implements Iterator<byte[]> {
private final DataInputStream stream;
private byte[] nextBytes;
- private int recordsize;
+ private final int recordsize;
public ChunkIterator(final File file, final int recordsize, final int chunksize) throws FileNotFoundException {
assert (file.exists());
diff --git a/source/net/yacy/kelondro/table/RecordStack.java b/source/net/yacy/kelondro/table/RecordStack.java
index 0beb8e24f..57806ceec 100644
--- a/source/net/yacy/kelondro/table/RecordStack.java
+++ b/source/net/yacy/kelondro/table/RecordStack.java
@@ -271,7 +271,7 @@ public final class RecordStack extends Records {
while ((s = f.readLine()) != null) {
s = s.trim();
line++;
- if ((s.length() > 0) && (!(s.startsWith("#")))) {
+ if (s.length() > 0 && s.charAt(0) != '#') {
st = new StringTokenizer(s, separator);
// buffer the entry
c = 0;
@@ -346,7 +346,7 @@ public final class RecordStack extends Records {
while (true) {
m = f.readLine();
if (m == null) break;
- if ((m.length() > 1) && (!m.startsWith("#"))) {
+ if (m.length() > 1 && m.charAt(0) != '#') {
m = m + " " + db;
cmd(line2args(m));
}
diff --git a/source/net/yacy/kelondro/table/Records.java b/source/net/yacy/kelondro/table/Records.java
index 267f54f23..f7b3fc53f 100644
--- a/source/net/yacy/kelondro/table/Records.java
+++ b/source/net/yacy/kelondro/table/Records.java
@@ -1026,7 +1026,7 @@ public class Records {
}
public final class Node {
- private Handle handle = null; // index of the entry, by default NUL means undefined
+ private final Handle handle; // index of the entry, by default NUL means undefined
private byte[] ohChunk = null; // contains overhead values
private byte[] bodyChunk = null; // contains all row values
private boolean ohChanged = false;
diff --git a/source/net/yacy/kelondro/util/AttrSeq.java b/source/net/yacy/kelondro/util/AttrSeq.java
index cc9f169fe..0770e3197 100644
--- a/source/net/yacy/kelondro/util/AttrSeq.java
+++ b/source/net/yacy/kelondro/util/AttrSeq.java
@@ -110,7 +110,7 @@ public class AttrSeq {
while ((line = br.readLine()) != null) {
line = line.trim();
if (line.length() == 0) continue;
- if (line.startsWith("#")) {
+ if (line.charAt(0) == '#') {
if (line.startsWith("# Structure=")) {
structure = new Structure(line.substring(12));
}
@@ -287,7 +287,7 @@ public class AttrSeq {
}
// parse sequence definition:
- if (seqs.startsWith("*")) seqs = seqs.substring(1);
+ if (seqs.length() > 0 && seqs.charAt(0) == '*') seqs = seqs.substring(1);
l = new ArrayList<Column>();
st = new StringTokenizer(seqs, ",");
while (st.hasMoreTokens()) {
diff --git a/source/net/yacy/kelondro/util/BDecoder.java b/source/net/yacy/kelondro/util/BDecoder.java
index 96e419948..5167dc6e0 100644
--- a/source/net/yacy/kelondro/util/BDecoder.java
+++ b/source/net/yacy/kelondro/util/BDecoder.java
@@ -33,7 +33,7 @@ import java.util.Map;
public class BDecoder {
- private byte[] b;
+ private final byte[] b;
private int pos;
public BDecoder(byte[] b) {
diff --git a/source/net/yacy/kelondro/util/ByteArray.java b/source/net/yacy/kelondro/util/ByteArray.java
index dbbd8cf2e..f9c209022 100644
--- a/source/net/yacy/kelondro/util/ByteArray.java
+++ b/source/net/yacy/kelondro/util/ByteArray.java
@@ -40,7 +40,7 @@ import net.yacy.kelondro.order.ByteOrder;
public class ByteArray {
- private byte[] buffer;
+ private final byte[] buffer;
private int hash;
diff --git a/source/net/yacy/kelondro/util/CompressedHashMap.java b/source/net/yacy/kelondro/util/CompressedHashMap.java
index 9ddffef6d..1b0d42e03 100644
--- a/source/net/yacy/kelondro/util/CompressedHashMap.java
+++ b/source/net/yacy/kelondro/util/CompressedHashMap.java
@@ -301,7 +301,7 @@ public class CompressedHashMap {
public static void main(final String[] args) {
final long start = System.currentTimeMillis();
final CompressedHashMap map = new CompressedHashMap(4);
- for (int i = 0; i < 100; i++) map.put(3333 + i, ("" + (1000 + i)).getBytes());
+ for (int i = 0; i < 100; i++) map.put(3333 + i, Integer.toString(1000 + i).getBytes());
final Iterator<entry> i = map.entries();
CompressedHashMap.entry e;
System.out.println("Enumeration of elements: count=" + map.size());
diff --git a/source/net/yacy/kelondro/util/DateFormatter.java b/source/net/yacy/kelondro/util/DateFormatter.java
index eaf77eca0..8e823b1e4 100644
--- a/source/net/yacy/kelondro/util/DateFormatter.java
+++ b/source/net/yacy/kelondro/util/DateFormatter.java
@@ -511,8 +511,8 @@ public final class DateFormatter {
public static long UTCDiff(final String diffString) {
if (diffString.length() != 5) throw new IllegalArgumentException("UTC String malformed (wrong size):" + diffString);
boolean ahead = true;
- if (diffString.charAt(0) == '+') ahead = true;
- else if (diffString.charAt(0) == '-') ahead = false;
+ if (diffString.length() > 0 && diffString.charAt(0) == '+') ahead = true;
+ else if (diffString.length() > 0 && diffString.charAt(0) == '-') ahead = false;
else throw new IllegalArgumentException("UTC String malformed (wrong sign):" + diffString);
final long oh = Long.parseLong(diffString.substring(1, 3));
final long om = Long.parseLong(diffString.substring(3));
diff --git a/source/net/yacy/kelondro/util/DiskSpace.java b/source/net/yacy/kelondro/util/DiskSpace.java
index 0fb4aa450..e8c32461b 100644
--- a/source/net/yacy/kelondro/util/DiskSpace.java
+++ b/source/net/yacy/kelondro/util/DiskSpace.java
@@ -114,7 +114,7 @@ public class DiskSpace {
checkMappedSubDirs(pathsToCheck);
for (int i = 0; i < allVolumes.size(); i++){
- if (usedVolumes.get(i) == true) {
+ if (usedVolumes.get(i)) {
yacyUsedVolumes.add(allVolumes.get (i));
yacyUsedMountPoints.add(allMountPoints.get (i));
}
@@ -159,7 +159,7 @@ public class DiskSpace {
try {
final List<String> lines = dfUnixExec();
nextLine: for (final String line: lines){
- if (line.charAt(0) != '/') continue;
+ if (line.length() > 0 && line.charAt(0) != '/') continue;
final String[] tokens = line.split(" +", 6);
if (tokens.length < 6) continue;
for (int i = 0; i < yacyUsedVolumes.size(); i++){
@@ -185,7 +185,7 @@ public class DiskSpace {
final List<String> lines = dfUnixExec();
nextLine: for (final String line: lines){
- if (line.charAt(0) != '/') continue;
+ if (line.length() > 0 && line.charAt(0) != '/') continue;
final String[] tokens = line.split(" +", 6);
if (tokens.length < 6) continue;
for (int i = 0; i < allMountPoints.size(); i++) {
diff --git a/source/net/yacy/kelondro/util/FileUtils.java b/source/net/yacy/kelondro/util/FileUtils.java
index 7c9640658..84c84580e 100644
--- a/source/net/yacy/kelondro/util/FileUtils.java
+++ b/source/net/yacy/kelondro/util/FileUtils.java
@@ -376,7 +376,7 @@ public final class FileUtils {
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
- if ((line.length() > 0) && (!(line.startsWith("#")))) set.add(line.trim().toLowerCase());
+ if (line.length() > 0 && line.charAt(0) != '#') set.add(line.trim().toLowerCase());
}
br.close();
} catch (final IOException e) {
@@ -527,8 +527,8 @@ public final class FileUtils {
String line;
final HashMap<String, String> props = new HashMap<String, String>(list.size());
while (i.hasNext()) {
- line = (i.next()).trim();
- if (line.startsWith("#")) continue; // exclude comments
+ line = i.next().trim();
+ if (line.length() > 0 && line.charAt(0) == '#') continue; // exclude comments
//System.out.println("NXTOOLS_PROPS - LINE:" + line);
pos = line.indexOf("=");
if (pos > 0) props.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim());
@@ -615,7 +615,8 @@ public final class FileUtils {
// Read the List
String line = "";
while ((line = br.readLine()) != null) {
- if ((!line.startsWith("#") || withcomments) || !line.equals("")) {
+ if (line.length() == 0) continue;
+ if (line.charAt(0) != '#' || withcomments) {
//temp += line + serverCore.CRLF_STRING;
temp.append(line).append(CR).append(LF);
}
@@ -762,7 +763,7 @@ public final class FileUtils {
*/
public static class StringsIterator implements Iterator<String> {
- private BufferedReader reader;
+ private final BufferedReader reader;
private String nextLine;
public StringsIterator(final BufferedReader reader) {
this.reader = reader;
diff --git a/source/net/yacy/kelondro/util/OS.java b/source/net/yacy/kelondro/util/OS.java
index 5aba86618..7d43a34b2 100644
--- a/source/net/yacy/kelondro/util/OS.java
+++ b/source/net/yacy/kelondro/util/OS.java
@@ -126,7 +126,7 @@ public final class OS {
public static String getMacFSType(final File f) {
if ((isMacArchitecture) && (macMRJFileUtils != null)) try {
final String s = macGetFileType.invoke(null, new Object[] {f}).toString();
- if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;
+ if (s == null || (s.length() > 0 && s.charAt(0) == 0)) return blankTypeString;
return s;
} catch (final Exception e) {
return null;
@@ -137,7 +137,7 @@ public final class OS {
public static String getMacFSCreator(final File f) {
if ((isMacArchitecture) && (macMRJFileUtils != null)) try {
final String s = macGetFileCreator.invoke(null, new Object[] {f}).toString();
- if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;
+ if (s == null || (s.length() > 0 && s.charAt(0) == 0)) return blankTypeString;
return s;
} catch (final Exception e) {
return null;
diff --git a/source/net/yacy/kelondro/util/ScoreCluster.java b/source/net/yacy/kelondro/util/ScoreCluster.java
index dde06a561..8afedb98d 100644
--- a/source/net/yacy/kelondro/util/ScoreCluster.java
+++ b/source/net/yacy/kelondro/util/ScoreCluster.java
@@ -120,7 +120,7 @@ public final class ScoreCluster<E> {
if (o instanceof byte[]) s = new 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.length() == 0 || s.charAt(0) == '-') return 0;
try {
long l = 0;
if (s.length() == shortDateFormatString.length()) {
diff --git a/source/net/yacy/kelondro/util/SetTools.java b/source/net/yacy/kelondro/util/SetTools.java
index 0125aa1a4..5391e6718 100644
--- a/source/net/yacy/kelondro/util/SetTools.java
+++ b/source/net/yacy/kelondro/util/SetTools.java
@@ -319,7 +319,7 @@ public class SetTools {
// comparators must be equal
if (map == null) return;
if (set == null) return;
- assert !(map instanceof TreeMap && set instanceof TreeSet) || ((TreeMap<A, B>) map).comparator() == ((TreeSet<A>) set).comparator();
+ assert !(map instanceof TreeMap<?,?> && set instanceof TreeSet<?>) || ((TreeMap<A, B>) map).comparator() == ((TreeSet<A>) set).comparator();
if (map.isEmpty() || set.isEmpty()) return;
if (map.size() < set.size())
@@ -342,7 +342,7 @@ public class SetTools {
public static <A> void excludeDestructive(final Set<A> set1, final Set<A> set2) {
if (set1 == null) return;
if (set2 == null) return;
- assert !(set1 instanceof TreeSet && set2 instanceof TreeSet) || ((TreeSet<A>) set1).comparator() == ((TreeSet<A>) set2).comparator();
+ assert !(set1 instanceof TreeSet<?> && set2 instanceof TreeSet<?>) || ((TreeSet<A>) set1).comparator() == ((TreeSet<A>) set2).comparator();
if (set1.isEmpty() || set2.isEmpty()) return;
if (set1.size() < set2.size())
@@ -372,7 +372,7 @@ public class SetTools {
int pos;
while ((line = br.readLine()) != null) {
line = line.trim();
- if ((line.length() > 0) && (!(line.startsWith("#"))) && ((pos = line.indexOf(sep)) > 0))
+ if ((line.length() > 0 && 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) {
@@ -391,7 +391,7 @@ public class SetTools {
int pos;
while ((line = br.readLine()) != null) {
line = line.trim();
- if ((line.length() > 0) && (!(line.startsWith("#"))) && ((pos = line.indexOf(sep)) > 0)) {
+ if ((line.length() > 0 && 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>());
@@ -415,7 +415,7 @@ public class SetTools {
String line;
while ((line = br.readLine()) != null) {
line = line.trim();
- if ((line.length() > 0) && (!(line.startsWith("#")))) list.add(line.trim().toLowerCase());
+ if (line.length() > 0 && line.charAt(0) != '#') list.add(line.trim().toLowerCase());
}
br.close();
} catch (final IOException e) {
diff --git a/source/net/yacy/kelondro/workflow/AbstractThread.java b/source/net/yacy/kelondro/workflow/AbstractThread.java
index 2e8a0ad1e..59bc65401 100644
--- a/source/net/yacy/kelondro/workflow/AbstractThread.java
+++ b/source/net/yacy/kelondro/workflow/AbstractThread.java
@@ -133,7 +133,7 @@ public abstract class AbstractThread extends Thread implements WorkflowThread {
}
}
- public void open() {} // dummy definition; should be overriden
- public void close() {} // dummy definition; should be overriden
+ public void open() {}; // dummy definition; should be overriden
+ public void close() {}; // dummy definition; should be overriden
}
diff --git a/source/net/yacy/kelondro/workflow/WorkflowProcessor.java b/source/net/yacy/kelondro/workflow/WorkflowProcessor.java
index 6935f20a0..68adc0448 100644
--- a/source/net/yacy/kelondro/workflow/WorkflowProcessor.java
+++ b/source/net/yacy/kelondro/workflow/WorkflowProcessor.java
@@ -46,11 +46,11 @@ public class WorkflowProcessor<J extends WorkflowJob> {
private ExecutorService executor;
private BlockingQueue<J> input;
- private WorkflowProcessor<J> output;
- private int poolsize;
- private Object environment;
- private String processName, methodName, description;
- private String[] childs;
+ private final WorkflowProcessor<J> output;
+ private final int poolsize;
+ private final Object environment;
+ private final String processName, methodName, description;
+ private final String[] childs;
private long blockTime, execTime, passOnTime;
private long execCount;
diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java
index 002d355bd..dc955f453 100644
--- a/source/net/yacy/repository/Blacklist.java
+++ b/source/net/yacy/repository/Blacklist.java
@@ -242,8 +242,7 @@ public class Blacklist {
blacklistMap = (isMatchable(host)) ? getBlacklistMap(blacklistType,true) : getBlacklistMap(blacklistType,false);
// avoid PatternSyntaxException e
- if(!isMatchable(host) && host.startsWith("*"))
- host = "." + host;
+ if (!isMatchable(host) && host.length() > 0 && host.charAt(0) == '*') host = "." + host;
ArrayList<String> hostList = blacklistMap.get(host.toLowerCase());
if (hostList == null) blacklistMap.put(host.toLowerCase(), (hostList = new ArrayList<String>()));
@@ -273,8 +272,7 @@ public class Blacklist {
blacklistMap = (isMatchable(host)) ? getBlacklistMap(blacklistType,true) : getBlacklistMap(blacklistType,false);
// avoid PatternSyntaxException e
- if(!isMatchable(host) && host.startsWith("*"))
- host = "." + host;
+ if (!isMatchable(host) && host.length() > 0 && host.charAt(0) == '*') host = "." + host;
ArrayList<String> hostList = blacklistMap.get(host.toLowerCase());
if (hostList != null) ret = hostList.contains(path);
diff --git a/source/org/apache/tools/tar/TarEntry.java b/source/org/apache/tools/tar/TarEntry.java
index 2a6c8ecec..42fcb9f43 100644
--- a/source/org/apache/tools/tar/TarEntry.java
+++ b/source/org/apache/tools/tar/TarEntry.java
@@ -239,7 +239,7 @@ public class TarEntry implements TarConstants {
// No absolute pathnames
// Windows (and Posix?) paths can start with "\\NetworkDrive\",
// so we loop on starting /'s.
- while (fileName.startsWith("/")) {
+ while (fileName.length() > 0 && fileName.charAt(0) == '/') {
fileName = fileName.substring(1);
}