Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
cleaned unnecessary nested code
Michael Peter Christenea10766bfdee
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefsindex 13e8970ba..01d204775 100644--- a/.settings/org.eclipse.jdt.core.prefs+++ b/.settings/org.eclipse.jdt.core.prefs@@ -1,5 +1,9 @@-#Tue May 22 00:37:34 CEST 2012eclipse.preferences.version=1+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabledorg.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabledorg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve@@ -18,6 +22,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=org.eclipse.jdt.core.compiler.problem.discouragedReference=warningorg.eclipse.jdt.core.compiler.problem.emptyStatement=ignoreorg.eclipse.jdt.core.compiler.problem.enumIdentifier=error+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignoreorg.eclipse.jdt.core.compiler.problem.fallthroughCase=warningorg.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabledorg.eclipse.jdt.core.compiler.problem.fieldHiding=ignore@@ -25,12 +30,15 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warningorg.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warningorg.eclipse.jdt.core.compiler.problem.forbiddenReference=errororg.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabledorg.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warningorg.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignoreorg.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignoreorg.eclipse.jdt.core.compiler.problem.localVariableHiding=ignoreorg.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignoreorg.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabledorg.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warningorg.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignoreorg.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled@@ -39,27 +47,37 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignororg.eclipse.jdt.core.compiler.problem.noEffectAssignment=warningorg.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warningorg.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=errororg.eclipse.jdt.core.compiler.problem.nullReference=ignore+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warningorg.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warningorg.eclipse.jdt.core.compiler.problem.parameterAssignment=ignoreorg.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warningorg.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignoreorg.eclipse.jdt.core.compiler.problem.rawTypeReference=warning+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warningorg.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignoreorg.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignoreorg.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabledorg.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warningorg.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabledorg.eclipse.jdt.core.compiler.problem.suppressWarnings=enabledorg.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignoreorg.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabledorg.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warningorg.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignoreorg.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warningorg.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warningorg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabledorg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabledorg.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled@@ -67,7 +85,7 @@ org.eclipse.jdt.core.compiler.problem.unusedImport=warningorg.eclipse.jdt.core.compiler.problem.unusedLabel=warningorg.eclipse.jdt.core.compiler.problem.unusedLocal=warningorg.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore+org.eclipse.jdt.core.compiler.problem.unusedParameter=warningorg.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabledorg.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabledorg.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disableddiff --git a/htroot/CacheResource_p.java b/htroot/CacheResource_p.javaindex 490bd2d4a..e055b0c4d 100644--- a/htroot/CacheResource_p.java+++ b/htroot/CacheResource_p.java@@ -59,19 +59,18 @@ public class CacheResource_p {if (header.get("EXT", "html").equals("png")) {// a png was requestedreturn ImageParser.parse(u, resource);- } else {- // get response header and set mime type- ResponseHeader responseHeader = Cache.getResponseHeader(url.hash());- String resMime = responseHeader == null ? null : responseHeader.mime();- if (resMime != null) {- final ResponseHeader outgoingHeader = new ResponseHeader(200);- outgoingHeader.put(HeaderFramework.CONTENT_TYPE, resMime);- prop.setOutgoingHeader(outgoingHeader);- }-- // add resource- prop.put("resource", resource);- return prop;}+ // get response header and set mime type+ ResponseHeader responseHeader = Cache.getResponseHeader(url.hash());+ String resMime = responseHeader == null ? null : responseHeader.mime();+ if (resMime != null) {+ final ResponseHeader outgoingHeader = new ResponseHeader(200);+ outgoingHeader.put(HeaderFramework.CONTENT_TYPE, resMime);+ prop.setOutgoingHeader(outgoingHeader);+ }++ // add resource+ prop.put("resource", resource);+ return prop;}}diff --git a/htroot/ViewFile.java b/htroot/ViewFile.javaindex f4a192fe2..de83d2568 100644--- a/htroot/ViewFile.java+++ b/htroot/ViewFile.java@@ -154,9 +154,8 @@ public class ViewFile {prop.put("viewMode", VIEW_MODE_NO_TEXT);prop.put("url", "");return prop;- } else {- prop.put("url", url.toNormalform(false, true));}+ prop.put("url", url.toNormalform(false, true));// loading the resource content as byte arrayprop.put("error_incache", Cache.has(url.hash()) ? 1 : 0);diff --git a/htroot/api/ynetSearch.java b/htroot/api/ynetSearch.javaindex e38647f0f..d905ca722 100644--- a/htroot/api/ynetSearch.java+++ b/htroot/api/ynetSearch.java@@ -26,37 +26,34 @@ public class ynetSearch {prop.authenticationRequired();}return prop;- } else {- InputStream is = null;- try {- String searchaddress = post.get("url");- if (!searchaddress.startsWith("http://")) {- // a relative path .. this addresses the local peer- searchaddress = "http://" + switchboard.peers.mySeed().getPublicAddress() + ((searchaddress.length() > 0 && searchaddress.charAt(0) == '/') ? "" : "/") + searchaddress;- }- post.remove("url");- post.remove("login");- final Iterator <Map.Entry<String, String>> it = post.entrySet().iterator();- String s = searchaddress;- Map.Entry<String, String> k;- while(it.hasNext()) {- k = it.next();- s = s + "&" + k.getKey() + "=" + k.getValue();- }- // final String s = searchaddress+"&query="+post.get("search")+"&maximumRecords="+post.get("maximumRecords")+"&startRecord="+post.get("startRecord");- final URL url = new URL(s);- is = url.openStream();- final String httpout = new Scanner(is).useDelimiter( "\\Z" ).next();- prop.put("http", httpout);- }- catch ( final Exception e ) {- prop.put("url", "error!");- }- finally {- if ( is != null )- try { is.close(); } catch ( final IOException e ) { }- }}+ InputStream is = null;+ try {+ String searchaddress = post.get("url");+ if (!searchaddress.startsWith("http://")) {+ // a relative path .. this addresses the local peer+ searchaddress = "http://" + switchboard.peers.mySeed().getPublicAddress() + ((searchaddress.length() > 0 && searchaddress.charAt(0) == '/') ? "" : "/") + searchaddress;+ }+ post.remove("url");+ post.remove("login");+ final Iterator <Map.Entry<String, String>> it = post.entrySet().iterator();+ String s = searchaddress;+ Map.Entry<String, String> k;+ while(it.hasNext()) {+ k = it.next();+ s = s + "&" + k.getKey() + "=" + k.getValue();+ }+ // final String s = searchaddress+"&query="+post.get("search")+"&maximumRecords="+post.get("maximumRecords")+"&startRecord="+post.get("startRecord");+ final URL url = new URL(s);+ is = url.openStream();+ final String httpout = new Scanner(is).useDelimiter( "\\Z" ).next();+ prop.put("http", httpout);+ } catch ( final Exception e ) {+ prop.put("url", "error!");+ } finally {+ if ( is != null )+ try { is.close(); } catch ( final IOException e ) { }+ }}return prop;}diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.javaindex ecbffa3e1..97a9b2968 100644--- a/source/de/anomic/crawler/CrawlProfile.java+++ b/source/de/anomic/crawler/CrawlProfile.java@@ -33,8 +33,6 @@ import java.util.Set;import java.util.concurrent.ConcurrentHashMap;import java.util.regex.Pattern;-import de.anomic.server.serverObjects;-import net.yacy.cora.document.ASCII;import net.yacy.cora.document.MultiProtocolURI;import net.yacy.cora.services.federated.yacy.CacheStrategy;@@ -43,6 +41,7 @@ import net.yacy.kelondro.data.word.Word;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.order.Base64Order;import net.yacy.kelondro.order.Digest;+import de.anomic.server.serverObjects;public class CrawlProfile extends ConcurrentHashMap<String, String> implements Map<String, String> {@@ -494,13 +493,12 @@ public class CrawlProfile extends ConcurrentHashMap<String, String> implements Mfinal String host = crawlingStartURL.getHost();if (host.startsWith("www.")) {return "https?://" + crawlingStartURL.getHost() + ".*";- } else {- // if the www is not given we accept that also- return "https?://(?:www.)?" + crawlingStartURL.getHost() + ".*";}+ // if the www is not given we accept that also+ return "https?://(?:www.)?" + crawlingStartURL.getHost() + ".*";}}-+public static final Set<String> ignoreNames = new HashSet<String>();static {diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.javaindex 388ff1d35..37329f97d 100644--- a/source/de/anomic/crawler/CrawlStacker.java+++ b/source/de/anomic/crawler/CrawlStacker.java@@ -446,9 +446,8 @@ public final class CrawlStacker {if (dbocc.equals("errors")) {final ZURL.Entry errorEntry = this.nextQueue.errorURL.get(url.hash());return "double in: errors (" + errorEntry.anycause() + ")";- } else {- return "double in: " + dbocc;}+ return "double in: " + dbocc;}} else {final boolean recrawl = profile.recrawlIfOlder() > oldEntry.loaddate().getTime();@@ -459,15 +458,13 @@ public final class CrawlStacker {} else {if (dbocc == null) {return "double in: LURL-DB";- } else {- if (this.log.isInfo()) this.log.logInfo("URL '" + urlstring + "' is double registered in '" + dbocc + "'. " + "Stack processing time:");- if (dbocc.equals("errors")) {- final ZURL.Entry errorEntry = this.nextQueue.errorURL.get(url.hash());- return "double in: errors (" + errorEntry.anycause() + ")";- } else {- return "double in: " + dbocc;- }}+ if (this.log.isInfo()) this.log.logInfo("URL '" + urlstring + "' is double registered in '" + dbocc + "'. " + "Stack processing time:");+ if (dbocc.equals("errors")) {+ final ZURL.Entry errorEntry = this.nextQueue.errorURL.get(url.hash());+ return "double in: errors (" + errorEntry.anycause() + ")";+ }+ return "double in: " + dbocc;}}diff --git a/source/de/anomic/crawler/retrieval/HTTPLoader.java b/source/de/anomic/crawler/retrieval/HTTPLoader.javaindex 9c29426b4..05aee0a8e 100644--- a/source/de/anomic/crawler/retrieval/HTTPLoader.java+++ b/source/de/anomic/crawler/retrieval/HTTPLoader.java@@ -176,11 +176,10 @@ public final class HTTPLoader {// retry crawling with new urlrequest.redirectURL(redirectionUrl);return load(request, retryCount - 1, maxFileSize, blacklistType);- } else {- // we don't want to follow redirects- this.sb.crawlQueues.errorURL.push(request, myHash, new Date(), 1, FailCategory.FINAL_PROCESS_CONTEXT, "redirection not wanted", statusCode);- throw new IOException("REJECTED UNWANTED REDIRECTION '" + client.getHttpResponse().getStatusLine() + "' for URL " + requestURLString);}+ // we don't want to follow redirects+ this.sb.crawlQueues.errorURL.push(request, myHash, new Date(), 1, FailCategory.FINAL_PROCESS_CONTEXT, "redirection not wanted", statusCode);+ throw new IOException("REJECTED UNWANTED REDIRECTION '" + client.getHttpResponse().getStatusLine() + "' for URL " + requestURLString);} else if (responseBody == null) {// no response, reject filethis.sb.crawlQueues.errorURL.push(request, myHash, new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "no response body", statusCode);diff --git a/source/de/anomic/data/ymark/TablesRowComparator.java b/source/de/anomic/data/ymark/TablesRowComparator.javaindex 570193273..945a66c3e 100644--- a/source/de/anomic/data/ymark/TablesRowComparator.java+++ b/source/de/anomic/data/ymark/TablesRowComparator.java@@ -1,13 +1,14 @@package de.anomic.data.ymark;import java.util.Comparator;+import net.yacy.cora.document.UTF8;import net.yacy.kelondro.blob.Tables;public class TablesRowComparator implements Comparator<Tables.Row> {private String sortname;private boolean desc;-+public TablesRowComparator(final String sortname, final String sortorder) {setSortName(sortname);if(sortorder.equals("desc"))@@ -15,20 +16,18 @@ public class TablesRowComparator implements Comparator<Tables.Row> {elsethis.desc = false;}-+public void setSortName(final String sortname) {this.sortname = sortname;}+ @Overridepublic int compare(Tables.Row row0, Tables.Row row1) {if(row0 != null && row1 != null) {if(row0.containsKey(this.sortname) && row1.containsKey(this.sortname)) {String name1 = UTF8.String(row0.get(this.sortname)).toLowerCase();String name2 = UTF8.String(row1.get(this.sortname)).toLowerCase();- if(desc)- return name2.compareTo(name1);- else- return name1.compareTo(name2);+ return (this.desc) ? name2.compareTo(name1) : name1.compareTo(name2);}}return 0;diff --git a/source/de/anomic/data/ymark/YMarkAutoTagger.java b/source/de/anomic/data/ymark/YMarkAutoTagger.javaindex 81b439787..071f3e17e 100644--- a/source/de/anomic/data/ymark/YMarkAutoTagger.java+++ b/source/de/anomic/data/ymark/YMarkAutoTagger.java@@ -215,10 +215,7 @@ public class YMarkAutoTagger implements Runnable, Thread.UncaughtExceptionHandlepublic static String autoTag(final String url, final LoaderDispatcher loader, final int max, final TreeMap<String, YMarkTag> tags) {final Document document = loadDocument(url, loader);- if (document != null)- return autoTag(document, max, tags);- else- return "/IOExceptions";+ return (document != null) ? autoTag(document, max, tags) : "/IOExceptions";}public static boolean isDigitSpace(String str) {diff --git a/source/de/anomic/data/ymark/YMarkCrawlStart.java b/source/de/anomic/data/ymark/YMarkCrawlStart.javaindex c5f7d8ac8..d0474b3a0 100644--- a/source/de/anomic/data/ymark/YMarkCrawlStart.java+++ b/source/de/anomic/data/ymark/YMarkCrawlStart.java@@ -39,7 +39,7 @@ import de.anomic.crawler.CrawlSwitchboard;import de.anomic.data.WorkTables;public class YMarkCrawlStart extends HashMap<String,String>{-+private static final long serialVersionUID = 1L;private final WorkTables worktables;private Date date_last_exec;@@ -47,7 +47,7 @@ public class YMarkCrawlStart extends HashMap<String,String>{private Date date_recording;private String apicall_pk;private String url;-+public YMarkCrawlStart(final WorkTables worktables) {super();this.date_recording = new Date(0);@@ -62,44 +62,41 @@ public class YMarkCrawlStart extends HashMap<String,String>{this.clear();this.load();}-+public String getPK() {if(this.isEmpty())return "";return this.apicall_pk;}-+public Date date_last_exec() {if(this.isEmpty())return new Date(0);return this.date_last_exec;}-+public Date date_next_exec() {if(this.isEmpty())return new Date(0);return this.date_next_exec;}-- public boolean hasSchedule() {- if(!this.isEmpty() && this.date_next_exec.after(new Date()))- return true;- else- return false;++ public boolean hasSchedule() {+ return !this.isEmpty() && this.date_next_exec.after(new Date());}-+public boolean isRunning(final CrawlSwitchboard crawler) {final Iterator<byte[]> iter = crawler.getActive().iterator();while(iter.hasNext()) {final byte[] key = iter.next();final CrawlProfile crawl = crawler.getActive(key);if (crawl.startURL().equals(this.url)) {- return true;+ return true;}}return false;}-+public Date date_recording() {return this.date_recording;}@@ -111,16 +108,16 @@ public class YMarkCrawlStart extends HashMap<String,String>{this.load();}}-+public int exec(final String host, final int port, final String realm) {return this.worktables.execAPICall(this.apicall_pk, host, port, realm);}-+private void load() {try {final StringBuilder buffer = new StringBuilder(500);buffer.append("^crawl start for ");- buffer.append(Pattern.quote(url));+ buffer.append(Pattern.quote(this.url));buffer.append("?.*");final Pattern pattern = Pattern.compile(buffer.toString());//final Iterator<Tables.Row> APIcalls = this.worktables.iterator(WorkTables.TABLE_API_NAME, WorkTables.TABLE_API_COL_URL, pattern);@@ -129,7 +126,7 @@ public class YMarkCrawlStart extends HashMap<String,String>{while(APIcalls.hasNext()) {row = APIcalls.next();if(row.get(WorkTables.TABLE_API_COL_TYPE, "").equals("crawler")) {- Date date = row.get(WorkTables.TABLE_API_COL_DATE_RECORDING, row.get(WorkTables.TABLE_API_COL_DATE, new Date()));+ Date date = row.get(WorkTables.TABLE_API_COL_DATE_RECORDING, row.get(WorkTables.TABLE_API_COL_DATE, new Date()));if(date.after(this.date_recording)) {this.clear();this.apicall_pk = UTF8.String(row.getPK());diff --git a/source/de/anomic/data/ymark/YMarkDate.java b/source/de/anomic/data/ymark/YMarkDate.javaindex 8f24af227..10855da9d 100644--- a/source/de/anomic/data/ymark/YMarkDate.java+++ b/source/de/anomic/data/ymark/YMarkDate.java@@ -9,7 +9,7 @@// $LastChangedBy: apfelmaennchen $//// LICENSE-//+//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or@@ -34,21 +34,21 @@ import net.yacy.cora.date.ISO8601Formatter;import net.yacy.cora.document.UTF8;public class YMarkDate {-+private long date;-+public YMarkDate() {- this.date = System.currentTimeMillis();+ this.date = System.currentTimeMillis();}-+public YMarkDate(final byte[] date) {this.set(date);}-+public YMarkDate(final Date date) {this.date = date.getTime();}-+public long parseISO8601(final String s) throws ParseException {if(s == null || s.length() < 1) {throw new ParseException("parseISO8601 - empty string, nothing to parse", 0);@@ -58,7 +58,7 @@ public class YMarkDate {if(s.length()==10)dateformat = new SimpleDateFormat("yyyy-MM-dd");else {- dateformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");+ dateformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");if(date.charAt(date.length()-1) == 'Z') {date.deleteCharAt(date.length()-1);date.append("GMT-00:00");@@ -69,41 +69,38 @@ public class YMarkDate {this.date = dateformat.parse(date.toString()).getTime();return this.date;}-+public String toISO8601() {- if(this.date == 0) {- return YMarkEntry.BOOKMARK.DATE_MODIFIED.deflt();- } else {- return ISO8601(new Date(this.date));- }+ return (this.date == 0) ? YMarkEntry.BOOKMARK.DATE_MODIFIED.deflt() : ISO8601(new Date(this.date));}-+public static String ISO8601(final Date date) {- return ISO8601Formatter.FORMATTER.format(date);+ return ISO8601Formatter.FORMATTER.format(date);}-+public byte[] toBytes() {return String.valueOf(this.date).getBytes();}-++ @Overridepublic String toString() {return String.valueOf(this.date);}-+public long get() {return this.date;}-+public void set(long date) {this.date = date;}-+public void set(byte[] date) {final String s = UTF8.String(date);if(!s.isEmpty()) {- this.date = Long.parseLong(s);+ this.date = Long.parseLong(s);} else {- this.date = 0;+ this.date = 0;}}}diff --git a/source/de/anomic/http/server/AugmentedHtmlStream.java b/source/de/anomic/http/server/AugmentedHtmlStream.javaindex 94c733a37..437f7052f 100644--- a/source/de/anomic/http/server/AugmentedHtmlStream.java+++ b/source/de/anomic/http/server/AugmentedHtmlStream.java@@ -52,9 +52,8 @@ public class AugmentedHtmlStream extends FilterOutputStream {public StringBuffer process(StringBuffer data) {if (this.urls.contains("currentyacypeer/")) {return data;- } else {- return AugmentHtmlStream.process (data, this.charset, this.url, this.requestHeader);}+ return AugmentHtmlStream.process (data, this.charset, this.url, this.requestHeader);}public static boolean supportsMime(String mime) {diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.javaindex de9c280e9..d450a30bf 100644--- a/source/de/anomic/http/server/HTTPDFileHandler.java+++ b/source/de/anomic/http/server/HTTPDFileHandler.java@@ -554,9 +554,7 @@ public final class HTTPDFileHandler {doURLProxy(args, conProp, requestHeader, out);return;}- else {- HTTPDemon.sendRespondError(conProp,out,3,403,"Access denied",null,null);- }+ HTTPDemon.sendRespondError(conProp,out,3,403,"Access denied",null,null);}// track all files that had been accessed so fardiff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.javaindex ac175ca20..921e92ddc 100644--- a/source/de/anomic/server/serverSwitch.java+++ b/source/de/anomic/server/serverSwitch.java@@ -647,18 +647,12 @@ public class serverSwitch}if ( file != null && file.exists() ) {return new FileReader(file);- } else {- throw new FileNotFoundException();- }- } else {- final File f =- (uri.length() > 0 && uri.startsWith("/")) ? new File(uri) : new File(rootPath, uri);- if ( f.exists() ) {- return new FileReader(f);- } else {- throw new FileNotFoundException(f.toString());}+ throw new FileNotFoundException();}+ final File f = (uri.length() > 0 && uri.startsWith("/")) ? new File(uri) : new File(rootPath, uri);+ if (f.exists()) return new FileReader(f);+ throw new FileNotFoundException(f.toString());}private static Random pwGenerator = new Random();diff --git a/source/net/yacy/ai/example/SchwarzerPeter.java b/source/net/yacy/ai/example/SchwarzerPeter.javaindex 4b5e6b356..0b883ec43 100644--- a/source/net/yacy/ai/example/SchwarzerPeter.java+++ b/source/net/yacy/ai/example/SchwarzerPeter.java@@ -11,18 +11,18 @@ import net.yacy.ai.greedy.Model;import net.yacy.ai.greedy.Role;public class SchwarzerPeter {-+public static enum Kartentyp {A, B, C, D, E, F, G, H, P;}-+public static enum Kartenzaehler {p, q;}-+public static class Karte {- private Kartentyp kartentyp;- private Kartenzaehler kartenzaehler;+ private final Kartentyp kartentyp;+ private final Kartenzaehler kartenzaehler;public Karte(Kartentyp kartentyp, Kartenzaehler kartenzaehler) {this.kartentyp = kartentyp; this.kartenzaehler = kartenzaehler;}@@ -44,7 +44,7 @@ public class SchwarzerPeter {return k1.kartentyp == k2.kartentyp;}}-+public static final List<Karte> alleKarten;static {alleKarten = new ArrayList<Karte>(33);@@ -54,7 +54,7 @@ public class SchwarzerPeter {}alleKarten.add(new Karte(Kartentyp.P, Kartenzaehler.p));}-+public static final List<Karte> neuerStapel(Random r) {List<Karte> stapel0 = new ArrayList<Karte>();for (Karte karte: alleKarten) stapel0.add(karte);@@ -62,17 +62,18 @@ public class SchwarzerPeter {while (stapel0.size() > 0) stapel1.add(stapel0.remove(r.nextInt(stapel0.size())));return stapel1;}-+public static class Spieler implements Role {- private int spielernummer;- private int spieleranzahl;-+ private final int spielernummer;+ private final int spieleranzahl;+public Spieler(int spielernummer, int spieleranzahl) {this.spielernummer = spielernummer;this.spieleranzahl = spieleranzahl;}-++ @Overridepublic Spieler nextRole() {int n = (this.spielernummer == this.spieleranzahl - 1) ? 0 : this.spielernummer + 1;return new Spieler(n, this.spieleranzahl);@@ -81,30 +82,30 @@ public class SchwarzerPeter {int n = (this.spielernummer == 0) ? this.spieleranzahl - 1 : this.spielernummer - 1;return new Spieler(n, this.spieleranzahl);}-+@Overridepublic boolean equals(Object obj) {return obj != null&& obj instanceof Spieler&& this.spielernummer == ((Spieler) obj).spielernummer;}-+@Overridepublic int hashCode() {return this.spielernummer;}}-+public static enum Strategy {nichtsortieren_linksziehen,nichtsortieren_zufallsziehen,sortieren_linksziehen,sortieren_zufallsziehen;}-+public static class Hand extends ArrayList<Karte> {private static final long serialVersionUID = -5274023237476645059L;- private Strategy strategy;+ private final Strategy strategy;public Hand(Strategy strategy) {this.strategy = strategy;}@@ -118,21 +119,20 @@ public class SchwarzerPeter {public Karte abgeben(Random r) {if (this.strategy == Strategy.nichtsortieren_linksziehen || this.strategy == Strategy.sortieren_linksziehen) {return this.remove(0);- } else {- return this.remove(r.nextInt(this.size()));}+ return this.remove(r.nextInt(this.size()));}public boolean paerchenAblegen() {-return true;+return true;}}-+public static class Zug extends AbstractFinding<Spieler> implements Finding<Spieler> {public Zug(Spieler spieler, int priority) {super(spieler, priority);}-+@Overridepublic Object clone() {return this;@@ -147,45 +147,50 @@ return true;public int hashCode() {return 0;}-+}public static class Spiel extends AbstractModel<Spieler, Zug> implements Model<Spieler, Zug>, Cloneable {- private Hand[] haende;- private Random random;-+ private final Hand[] haende;+ private final Random random;+public Spiel(Spieler spieler, Random r) {super(spieler);this.random = r;- haende = new Hand[spieler.spieleranzahl];- for (int i = 0; i < spieler.spieleranzahl; i++) haende[i] = new Hand(Strategy.nichtsortieren_linksziehen);+ this.haende = new Hand[spieler.spieleranzahl];+ for (int i = 0; i < spieler.spieleranzahl; i++) this.haende[i] = new Hand(Strategy.nichtsortieren_linksziehen);List<Karte> geben = neuerStapel(r);while (geben.size() > 0) {- haende[spieler.spielernummer].annehmen(r, geben.remove(0));+ this.haende[spieler.spielernummer].annehmen(r, geben.remove(0));spieler = spieler.nextRole();}}+ @Overridepublic List<Zug> explore() {return new ArrayList<Zug>(0);}+ @Overridepublic void applyFinding(Zug finding) {- haende[this.currentRole().spielernummer].annehmen(random, this.haende[this.currentRole().linkerNachbar().spielernummer].abgeben(random));+ this.haende[this.currentRole().spielernummer].annehmen(this.random, this.haende[this.currentRole().linkerNachbar().spielernummer].abgeben(this.random));}+ @Overridepublic int getRanking(int findings, Spieler role) {// TODO Auto-generated method stubreturn 0;}+ @Overridepublic boolean isTermination(Spieler role) {// TODO Auto-generated method stubreturn false;}+ @Overridepublic Spieler isTermination() {// TODO Auto-generated method stubreturn null;diff --git a/source/net/yacy/ai/greedy/Battle.java b/source/net/yacy/ai/greedy/Battle.javaindex 69d37ac93..cc45e617f 100644--- a/source/net/yacy/ai/greedy/Battle.java+++ b/source/net/yacy/ai/greedy/Battle.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -33,7 +33,7 @@ public class Battle<SpecificModel extends Model<SpecificRole, SpecificFinding>>{-+public Battle(SpecificModel startModel,Map<SpecificRole, ContextFactory<SpecificRole, SpecificFinding, SpecificModel>> contexts,@@ -52,18 +52,17 @@ public class Battle<if (agent.getContext().hasNoResults()) {System.out.println("battle terminated, "+ agent.getModel().currentRole() + " found no finding");break;- } else {- Challenge<SpecificRole, SpecificFinding, SpecificModel> challenge = agent.getContext().takeResult();- if (challenge == null) {- // lost the game- System.out.println("lost the game: " + agent.getModel().currentRole());- System.exit(1);- }- System.out.println("finding " + challenge.getFinding().toString());- currentModel.applyFinding(challenge.getFinding());- currentModel.nextRole();- System.out.println(currentModel.toString());}+ Challenge<SpecificRole, SpecificFinding, SpecificModel> challenge = agent.getContext().takeResult();+ if (challenge == null) {+ // lost the game+ System.out.println("lost the game: " + agent.getModel().currentRole());+ System.exit(1);+ }+ System.out.println("finding " + challenge.getFinding().toString());+ currentModel.applyFinding(challenge.getFinding());+ currentModel.nextRole();+ System.out.println(currentModel.toString());}engine.stop();}diff --git a/source/net/yacy/ai/greedy/Context.java b/source/net/yacy/ai/greedy/Context.javaindex 682677edd..def2cdc3b 100644--- a/source/net/yacy/ai/greedy/Context.java+++ b/source/net/yacy/ai/greedy/Context.java@@ -11,12 +11,12 @@* modify it under the terms of the GNU Lesser General Public* License as published by the Free Software Foundation; either* version 2.1 of the License, or (at your option) any later version.- *+ ** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.- *+ ** You should have received a copy of the GNU Lesser General Public License* along with this program in the file lgpl21.txt* If not, see <http://www.gnu.org/licenses/>.@@ -36,8 +36,8 @@ public class Context<SpecificFinding extends Finding<SpecificRole>,SpecificModel extends Model<SpecificRole, SpecificFinding>>{-- private static final Object PRESENT = (Object) "";++ private static final Object PRESENT = "";private final Goal<SpecificRole, SpecificFinding, SpecificModel> goal;private final SpecificModel initialModel;private final SpecificRole initialRole;@@ -50,7 +50,7 @@ public class Context<private final boolean feedAssetCache, useAssetCache;private long startTime;private boolean fullfilled;-+protected Context(Goal<SpecificRole, SpecificFinding, SpecificModel> goal,SpecificModel initialModel,@@ -69,11 +69,11 @@ public class Context<this.feedAssetCache = feedAssetCache;this.useAssetCache = useAssetCache;}-+public int getInstanceCount() {return this.instances.get();}-+public void incInstances() {this.instances.incrementAndGet();}@@ -82,52 +82,51 @@ public class Context<return this.instances.decrementAndGet();}-+public boolean setBestMove(SpecificRole role, int ranking) {Integer b = this.bestMove.get(role);if (b == null) {this.bestMove.put(role, ranking);System.out.println("first move");return true;- } else {- if (b.intValue() < ranking) {- System.out.println("best next move");- this.bestMove.put(role, ranking);- return true;- }+ }+ if (b.intValue() < ranking) {+ System.out.println("best next move");+ this.bestMove.put(role, ranking);+ return true;}return false;}-+public int getBestMove(SpecificRole role) {Integer b = this.bestMove.get(role);if (b == null) return Integer.MIN_VALUE;return b.intValue();}-+public void addModel(SpecificModel model) {if (model.toString().equals("[],[3, 2, 1],[]")) {System.out.println("target");}this.models.put(model, PRESENT);}-+public Goal<SpecificRole, SpecificFinding, SpecificModel> getGoal() {- return goal;+ return this.goal;}-+public SpecificModel getInitialModel() {- return initialModel;+ return this.initialModel;}-+public boolean isKnownModel(SpecificModel model) {return this.models.containsKey(model);}-+public int getKnownModelsCount() {return this.models.size();}-+public void registerResult(Agent<SpecificRole, SpecificFinding, SpecificModel> agent, SpecificFinding finding) {assert agent != null;assert agent.getFinding() != null;@@ -135,11 +134,11 @@ public class Context<assert finding != null;this.result.offer(new Challenge<SpecificRole, SpecificFinding, SpecificModel>(agent, finding));}-+public SpecificRole initialRole() {return this.initialRole;}-+/*** return one of the results from the problem solving computation.* if there is no result available, then return null.@@ -156,39 +155,39 @@ public class Context<return resultChallenge;}// if this state is reached then all possible findings will cause a lost situation-+return null;} catch (InterruptedException e) {return null;}}-+public boolean hasNoResults() {return this.result.isEmpty();}-+public int countResults() {return this.result.size();}-+public void reset() {this.startTime = System.currentTimeMillis();this.termination.drainPermits();}public boolean feedAssetCache() {- return feedAssetCache;+ return this.feedAssetCache;}-+public boolean useAssetCache() {- return useAssetCache;+ return this.useAssetCache;}-+public void announceCompletion() {this.fullfilled = true;this.termination.release();}-+public boolean isCompleted() {if (this.fullfilled) return true;//System.out.println("runtime = " + runtime);@@ -206,7 +205,7 @@ public class Context<public void awaitTermination(long pauseAfterAquire, boolean announceCompletionAfterTimeOut) {try {- if (this.termination.tryAcquire(timeoutForSnapshot, TimeUnit.MILLISECONDS)) {+ if (this.termination.tryAcquire(this.timeoutForSnapshot, TimeUnit.MILLISECONDS)) {Thread.sleep(pauseAfterAquire);} else {System.out.println("timed-out termination");@@ -214,7 +213,7 @@ public class Context<} catch (InterruptedException e) {}if (announceCompletionAfterTimeOut) announceCompletion();}-+public void printReport(int count) {System.out.println("==== " + this.getKnownModelsCount() + " models computed");Challenge<SpecificRole, SpecificFinding, SpecificModel> resultChallenge;diff --git a/source/net/yacy/cora/document/JSONObject.java b/source/net/yacy/cora/document/JSONObject.javaindex 0d7e540fb..60f96c87d 100644--- a/source/net/yacy/cora/document/JSONObject.java+++ b/source/net/yacy/cora/document/JSONObject.java@@ -27,8 +27,8 @@ package net.yacy.cora.document;import java.io.IOException;import java.io.Writer;import java.lang.reflect.Field;-import java.lang.reflect.Modifier;import java.lang.reflect.Method;+import java.lang.reflect.Modifier;import java.util.Collection;import java.util.HashMap;import java.util.Iterator;@@ -136,7 +136,7 @@ public class JSONObject {/*** The map where the JSONObject's properties are kept.*/- private Map<String, Object> map;+ private final Map<String, Object> map;/**@@ -162,14 +162,14 @@ public class JSONObject {* Missing keys are ignored.* @param jo A JSONObject.* @param names An array of strings.- * @throws JSONException+ * @throws JSONException* @exception JSONException If a value is a non-finite number or if a name is duplicated.*/public JSONObject(JSONObject jo, String[] names) {this();- for (int i = 0; i < names.length; i += 1) {+ for (String name : names) {try {- putOnce(names[i], jo.opt(names[i]));+ putOnce(name, jo.opt(name));} catch (Exception ignore) {}}@@ -242,7 +242,7 @@ public class JSONObject {** @param map A map object that can be used to initialize the contents of* the JSONObject.- * @throws JSONException+ * @throws JSONException*/public JSONObject(Map<String, Object> map) {this.map = new HashMap<String, Object>();@@ -295,8 +295,7 @@ public class JSONObject {public JSONObject(Object object, String names[]) {this();Class<? extends Object> c = object.getClass();- for (int i = 0; i < names.length; i += 1) {- String name = names[i];+ for (String name : names) {try {putOpt(name, c.getField(name).get(object));} catch (Exception ignore) {@@ -462,7 +461,7 @@ public class JSONObject {/**- * Get the int value associated with a key.+ * Get the int value associated with a key.** @param key A key string.* @return The integer value.@@ -519,7 +518,7 @@ public class JSONObject {/**- * Get the long value associated with a key.+ * Get the long value associated with a key.** @param key A key string.* @return The long value.@@ -603,8 +602,8 @@ public class JSONObject {public boolean has(String key) {return this.map.containsKey(key);}--++/*** Increment a property of a JSONObject. If there is no such property,* create one with a value of 1. If there is such a property, and if@@ -622,11 +621,11 @@ public class JSONObject {if (value instanceof Integer) {put(key, ((Integer)value).intValue() + 1);} else if (value instanceof Long) {- put(key, ((Long)value).longValue() + 1);+ put(key, ((Long)value).longValue() + 1);} else if (value instanceof Double) {- put(key, ((Double)value).doubleValue() + 1);+ put(key, ((Double)value).doubleValue() + 1);} else if (value instanceof Float) {- put(key, ((Float)value).floatValue() + 1);+ put(key, ((Float)value).floatValue() + 1);} else {throw new JSONException("Unable to increment [" + key + "].");}@@ -910,20 +909,19 @@ public class JSONObject {private void populateMap(Object bean) {Class<? extends Object> klass = bean.getClass();-// If klass is a System class then set includeSuperClass to false.+// If klass is a System class then set includeSuperClass to false.boolean includeSuperClass = klass.getClassLoader() != null;Method[] methods = (includeSuperClass) ?klass.getMethods() : klass.getDeclaredMethods();- for (int i = 0; i < methods.length; i += 1) {+ for (Method method : methods) {try {- Method method = methods[i];if (Modifier.isPublic(method.getModifiers())) {String name = method.getName();String key = "";if (name.startsWith("get")) {- if (name.equals("getClass") ||+ if (name.equals("getClass") ||name.equals("getDeclaringClass")) {key = "";} else {@@ -944,7 +942,7 @@ public class JSONObject {Object result = method.invoke(bean, (Object[])null);- map.put(key, wrap(result));+ this.map.put(key, wrap(result));}}} catch (Exception ignore) {@@ -1206,8 +1204,8 @@ public class JSONObject {}/*- * If it might be a number, try converting it.- * We support the non-standard 0x- convention.+ * If it might be a number, try converting it.+ * We support the non-standard 0x- convention.* If a number cannot be produced, then the value will just* be a string. Note that the 0x-, plus, and implied string* conventions are non-standard. A JSON parser may accept@@ -1224,17 +1222,15 @@ public class JSONObject {}}try {- if (s.indexOf('.') > -1 ||+ if (s.indexOf('.') > -1 ||s.indexOf('e') > -1 || s.indexOf('E') > -1) {return Float.valueOf(s);- } else {- Long myLong = new Long(s);- if (myLong.longValue() == myLong.intValue()) {- return new Integer(myLong.intValue());- } else {- return myLong;- }}+ Long myLong = new Long(s);+ if (myLong.longValue() == myLong.intValue()) {+ return new Integer(myLong.intValue());+ }+ return myLong;} catch (Exception ignore) {}}@@ -1432,7 +1428,7 @@ public class JSONObject {return new JSONObject((Map<String, Object>) value).toString();}if (value instanceof Collection) {- return new JSONArray((Collection<?>)value).toString();+ return new JSONArray(value).toString();}if (value.getClass().isArray()) {return new JSONArray(value).toString();@@ -1483,7 +1479,7 @@ public class JSONObject {return new JSONObject((Map<String, Object>) value).toString(indentFactor, indent);}if (value instanceof Collection) {- return new JSONArray((Collection<?>) value).toString(indentFactor, indent);+ return new JSONArray(value).toString(indentFactor, indent);}if (value.getClass().isArray()) {return new JSONArray(value).toString(indentFactor, indent);@@ -1493,11 +1489,11 @@ public class JSONObject {/**- * Wrap an object, if necessary. If the object is null, return the NULL- * object. If it is an array or collection, wrap it in a JSONArray. If- * it is a map, wrap it in a JSONObject. If it is a standard property- * (Double, String, et al) then it is already wrapped. Otherwise, if it- * comes from one of the java packages, turn it into a string. And if+ * Wrap an object, if necessary. If the object is null, return the NULL+ * object. If it is an array or collection, wrap it in a JSONArray. If+ * it is a map, wrap it in a JSONObject. If it is a standard property+ * (Double, String, et al) then it is already wrapped. Otherwise, if it+ * comes from one of the java packages, turn it into a string. And if* it doesn't, try to wrap it in a JSONObject. If the wrapping fails,* then null is returned.*@@ -1510,17 +1506,17 @@ public class JSONObject {if (object == null) {return NULL;}- if (object instanceof JSONObject || object instanceof JSONArray ||+ if (object instanceof JSONObject || object instanceof JSONArray ||object instanceof Byte || object instanceof Character ||object instanceof Short || object instanceof Integer ||- object instanceof Long || object instanceof Boolean ||+ object instanceof Long || object instanceof Boolean ||object instanceof Float || object instanceof Double ||object instanceof String || NULL.equals(object)) {return object;}-+if (object instanceof Collection) {- return new JSONArray((Collection<?>) object);+ return new JSONArray(object);}if (object.getClass().isArray()) {return new JSONArray(object);@@ -1541,7 +1537,7 @@ public class JSONObject {}}-+/*** Write the contents of the JSONObject as JSON text to a writer.* For compactness, no whitespace is added.diff --git a/source/net/yacy/cora/lod/vocabulary/Tagging.java b/source/net/yacy/cora/lod/vocabulary/Tagging.javaindex 6a931eb88..f8716d59c 100644--- a/source/net/yacy/cora/lod/vocabulary/Tagging.java+++ b/source/net/yacy/cora/lod/vocabulary/Tagging.java@@ -328,9 +328,8 @@ public class Tagging {}if (pl[0].equals(term)) {continue vocloop;- } else {- w.write(pl[0] + (pl[1] == null || pl[1].length() == 0 ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].length() == 0 || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");}+ w.write(pl[0] + (pl[1] == null || pl[1].length() == 0 ? "" : ":" + pl[1]) + (pl[2] == null || pl[2].length() == 0 || pl[2].equals(this.objectspace + pl[0]) ? "" : "#" + pl[2]) + "\n");}} catch (InterruptedException e) {}diff --git a/source/net/yacy/cora/protocol/ResponseHeader.java b/source/net/yacy/cora/protocol/ResponseHeader.javaindex a691f1bf3..6d405d33a 100644--- a/source/net/yacy/cora/protocol/ResponseHeader.java+++ b/source/net/yacy/cora/protocol/ResponseHeader.java@@ -73,7 +73,7 @@ public class ResponseHeader extends HeaderFramework {public Date date() {final Date d = headerDate(HeaderFramework.DATE);- if (d == null) return new Date(); else return d;+ return (d == null) ? new Date() : d;}public Date expires() {@@ -82,7 +82,7 @@ public class ResponseHeader extends HeaderFramework {public Date lastModified() {final Date d = headerDate(LAST_MODIFIED);- if (d == null) return date(); else return d;+ return (d == null) ? date() : d;}public long age() {diff --git a/source/net/yacy/cora/protocol/ftp/FTPClient.java b/source/net/yacy/cora/protocol/ftp/FTPClient.javaindex 12fc239f5..31f446439 100644--- a/source/net/yacy/cora/protocol/ftp/FTPClient.java+++ b/source/net/yacy/cora/protocol/ftp/FTPClient.java@@ -423,9 +423,8 @@ public class FTPClient {// appropriate error messageif (isFolder(path)) {throw new IOException(reply2);- } else {- throw new IOException(reply1);}+ throw new IOException(reply1);}}}@@ -2316,9 +2315,8 @@ public class FTPClient {/*reply =*/ receive();// boolean success = !isNotPositiveCompletion(reply);return os.toByteArray();- } else {- throw new IOException(reply);}+ throw new IOException(reply);}diff --git a/source/net/yacy/cora/storage/ConfigurationSet.java b/source/net/yacy/cora/storage/ConfigurationSet.javaindex 8682fbba4..a079e4855 100644--- a/source/net/yacy/cora/storage/ConfigurationSet.java+++ b/source/net/yacy/cora/storage/ConfigurationSet.java@@ -79,39 +79,38 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializa// is comment line - do nothingif (s.startsWith("##")) comment = s.substring(2);continue;+ }+ if (s.startsWith("#")) {+ enabled = false ;+ s = s.substring (1).trim();} else {- if (s.startsWith("#")) {- enabled = false ;- s = s.substring (1).trim();- } else {- enabled = true;- }- if (s.contains("#")) {- // second # = text afterwards is a comment- i = s.indexOf("#");- comment = s.substring(i+1);- s = s.substring(0,i).trim();- } else {- // comment = null;- }- if (s.contains("=")) {- i = s.indexOf("=");- key = s.substring(0,i).trim();- value = s.substring(i+1).trim();- if (value.isEmpty()) value = null;+ enabled = true;+ }+ if (s.contains("#")) {+ // second # = text afterwards is a comment+ i = s.indexOf("#");+ comment = s.substring(i+1);+ s = s.substring(0,i).trim();+ } else {+ // comment = null;+ }+ if (s.contains("=")) {+ i = s.indexOf("=");+ key = s.substring(0,i).trim();+ value = s.substring(i+1).trim();+ if (value.isEmpty()) value = null;- } else {- key = s.trim();- value = null;- }- if (!key.isEmpty()) {- Entry entry = new Entry(key, value, enabled);- if (comment != null) {- entry.setComment(comment);- comment = null;- }- this.put(key, entry);+ } else {+ key = s.trim();+ value = null;+ }+ if (!key.isEmpty()) {+ Entry entry = new Entry(key, value, enabled);+ if (comment != null) {+ entry.setComment(comment);+ comment = null;}+ this.put(key, entry);}}} catch (final IOException e) {@@ -221,33 +220,32 @@ public class ConfigurationSet extends TreeMap<String,Entry> implements Serializa// is comment line - write as iswriter.write(sorig + "\n");continue;+ }+ if (sorig.startsWith("#")) {+ s = sorig.substring (1).trim();} else {- if (sorig.startsWith("#")) {- s = sorig.substring (1).trim();- } else {- s = sorig;- }- if (s.contains("#")) {- // second # = is a line comment- i = s.indexOf("#");- s = s.substring(0,i).trim();- }- if (s.contains("=")) {- i = s.indexOf("=");- key = s.substring(0,i).trim();- } else {- key = s.trim();- }- if (!key.isEmpty()) {- Entry e = this.get(key);- if (e != null) {- writer.write (e.toString());- tclone.remove(key); // remove written entries from clone- } else {writer.write(sorig); }- writer.write("\n");- } else {- writer.write(sorig+"\n");- }+ s = sorig;+ }+ if (s.contains("#")) {+ // second # = is a line comment+ i = s.indexOf("#");+ s = s.substring(0,i).trim();+ }+ if (s.contains("=")) {+ i = s.indexOf("=");+ key = s.substring(0,i).trim();+ } else {+ key = s.trim();+ }+ if (!key.isEmpty()) {+ Entry e = this.get(key);+ if (e != null) {+ writer.write (e.toString());+ tclone.remove(key); // remove written entries from clone+ } else {writer.write(sorig); }+ writer.write("\n");+ } else {+ writer.write(sorig+"\n");}}reader.close();diff --git a/source/net/yacy/cora/storage/SimpleARC.java b/source/net/yacy/cora/storage/SimpleARC.javaindex 8ee383d90..4977b1f10 100644--- a/source/net/yacy/cora/storage/SimpleARC.java+++ b/source/net/yacy/cora/storage/SimpleARC.java@@ -55,6 +55,7 @@ abstract class SimpleARC<K, V> extends AbstractMap<K, V> implements Map<K, V>, I* @param s* @param v*/+ @Overridepublic final synchronized void insert(final K s, final V v) {if (this.levelB.containsKey(s)) {this.levelB.put(s, v);@@ -71,6 +72,7 @@ abstract class SimpleARC<K, V> extends AbstractMap<K, V> implements Map<K, V>, I* @param s* @param v*/+ @Overridepublic void insertIfAbsent(final K s, final V v) {if (this.levelB.containsKey(s)) {return;@@ -98,6 +100,7 @@ abstract class SimpleARC<K, V> extends AbstractMap<K, V> implements Map<K, V>, I* @param v* @return the value before inserting the new value*/+ @Overridepublic V putIfAbsent(final K s, final V v) {synchronized (this) {V o = this.levelB.get(s);@@ -115,16 +118,16 @@ abstract class SimpleARC<K, V> extends AbstractMap<K, V> implements Map<K, V>, I* @param s* @param v*/+ @Overridepublic final synchronized V put(final K s, final V v) {if (this.levelB.containsKey(s)) {final V r = this.levelB.put(s, v);assert (this.levelB.size() <= this.cacheSize); // the cache should shrink automaticallyreturn r;- } else {- final V r = this.levelA.put(s, v);- assert (this.levelA.size() <= this.cacheSize); // the cache should shrink automatically- return r;}+ final V r = this.levelA.put(s, v);+ assert (this.levelA.size() <= this.cacheSize); // the cache should shrink automatically+ return r;}/**@@ -158,6 +161,7 @@ abstract class SimpleARC<K, V> extends AbstractMap<K, V> implements Map<K, V>, I* @param value* @return the keys that have the given value*/+ @Overridepublic Collection<K> getKeys(final V value) {final ArrayList<K> keys = new ArrayList<K>();synchronized (this.levelB) {@@ -218,6 +222,7 @@ abstract class SimpleARC<K, V> extends AbstractMap<K, V> implements Map<K, V>, I/*** iterator implements the Iterable interface*/+ @Overridepublic final Iterator<Map.Entry<K, V>> iterator() {return entrySet().iterator();}diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.javaindex 366cfa4c9..905576086 100644--- a/source/net/yacy/document/TextParser.java+++ b/source/net/yacy/document/TextParser.java@@ -178,7 +178,7 @@ public final class TextParser {} finally {if (sourceStream != null) try { sourceStream.close(); } catch (final Exception ex) {}}-+return docs;}@@ -313,14 +313,13 @@ public final class TextParser {final String errorMsg = "Parsing content with file extension '" + location.getFileExtension() + "' and mimetype '" + mimeType + "' failed.";//log.logWarning("Unable to parse '" + location + "'. " + errorMsg);throw new Parser.Failure(errorMsg, location);- } else {- String failedParsers = "";- for (final Map.Entry<Parser, Parser.Failure> error: failedParser.entrySet()) {- log.logWarning("tried parser '" + error.getKey().getName() + "' to parse " + location.toNormalform(true, false) + " but failed: " + error.getValue().getMessage(), error.getValue());- failedParsers += error.getKey().getName() + " ";- }- throw new Parser.Failure("All parser failed: " + failedParsers, location);}+ String failedParsers = "";+ for (final Map.Entry<Parser, Parser.Failure> error: failedParser.entrySet()) {+ log.logWarning("tried parser '" + error.getKey().getName() + "' to parse " + location.toNormalform(true, false) + " but failed: " + error.getValue().getMessage(), error.getValue());+ failedParsers += error.getKey().getName() + " ";+ }+ throw new Parser.Failure("All parser failed: " + failedParsers, location);}for (final Document d: docs) { assert d.getTextStream() != null : "mimeType = " + mimeType; } // verify docsdiff --git a/source/net/yacy/document/WordCache.java b/source/net/yacy/document/WordCache.javaindex 24951c991..cbce70c61 100644--- a/source/net/yacy/document/WordCache.java+++ b/source/net/yacy/document/WordCache.java@@ -54,7 +54,7 @@ public class WordCache {static {Log.logConfig("WordCache", "commonWordsMaxSize = " + commonWordsMaxSize);}-+// dictionariesprivate final File dictionaryPath;final Map<String, Dictionary> dictionaries;@@ -65,7 +65,7 @@ public class WordCache {private final TreeSet<StringBuilder> tcid; // the dictionary of reverse wordspublic Dictionary(final File file) throws IOException {-+this.dict = new TreeSet<StringBuilder>(StringBuilderComparator.CASE_INSENSITIVE_ORDER);this.tcid = new TreeSet<StringBuilder>(StringBuilderComparator.CASE_INSENSITIVE_ORDER);@@ -144,18 +144,16 @@ public class WordCache {for (final StringBuilder r: t) {if (StringBuilderComparator.CASE_INSENSITIVE_ORDER.startsWith(string, r)) {return true;- } else {- break;}+ break;}string = reverse(string);t = this.tcid.tailSet(string);for (final StringBuilder r: t) {if (StringBuilderComparator.CASE_INSENSITIVE_ORDER.startsWith(string, r)) {return true;- } else {- break;}+ break;}return false;}diff --git a/source/net/yacy/document/importer/MediawikiImporter.java b/source/net/yacy/document/importer/MediawikiImporter.javaindex dc739d5de..8ec4d32dc 100644--- a/source/net/yacy/document/importer/MediawikiImporter.java+++ b/source/net/yacy/document/importer/MediawikiImporter.java@@ -223,9 +223,8 @@ public class MediawikiImporter extends Thread implements Importer {}sb = new StringBuilder(200);continue;- } else {- sb.append(t.substring(q + 1));}+ sb.append(t.substring(q + 1));}continue;}diff --git a/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java b/source/net/yacy/document/parser/rdfa/impl/RDFaParser.javaindex ee58f68d6..0240be779 100644--- a/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java+++ b/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java@@ -61,10 +61,8 @@ public class RDFaParser extends AbstractParser implements Parser {}retDocs[retDocs.length - 1] = rdfaDoc;return retDocs;- } else {- return htmlDocs;}-+ return htmlDocs;}private Document parseRDFa(DigestURI url, String mimeType,@@ -93,7 +91,6 @@ public class RDFaParser extends AbstractParser implements Parser {"Conversion triple to document failed");}return doc;-}private Document[] parseHtml(DigestURI url, String mimeType,@@ -109,7 +106,6 @@ public class RDFaParser extends AbstractParser implements Parser {Log.logWarning("RDFA PARSER", "Super call failed");}return htmlDocs;-}private Document convertAllTriplesToDocument(DigestURI url,@@ -155,8 +151,7 @@ public class RDFaParser extends AbstractParser implements Parser {public static void main(String[] args) {URL aURL = null;if (args.length < 1) {- System.out- .println("Usage: one and only one argument giving a file path or a URL.");+ System.out.println("Usage: one and only one argument giving a file path or a URL.");} else {File aFile = new File(args[0]);Reader aReader = null;diff --git a/source/net/yacy/document/parser/sidAudioParser.java b/source/net/yacy/document/parser/sidAudioParser.javaindex be68d8409..8f793d9db 100644--- a/source/net/yacy/document/parser/sidAudioParser.java+++ b/source/net/yacy/document/parser/sidAudioParser.java@@ -55,10 +55,10 @@ public class sidAudioParser extends AbstractParser implements Parser {this.SUPPORTED_MIME_TYPES.add("audio/x-sidtune");}+ @Overridepublic Document[] parse(final DigestURI location, final String mimeType,final String charset, final InputStream source)- throws Parser.Failure, InterruptedException- {+ throws Parser.Failure, InterruptedException {try {final int available = source.available();final byte[] b = new byte[available];@@ -96,9 +96,8 @@ public class sidAudioParser extends AbstractParser implements Parser {null,null,false)};- } else {- throw new Parser.Failure("Unable to parse SID file, file does seems to be incomplete (len = " + available + ").", location);}+ throw new Parser.Failure("Unable to parse SID file, file does seems to be incomplete (len = " + available + ").", location);} catch (IOException ex) {throw new Parser.Failure("Unable to read SID file header.", location, ex);}diff --git a/source/net/yacy/interaction/AugmentHtmlStream.java b/source/net/yacy/interaction/AugmentHtmlStream.javaindex ef0e28d04..7788a3821 100644--- a/source/net/yacy/interaction/AugmentHtmlStream.java+++ b/source/net/yacy/interaction/AugmentHtmlStream.java@@ -401,11 +401,9 @@ public class AugmentHtmlStream {if (augmented) {-return (new StringBuffer (Doc));- } else {- return (data);}+ return (data);}}\ No newline at end of filediff --git a/source/net/yacy/kelondro/blob/ArrayStack.java b/source/net/yacy/kelondro/blob/ArrayStack.javaindex 7ba21ae54..2af1e674e 100644--- a/source/net/yacy/kelondro/blob/ArrayStack.java+++ b/source/net/yacy/kelondro/blob/ArrayStack.java@@ -910,22 +910,21 @@ public class ArrayStack implements BLOB {}Log.logInfo("BLOBArray", "rewrite of " + f1.getName() + " into " + resultFile);return resultFile;- } else {- Log.logInfo("BLOBArray", "merging " + f1.getName() + " with " + f2.getName());- final File resultFile = mergeWorker(factory, this.keylength, this.ordering, f1, f2, newFile, writeBuffer);- if (resultFile == null) {- Log.logWarning("BLOBArray", "merge of files " + f1 + ", " + f2 + " returned null. newFile = " + newFile);- return null;- }- try {- mountBLOB(resultFile, false);- } catch (final IOException e) {- Log.logWarning("BLOBArray", "merge of files " + f1 + ", " + f2 + " successfull, but read failed. resultFile = " + resultFile);- return null;- }- Log.logInfo("BLOBArray", "merged " + f1.getName() + " with " + f2.getName() + " into " + resultFile);- return resultFile;}+ Log.logInfo("BLOBArray", "merging " + f1.getName() + " with " + f2.getName());+ final File resultFile = mergeWorker(factory, this.keylength, this.ordering, f1, f2, newFile, writeBuffer);+ if (resultFile == null) {+ Log.logWarning("BLOBArray", "merge of files " + f1 + ", " + f2 + " returned null. newFile = " + newFile);+ return null;+ }+ try {+ mountBLOB(resultFile, false);+ } catch (final IOException e) {+ Log.logWarning("BLOBArray", "merge of files " + f1 + ", " + f2 + " successfull, but read failed. resultFile = " + resultFile);+ return null;+ }+ Log.logInfo("BLOBArray", "merged " + f1.getName() + " with " + f2.getName() + " into " + resultFile);+ return resultFile;}private static <ReferenceType extends Reference> File mergeWorker(diff --git a/source/net/yacy/kelondro/blob/MapHeap.java b/source/net/yacy/kelondro/blob/MapHeap.javaindex 57b636391..b28de4b07 100644--- a/source/net/yacy/kelondro/blob/MapHeap.java+++ b/source/net/yacy/kelondro/blob/MapHeap.java@@ -334,19 +334,18 @@ public class MapHeap implements Map<byte[], Map<String, String>> {// return valuereturn map;}- } else {- byte[] b;- synchronized (this) {- map = this.cache.get(key);- if (map != null) return map;- b = this.blob.get(key);- }- if (b == null) return null;- try {- return bytes2map(b);- } catch (final RowSpaceExceededException e) {- throw new IOException(e.getMessage());- }+ }+ byte[] b = null;+ synchronized (this) {+ map = this.cache.get(key);+ if (map != null) return map;+ b = this.blob.get(key);+ }+ if (b == null) return null;+ try {+ return bytes2map(b);+ } catch (final RowSpaceExceededException e) {+ throw new IOException(e.getMessage());}}diff --git a/source/net/yacy/kelondro/blob/ObjectBuffer.java b/source/net/yacy/kelondro/blob/ObjectBuffer.javaindex ec82b9e13..34c92c733 100644--- a/source/net/yacy/kelondro/blob/ObjectBuffer.java+++ b/source/net/yacy/kelondro/blob/ObjectBuffer.java@@ -12,7 +12,7 @@////// LICENSE-//+//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or@@ -42,7 +42,7 @@// software, even if provoked by documentation provided together with// the software.//-//+//// A NOTE FROM THE AUTHOR TO DEVELOPERS://// Contributions and changes to the program code should be marked as such:@@ -63,12 +63,12 @@ public class ObjectBuffer {// this is a buffer for a single (only one) key/value object// without an index-backend-+private int readHit, readMiss, writeUnique, writeDouble;private final String name;private byte[] key;private Object value;-+public ObjectBuffer(final String name) {this.name = name;this.readHit = 0;@@ -80,18 +80,18 @@ public class ObjectBuffer {}public String getName() {- return name;+ return this.name;}-+public String[] status() {return new String[]{- Integer.toString(readHit),- Integer.toString(readMiss),- Integer.toString(writeUnique),- Integer.toString(writeDouble)+ Integer.toString(this.readHit),+ Integer.toString(this.readMiss),+ Integer.toString(this.writeUnique),+ Integer.toString(this.writeDouble)};}-+private static String[] combinedStatus(final String[] a, final String[] b) {return new String[]{Integer.toString(Integer.parseInt(a[0]) + Integer.parseInt(b[0])),@@ -100,66 +100,64 @@ public class ObjectBuffer {Integer.toString(Integer.parseInt(a[3]) + Integer.parseInt(b[3]))};}-+public static String[] combinedStatus(final String[][] a, final int l) {if ((a == null) || (a.length == 0) || (l == 0)) return null;if ((a.length >= 1) && (l == 1)) return a[0];if ((a.length >= 2) && (l == 2)) return combinedStatus(a[0], a[1]);return combinedStatus(combinedStatus(a, l - 1), a[l - 1]);}-+public void put(final byte[] key, final Object value) {if ((key == null) || (value == null)) return;synchronized(this) {if (NaturalOrder.naturalOrder.equal(this.key, key)){this.writeDouble++;} else {- this.writeUnique++;+ this.writeUnique++;}this.key = key;this.value = value;}}-+public void put(final String key, final Object value) {if ((key == null) || (value == null)) return;synchronized(this) {if (NaturalOrder.naturalOrder.equal(this.key, UTF8.getBytes(key))){this.writeDouble++;} else {- this.writeUnique++;+ this.writeUnique++;}this.key = UTF8.getBytes(key);this.value = value;}}-+public Object get(final byte[] key) {if (key == null) return null;synchronized(this) {if (NaturalOrder.naturalOrder.equal(this.key, key)){this.readHit++;return this.value;- } else {- this.readMiss++;- return null;}+ this.readMiss++;+ return null;}}-+public Object get(final String key) {if (key == null) return null;synchronized(this) {if (NaturalOrder.naturalOrder.equal(this.key, UTF8.getBytes(key))){this.readHit++;return this.value;- } else {- this.readMiss++;- return null;}+ this.readMiss++;+ return null;}}-+public void remove(final byte[] key) {if (key == null) return;synchronized(this) {@@ -169,7 +167,7 @@ public class ObjectBuffer {}}}-+public void remove(final String key) {if (key == null) return;synchronized(this) {@@ -179,5 +177,5 @@ public class ObjectBuffer {}}}-+}diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.javaindex a04e065a7..961375b43 100644--- a/source/net/yacy/kelondro/data/meta/DigestURI.java+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java@@ -295,11 +295,10 @@ public class DigestURI extends MultiProtocolURI implements Serializable {private static final String hosthash5(final String protocol, final String host, final int port) {if (host == null) {return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(protocol)).substring(0, 5);- } else {- final StringBuilder sb = new StringBuilder(host.length() + 15);- sb.append(protocol).append(':').append(host).append(':').append(Integer.toString(port));- return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(sb.toString())).substring(0, 5);}+ final StringBuilder sb = new StringBuilder(host.length() + 15);+ sb.append(protocol).append(':').append(host).append(':').append(Integer.toString(port));+ return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(sb.toString())).substring(0, 5);}/**diff --git a/source/net/yacy/kelondro/index/Cache.java b/source/net/yacy/kelondro/index/Cache.javaindex 17e275efb..0ae2ae361 100644--- a/source/net/yacy/kelondro/index/Cache.java+++ b/source/net/yacy/kelondro/index/Cache.java@@ -95,6 +95,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {this.hasnotDelete = 0;}+ @Overridepublic long mem() {return this.index.mem() + this.readHitCache.mem() + this.readMissCache.mem();}@@ -119,10 +120,12 @@ public final class Cache implements Index, Iterable<Row.Entry> {return this.missLimit;}+ @Overridepublic byte[] smallestKey() {return this.index.smallestKey();}+ @Overridepublic byte[] largestKey() {return this.index.largestKey();}@@ -234,21 +237,22 @@ public final class Cache implements Index, Iterable<Row.Entry> {if (this.readHitCache != null) this.readHitCache.clear();}+ @Overridepublic final synchronized void close() {this.index.close();this.readHitCache = null;this.readMissCache = null;}+ @Overridepublic final synchronized boolean has(final byte[] key) {// first look into the miss cacheif (this.readMissCache != null) {if (this.readMissCache.has(key)) {this.hasnotHit++;return false;- } else {- this.hasnotMiss++;}+ this.hasnotMiss++;}// then try the hit cache and the buffers@@ -256,24 +260,23 @@ public final class Cache implements Index, Iterable<Row.Entry> {if (this.readHitCache.has(key)) {this.readHit++;return true;- } else {- this.readMiss++;}+ this.readMiss++;}// finally ask the back-end indexreturn this.index.has(key);}+ @Overridepublic final synchronized Row.Entry get(final byte[] key, final boolean cachecopy) throws IOException {// first look into the miss cacheif (this.readMissCache != null) {if (this.readMissCache.has(key)) {this.hasnotHit++;return null;- } else {- this.hasnotMiss++;}+ this.hasnotMiss++;}Row.Entry entry = null;@@ -310,6 +313,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {return entry;}+ @Overridepublic Map<byte[], Row.Entry> get(final Collection<byte[]> keys, final boolean forcecopy) throws IOException, InterruptedException {final Map<byte[], Row.Entry> map = new TreeMap<byte[], Row.Entry>(row().objectOrder);Row.Entry entry;@@ -320,6 +324,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {return map;}+ @Overridepublic final synchronized boolean put(final Row.Entry row) throws IOException, RowSpaceExceededException {assert (row != null);assert (row.columns() == row().columns());@@ -353,6 +358,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {return c;}+ @Overridepublic final synchronized Row.Entry replace(final Row.Entry row) throws IOException, RowSpaceExceededException {assert (row != null);assert (row.columns() == row().columns());@@ -402,6 +408,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {return entry;}+ @Overridepublic final synchronized void addUnique(final Row.Entry row) throws IOException, RowSpaceExceededException {assert (row != null);assert (row.columns() == row().columns());@@ -482,11 +489,13 @@ public final class Cache implements Index, Iterable<Row.Entry> {}}+ @Overridepublic final synchronized List<RowCollection> removeDoubles() throws IOException, RowSpaceExceededException {return this.index.removeDoubles();// todo: remove reported entries from the cache!!!}+ @Overridepublic final synchronized boolean delete(final byte[] key) throws IOException {checkMissSpace();@@ -518,6 +527,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {return this.index.delete(key);}+ @Overridepublic final synchronized Row.Entry remove(final byte[] key) throws IOException {checkMissSpace();@@ -549,6 +559,7 @@ public final class Cache implements Index, Iterable<Row.Entry> {return this.index.remove(key);}+ @Overridepublic final synchronized Row.Entry removeOne() throws IOException {checkMissSpace();@@ -568,22 +579,27 @@ public final class Cache implements Index, Iterable<Row.Entry> {return entry;}+ @Overridepublic synchronized List<Row.Entry> top(final int count) throws IOException {return this.index.top(count);}+ @Overridepublic final synchronized Row row() {return this.index.row();}+ @Overridepublic final synchronized CloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) throws IOException {return this.index.keys(up, firstKey);}+ @Overridepublic final synchronized CloneableIterator<Row.Entry> rows(final boolean up, final byte[] firstKey) throws IOException {return this.index.rows(up, firstKey);}+ @Overridepublic final Iterator<Entry> iterator() {try {return rows();@@ -592,27 +608,33 @@ public final class Cache implements Index, Iterable<Row.Entry> {}}+ @Overridepublic final synchronized CloneableIterator<Row.Entry> rows() throws IOException {return this.index.rows();}+ @Overridepublic final int size() {return this.index.size();}+ @Overridepublic final boolean isEmpty() {return this.index.isEmpty();}+ @Overridepublic final String filename() {return this.index.filename();}+ @Overridepublic final void clear() throws IOException {this.index.clear();init();}+ @Overridepublic final void deleteOnExit() {this.index.deleteOnExit();}diff --git a/source/net/yacy/kelondro/index/RowSet.java b/source/net/yacy/kelondro/index/RowSet.javaindex 8185662ff..fb8807a92 100644--- a/source/net/yacy/kelondro/index/RowSet.java+++ b/source/net/yacy/kelondro/index/RowSet.java@@ -175,12 +175,11 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>,if (index < 0) {super.addUnique(entry);return true;- } else {- final int sb = this.sortBound; // save the sortBound, because it is not altered (we replace at the same place)- set(index, entry); // this may alter the sortBound, which we will revert in the next step- this.sortBound = sb; // revert a sortBound altering- return false;}+ final int sb = this.sortBound; // save the sortBound, because it is not altered (we replace at the same place)+ set(index, entry); // this may alter the sortBound, which we will revert in the next step+ this.sortBound = sb; // revert a sortBound altering+ return false;}}@@ -245,10 +244,9 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>,index = find(a, 0);if (index < 0) {return exists;- } else {- exists = true;- super.removeRow(index, true); // keep order of collection!}+ exists = true;+ super.removeRow(index, true); // keep order of collection!}}@@ -277,10 +275,9 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>,index = find(a, 0);if (index < 0) {return entry;- } else {- entry = super.get(index, true);- super.removeRow(index, true); // keep order of collection!}+ entry = super.get(index, true);+ super.removeRow(index, true); // keep order of collection!}}@@ -393,11 +390,7 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>,public final boolean hasNext() {if (this.p < 0) return false;if (this.p >= size()) return false;- if (this.up) {- return this.p < this.bound;- } else {- return this.p >= 0;- }+ return (this.up) ? this.p < this.bound : this.p >= 0;}@Override@@ -464,11 +457,7 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>,public final boolean hasNext() {if (this.p < 0) return false;if (this.p >= size()) return false;- if (this.up) {- return this.p < this.bound;- } else {- return this.p >= 0;- }+ return (this.up) ? this.p < this.bound : this.p >= 0;}@Overridediff --git a/source/net/yacy/kelondro/rwi/IndexCell.java b/source/net/yacy/kelondro/rwi/IndexCell.javaindex e29797ec6..523bfbce6 100644--- a/source/net/yacy/kelondro/rwi/IndexCell.java+++ b/source/net/yacy/kelondro/rwi/IndexCell.java@@ -180,25 +180,29 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu// first try to merge small files that matchint term = 10;while (term-- > 0 && (this.merger.queueLength() < 3 || this.array.entries() >= 50)) {- if (!this.array.shrinkBestSmallFiles(this.merger, targetFileSize)) break; else donesomething = true;+ if (!this.array.shrinkBestSmallFiles(this.merger, targetFileSize)) break;+ donesomething = true;}// then try to merge simply any small fileterm = 10;while (term-- > 0 && (this.merger.queueLength() < 2)) {- if (!this.array.shrinkAnySmallFiles(this.merger, targetFileSize)) break; else donesomething = true;+ if (!this.array.shrinkAnySmallFiles(this.merger, targetFileSize)) break;+ donesomething = true;}// if there is no small file, then merge matching files up to limitterm = 10;while (term-- > 0 && (this.merger.queueLength() < 1)) {- if (!this.array.shrinkUpToMaxSizeFiles(this.merger, maxFileSize)) break; else donesomething = true;+ if (!this.array.shrinkUpToMaxSizeFiles(this.merger, maxFileSize)) break;+ donesomething = true;}// rewrite old files (hack from sixcooler, see http://forum.yacy-websuche.de/viewtopic.php?p=15004#p15004)term = 10;while (term-- > 0 && (this.merger.queueLength() < 1)) {- if (!this.array.shrinkOldFiles(this.merger, targetFileSize)) break; else donesomething = true;+ if (!this.array.shrinkOldFiles(this.merger, targetFileSize)) break;+ donesomething = true;}return donesomething;diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainer.java b/source/net/yacy/kelondro/rwi/ReferenceContainer.javaindex 5b5382501..3512ec89b 100644--- a/source/net/yacy/kelondro/rwi/ReferenceContainer.java+++ b/source/net/yacy/kelondro/rwi/ReferenceContainer.java@@ -405,10 +405,8 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet// start most efficient methodif (stepsEnum > stepsTest) {- if (i1.size() < i2.size())- return joinConstructiveByTest(factory, i1, i2, maxDistance);- else- return joinConstructiveByTest(factory, i2, i1, maxDistance);+ if (i1.size() < i2.size()) return joinConstructiveByTest(factory, i1, i2, maxDistance);+ return joinConstructiveByTest(factory, i2, i1, maxDistance);}return joinConstructiveByEnumeration(factory, i1, i2, maxDistance);}diff --git a/source/net/yacy/kelondro/util/ByteArray.java b/source/net/yacy/kelondro/util/ByteArray.javaindex fe05ea19f..1aab46737 100644--- a/source/net/yacy/kelondro/util/ByteArray.java+++ b/source/net/yacy/kelondro/util/ByteArray.java@@ -147,10 +147,10 @@ public class ByteArray {result -= digit;}if (negative) {- if (i > 1) return result; else throw new NumberFormatException(UTF8.String(s));- } else {- return -result;+ if (i > 1) return result;+ throw new NumberFormatException(UTF8.String(s));}+ return -result;}public static void main(String[] args) {diff --git a/source/net/yacy/kelondro/util/ByteBuffer.java b/source/net/yacy/kelondro/util/ByteBuffer.javaindex 93ef6d7b8..efd6af2b8 100644--- a/source/net/yacy/kelondro/util/ByteBuffer.java+++ b/source/net/yacy/kelondro/util/ByteBuffer.java@@ -549,13 +549,12 @@ public final class ByteBuffer extends OutputStream {System.arraycopy(b, c, bb, 0, bb.length);a.add(bb);break loop;- } else {- // found a separator- final byte[] bb = new byte[i - c];- System.arraycopy(b, c, bb, 0, bb.length);- a.add(bb);- c = i + 1;}+ // found a separator+ final byte[] bb = new byte[i - c];+ System.arraycopy(b, c, bb, 0, bb.length);+ a.add(bb);+ c = i + 1;}return a;}diff --git a/source/net/yacy/kelondro/util/StandardMemoryStrategy.java b/source/net/yacy/kelondro/util/StandardMemoryStrategy.javaindex 7035e9486..401e9c518 100644--- a/source/net/yacy/kelondro/util/StandardMemoryStrategy.java+++ b/source/net/yacy/kelondro/util/StandardMemoryStrategy.java@@ -176,11 +176,10 @@ public class StandardMemoryStrategy extends MemoryStrategy {}checkProper(avail);return avail >= size;- } else {- if (log.isFine()) log.logFine("former GCs indicate to not be able to free enough memory (requested/available/average: "- + (size >> 10) + " / " + (avail >> 10) + " / " + (avg >> 10) + " KB)");- return false;}+ if (log.isFine()) log.logFine("former GCs indicate to not be able to free enough memory (requested/available/average: "+ + (size >> 10) + " / " + (avail >> 10) + " / " + (avg >> 10) + " KB)");+ return false;}/**diff --git a/source/net/yacy/kelondro/workflow/InstantBusyThread.java b/source/net/yacy/kelondro/workflow/InstantBusyThread.javaindex fe8f4b390..d193f65c7 100644--- a/source/net/yacy/kelondro/workflow/InstantBusyThread.java+++ b/source/net/yacy/kelondro/workflow/InstantBusyThread.java@@ -88,10 +88,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTif (this.jobCountMethod == null) return Integer.MAX_VALUE;try {final Object result = this.jobCountMethod.invoke(this.environment);- if (result instanceof Integer)- return ((Integer) result).intValue();- else- return -1;+ return (result instanceof Integer) ? ((Integer) result).intValue() : -1;} catch (final IllegalAccessException e) {return -1;} catch (final IllegalArgumentException e) {diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.javaindex 8e5cd8bb2..2af48cd67 100644--- a/source/net/yacy/peers/Seed.java+++ b/source/net/yacy/peers/Seed.java@@ -1092,11 +1092,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>final String b = crypt.simpleEncode(r, key, 'b');// the compressed string may be longer that the uncompressed if there is too much overhead for compression meta-info// take simply that string that is shorter- if ( b.length() < z.length() ) {- return b;- } else {- return z;- }+ return ( b.length() < z.length() ) ? b : z;}public final void save(final File f) throws IOException {diff --git a/source/net/yacy/peers/dht/PeerSelection.java b/source/net/yacy/peers/dht/PeerSelection.javaindex 334345167..0a30d63c2 100644--- a/source/net/yacy/peers/dht/PeerSelection.java+++ b/source/net/yacy/peers/dht/PeerSelection.java@@ -363,11 +363,10 @@ public class PeerSelection {// take my own seed hash instead the enumeration resultthis.alsoMyOwn = false;return this.seedDB.mySeed();- } else {- final Seed next = this.nextSeed;- this.nextSeed = nextInternal();- return next;}+ final Seed next = this.nextSeed;+ this.nextSeed = nextInternal();+ return next;}@Overridediff --git a/source/net/yacy/repository/FilterEngine.java b/source/net/yacy/repository/FilterEngine.javaindex c2a8eba2f..a35706059 100644--- a/source/net/yacy/repository/FilterEngine.java+++ b/source/net/yacy/repository/FilterEngine.java@@ -124,10 +124,9 @@ public class FilterEngine {// Cache Hitfinal EnumSet<listTypes> e = this.cachedUrlHashs.get(url);return e.containsAll(type);- } else {- // Cache Miss- return isListed(url.getHost().toLowerCase(), url.getFile(), type);}+ // Cache Miss+ return isListed(url.getHost().toLowerCase(), url.getFile(), type);}public static boolean isMatchable (final String host) {diff --git a/source/net/yacy/repository/LoaderDispatcher.java b/source/net/yacy/repository/LoaderDispatcher.javaindex e002c7705..6c572221b 100644--- a/source/net/yacy/repository/LoaderDispatcher.java+++ b/source/net/yacy/repository/LoaderDispatcher.java@@ -232,9 +232,8 @@ public final class LoaderDispatcher {if (response.isFreshForProxy()) {this.log.logInfo("cache hit/fresh for: " + url.toNormalform(true, false));return response;- } else {- this.log.logInfo("cache hit/stale for: " + url.toNormalform(true, false));}+ this.log.logInfo("cache hit/stale for: " + url.toNormalform(true, false));} else if (cachedResponse != null) {this.log.logWarning("HTCACHE contained response header, but not content for url " + url.toNormalform(true, false));} else if (content != null) {diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex 63c5c3c54..81e2a4728 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -1398,9 +1398,8 @@ public final class Switchboard extends serverSwitchif ( clustermode.equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER) ) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.containsKey(ASCII.getBytes(peer));- } else {- return false;}+ return false;}public boolean isInMyCluster(final Seed seed) {@@ -1417,9 +1416,8 @@ public final class Switchboard extends serverSwitchif ( clustermode.equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER) ) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.containsKey(ASCII.getBytes(seed.hash));- } else {- return false;}+ return false;}public String urlExists(final byte[] hash) {@@ -1712,40 +1710,39 @@ public final class Switchboard extends serverSwitchif (zis != null) try {zis.close();} catch (IOException e) {}}return moved;- } else {- try {- InputStream is = new BufferedInputStream(new FileInputStream(infile));- if ( s.endsWith(".gz") ) {- is = new GZIPInputStream(is);- }- processSurrogate(is, infile.getName());- } catch ( final IOException e ) {- Log.logException(e);- } finally {- moved = infile.renameTo(outfile);- if ( moved ) {- // check if this file is already compressed, if not, compress now- if ( !outfile.getName().endsWith(".gz") ) {- final String gzname = outfile.getName() + ".gz";- final File gzfile = new File(outfile.getParentFile(), gzname);- try {- final OutputStream os =- new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(gzfile)));- FileUtils.copy(new BufferedInputStream(new FileInputStream(outfile)), os);- os.close();- if ( gzfile.exists() ) {- FileUtils.deletedelete(outfile);- }- } catch ( final FileNotFoundException e ) {- Log.logException(e);- } catch ( final IOException e ) {- Log.logException(e);+ }+ try {+ InputStream is = new BufferedInputStream(new FileInputStream(infile));+ if ( s.endsWith(".gz") ) {+ is = new GZIPInputStream(is);+ }+ processSurrogate(is, infile.getName());+ } catch ( final IOException e ) {+ Log.logException(e);+ } finally {+ moved = infile.renameTo(outfile);+ if ( moved ) {+ // check if this file is already compressed, if not, compress now+ if ( !outfile.getName().endsWith(".gz") ) {+ final String gzname = outfile.getName() + ".gz";+ final File gzfile = new File(outfile.getParentFile(), gzname);+ try {+ final OutputStream os =+ new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(gzfile)));+ FileUtils.copy(new BufferedInputStream(new FileInputStream(outfile)), os);+ os.close();+ if ( gzfile.exists() ) {+ FileUtils.deletedelete(outfile);}+ } catch ( final FileNotFoundException e ) {+ Log.logException(e);+ } catch ( final IOException e ) {+ Log.logException(e);}}}- return moved;}+ return moved;}public void processSurrogate(final InputStream is, final String name) throws IOException {diff --git a/source/net/yacy/search/query/SnippetProcess.java b/source/net/yacy/search/query/SnippetProcess.javaindex 16fa751da..1995d3077 100644--- a/source/net/yacy/search/query/SnippetProcess.java+++ b/source/net/yacy/search/query/SnippetProcess.java@@ -620,10 +620,8 @@ public class SnippetProcess {Log.logInfo("SEARCH", "sorted out url " + page.url().toNormalform(true, false) + " during search: " + reason);return null;}- } else {- return new ResultEntry(page, this.query.getSegment(), this.peers, null, null, dbRetrievalTime, 0); // result without snippet}- // finished, no more actions possible here+ return new ResultEntry(page, this.query.getSegment(), this.peers, null, null, dbRetrievalTime, 0); // result without snippet}/**diff --git a/source/net/yacy/search/snippet/TextSnippet.java b/source/net/yacy/search/snippet/TextSnippet.javaindex 6ffdb7c32..65839436d 100644--- a/source/net/yacy/search/snippet/TextSnippet.java+++ b/source/net/yacy/search/snippet/TextSnippet.java@@ -187,7 +187,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnipwhile (sr.hasNext()) {sentences.add(sr.next());}-+if (sentences != null) {try {final SnippetExtractor tsr = new SnippetExtractor(sentences, remainingHashes, snippetMaxLength);@@ -231,17 +231,16 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnipif (sentences == null) {init(url.hash(), null, ResultClass.SOURCE_METADATA, null);return;- } else {- // use the first lines from the text as snippet- final StringBuilder s = new StringBuilder(snippetMaxLength);- for (final StringBuilder t: sentences) {- s.append(t).append(' ');- if (s.length() >= snippetMaxLength / 4 * 3) break;- }- if (s.length() > snippetMaxLength) { s.setLength(snippetMaxLength); s.trimToSize(); }- init(url.hash(), s.length() > 0 ? s.toString() : this.line, ResultClass.SOURCE_METADATA, null);- return;}+ // use the first lines from the text as snippet+ final StringBuilder s = new StringBuilder(snippetMaxLength);+ for (final StringBuilder t: sentences) {+ s.append(t).append(' ');+ if (s.length() >= snippetMaxLength / 4 * 3) break;+ }+ if (s.length() > snippetMaxLength) { s.setLength(snippetMaxLength); s.trimToSize(); }+ init(url.hash(), s.length() > 0 ? s.toString() : this.line, ResultClass.SOURCE_METADATA, null);+ return;}// try to load the resource from the cachediff --git a/source/net/yacy/upnp/services/ISO8601Date.java b/source/net/yacy/upnp/services/ISO8601Date.javaindex c43f9bac2..65a334b20 100644--- a/source/net/yacy/upnp/services/ISO8601Date.java+++ b/source/net/yacy/upnp/services/ISO8601Date.java@@ -26,8 +26,8 @@* prior written permission. For written permission, please contact*- * 5. Products derived from this software may not be called- * "SuperBonBon Industries", nor may "SBBI" appear in their name,+ * 5. Products derived from this software may not be called+ * "SuperBonBon Industries", nor may "SBBI" appear in their name,* without prior written permission of SuperBonBon Industries.** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,@@ -42,7 +42,7 @@* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.** This software consists of voluntary contributions made by many individuals- * on behalf of SuperBonBon Industries. For more information on+ * on behalf of SuperBonBon Industries. For more information on* SuperBonBon Industries, please see <http://www.sbbi.net/>.*/package net.yacy.upnp.services;@@ -62,19 +62,18 @@ import java.util.TimeZone;*/public class ISO8601Date {-+private static boolean check(StringTokenizer st, String token) throws NumberFormatException {try {if (st.nextToken().equals(token)) {return true;- } else {- throw new NumberFormatException("Missing [" + token + "]");}+ throw new NumberFormatException("Missing [" + token + "]");} catch (NoSuchElementException ex) {return false;}}-+private static Calendar getCalendar( String isodate ) throws NumberFormatException {// YYYY-MM-DDThh:mm:ss.sTZD or hh:mm:ss.sTZD// does it contains a date ?@@ -111,7 +110,7 @@ public class ISO8601Date {return calendar;}}- // Hour+ // Hourif ( ( check(st, "T") ) && ( st.hasMoreTokens() ) ) {int hour = Integer.parseInt(st.nextToken());calendar.set(Calendar.HOUR_OF_DAY, hour);@@ -132,11 +131,11 @@ public class ISO8601Date {calendar.set(Calendar.MILLISECOND, 0);return calendar;}-+//// Not mandatory now//-+// Secondesif (!st.hasMoreTokens()) {return calendar;@@ -201,7 +200,7 @@ public class ISO8601Date {}return calendar;}-+/*** Parse the given string in ISO 8601 format and build a Date object.* @param isodate the date in ISO 8601 format@@ -213,14 +212,14 @@ public class ISO8601Date {Calendar calendar = getCalendar(isodate);return calendar.getTime();}-+private static String twoDigit(int i) {if (i >= 0 && i < 10) {return "0" + String.valueOf(i);}return String.valueOf(i);}-+/*** Generate a ISO 8601 date* @param date a Date instance@@ -237,7 +236,7 @@ public class ISO8601Date {buffer.append(twoDigit(calendar.get(Calendar.DAY_OF_MONTH)));return buffer.toString();}-+/*** Generate a ISO 8601 date time without timezone* @param date a Date instance@@ -262,7 +261,7 @@ public class ISO8601Date {buffer.append(twoDigit(calendar.get(Calendar.MILLISECOND) / 10));return buffer.toString();}-+/*** Generate a ISO 8601 date time with timezone* @param date a Date instance@@ -288,7 +287,7 @@ public class ISO8601Date {buffer.append("Z");return buffer.toString();}-+/*** Generate a ISO 8601 time* @param date a Date instance@@ -307,7 +306,7 @@ public class ISO8601Date {buffer.append(twoDigit(calendar.get(Calendar.MILLISECOND) / 10));return buffer.toString();}-+/*** Generate a ISO 8601 time* @param date a Date instance@@ -327,5 +326,5 @@ public class ISO8601Date {buffer.append("Z");return buffer.toString();}-+}