Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- fix for http://www.yacy-forum.de/viewtopic.php?t=3657 - fix for http://www.yacy-forum.de/viewtopic.php?p=32758#32758 - Diff takes any objects now, not only strings
karlchenofhell264a82eec87c
diff --git a/htroot/Settings_p.java b/htroot/Settings_p.javaindex b3d993396..92d1bb580 100644--- a/htroot/Settings_p.java+++ b/htroot/Settings_p.java@@ -68,10 +68,7 @@ public final class Settings_p {String page = (post == null) ? "general" : post.get("page", "general");- if (page.equals("general")) {- prop.put("settingsTables", "Settings_General.inc");- }- else if (page.equals("ProxyAccess")) {+ if (page.equals("ProxyAccess")) {prop.put("settingsTables", "Settings_ProxyAccess.inc");}else if (page.equals("http")) {@@ -100,9 +97,8 @@ public final class Settings_p {}else if (page.equals("crawler")) {prop.put("settingsTables", "Settings_Crawler.inc");- }- else {- prop.put("settingsTables", "Settings_General.inc");+ } else {+ prop.put("settingsTables", "");}prop.put("port", env.getConfig("port", "8080"));diff --git a/htroot/index.java b/htroot/index.javaindex 831906e3b..a75451960 100644--- a/htroot/index.java+++ b/htroot/index.java@@ -93,10 +93,11 @@ public class index {if (cds.equals("image")) contentdom = plasmaSearchQuery.CONTENTDOM_IMAGE;if (cds.equals("app")) contentdom = plasmaSearchQuery.CONTENTDOM_APP;+ long mylinks = 0;try {- prop.put("links", groupDigits(Long.parseLong(yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "0"))));+ prop.put("links", groupDigits(mylinks = Long.parseLong(yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "0"))));} catch (NumberFormatException e) { prop.put("links", "0"); }- prop.put("total-links", groupDigits(yacyCore.seedDB.countActiveURL()));+ prop.put("total-links", groupDigits(mylinks + yacyCore.seedDB.countActiveURL()));// we create empty entries for template stringsString promoteSearchPageGreeting = env.getConfig("promoteSearchPageGreeting", "");diff --git a/source/de/anomic/data/Diff.java b/source/de/anomic/data/Diff.javaindex c37f81ee8..67d44a7c4 100644--- a/source/de/anomic/data/Diff.java+++ b/source/de/anomic/data/Diff.java@@ -55,8 +55,8 @@ import java.util.ArrayList;public class Diff {private final ArrayList /* of Part */ parts = new ArrayList();- private final String o;- private final String n;+ private final Object[] o;+ private final Object[] n;/*** @param o the original <code>String</code>@@ -64,10 +64,7 @@ public class Diff {* @throws NullPointerException if one of the arguments is <code>null</code>*/public Diff(String o, String n) {- if (o == null || n == null) throw new NullPointerException("neither o nor n must be null");- this.o = o;- this.n = n;- parse(1);+ this(o, n, 1);}/**@@ -80,6 +77,17 @@ public class Diff {* <code>null</code>*/public Diff(String o, String n, int minConsecutive) {+ if (o == null || n == null) throw new NullPointerException("neither o nor n must be null");+ this.o = new Comparable[o.length()];+ for (int i=0; i<o.length(); i++)+ this.o[i] = new Character(o.charAt(i));+ this.n = new Comparable[n.length()];+ for (int i=0; i<n.length(); i++)+ this.n[i] = new Character(n.charAt(i));+ parse((minConsecutive > 0) ? minConsecutive : 1);+ }++ public Diff(Object[] o, Object[] n, int minConsecutive) {if (o == null || n == null) throw new NullPointerException("neither o nor n must be null");this.o = o;this.n = n;@@ -108,22 +116,21 @@ public class Diff {* E| | |#| | | | | | | | |#| | |#| | |#|* N| | | | | | | | | | | | |#| | |#| | |* C| | | | | | | | | | | | | | | | |#| |- * E| | |#| | | | | | | | | |#| | |#| |#|+ * E| | |#| | | | | | | | |#| | |#| | |#|*/- boolean[][] matrix = new boolean[this.n.length()][this.o.length()];- for (int y=0; y<this.n.length(); y++)- for (int x=0; x<this.o.length(); x++)- matrix[y][x] = this.o.charAt(x) == this.n.charAt(y);+ boolean[][] matrix = new boolean[this.n.length][this.o.length];+ for (int y=0; y<this.n.length; y++)+ for (int x=0; x<this.o.length; x++)+ matrix[y][x] = this.o[x].equals(this.n[y]);int s = 0, t = 0;- int[] tmp = findDiagonal(s, t, matrix, minLength);- while (tmp != null) {+ int[] tmp;+ while ((tmp = findDiagonal(s, t, matrix, minLength)) != null) {addReplacementParts(s, t, tmp[0], tmp[1]);this.parts.add(new Part(Part.UNCHANGED, tmp[0], s = tmp[0] + tmp[2]));t = tmp[1] + tmp[2];- tmp = findDiagonal(s, t, matrix, minLength);}- addReplacementParts(s, t, this.o.length(), this.n.length());+ addReplacementParts(s, t, this.o.length, this.n.length);}private void addReplacementParts(int startx, int starty, int endx, int endy) {@@ -154,8 +161,10 @@ public class Diff {for (yy=y; yy<matrix.length; yy++)for (xx=x; xx<matrix[yy].length; xx++)if (matrix[yy][xx]) { // reverse order! [y][x]+ // save positionrx = xx;ry = yy;+ // follow diagonal as long as far as possiblefor (i=1; (yy + i)<matrix.length && (xx + i)<matrix[yy].length; i++)if (!matrix[yy + i][xx + i])break;@@ -166,14 +175,14 @@ public class Diff {}/**- * @return the original <code>String</code> passed to this class on instantiation+ * @return the original <code>Object[]</code> passed to this class on instantiation*/- public String getOriginal() { return this.o; }+ public Object[] getOriginal() { return this.o; }/**- * @return the new <code>String</code> passed to this class on instantiation+ * @return the new <code>Object[]</code> passed to this class on instantiation*/- public String getNew() { return this.n; }+ public Object[] getNew() { return this.n; }/*** A diff is composed of different parts. Each of these parts stands for an@@ -225,7 +234,15 @@ public class Diff {* @return the plain string this diff-part cares about*/public String getString() {- return ((this.action == ADDED) ? Diff.this.n : Diff.this.o).substring(this.posOld, this.posNew);+ final StringBuffer sb = new StringBuffer(this.posNew - this.posOld);+ if (this.action == ADDED) {+ for (int i=this.posOld; i<this.posNew; i++)+ sb.append(Diff.this.n[i]);+ } else {+ for (int i=this.posOld; i<this.posNew; i++)+ sb.append(Diff.this.o[i]);+ }+ return new String(sb);}/**