Skip to content

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

- fixes for missing or bad hashCode computation - fixes for bad equals() methods that had not been used by hash maps and therefore some classes did not work as objects in hash maps. - this may also affect some cases where double-checks should have been, but did not work.

orbiter4df88a4e7a5d
diff --git a/source/de/anomic/http/client/ConnectionInfo.java b/source/de/anomic/http/client/ConnectionInfo.java
index 1d31a7c63..9080f5068 100644
--- a/source/de/anomic/http/client/ConnectionInfo.java
+++ b/source/de/anomic/http/client/ConnectionInfo.java
@@ -211,19 +211,10 @@ public class ConnectionInfo {
*/
@Override
public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
final ConnectionInfo other = (ConnectionInfo) obj;
- if (id != other.id) {
- return false;
- }
- return true;
+ return this.id == other.id;
}
}
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.java
index a0acd129b..166db7030 100644
--- a/source/de/anomic/http/server/HTTPDemon.java
+++ b/source/de/anomic/http/server/HTTPDemon.java
@@ -1267,7 +1267,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
headers.put(HeaderFramework.SERVER, "AnomicHTTPD (www.anomic.de)");
headers.put(HeaderFramework.DATE, DateFormatter.formatRFC1123(now));
if (moddate.after(now)) {
- System.out.println("*** DEBUG: correcting moddate = " + moddate.toString() + " to now = " + now.toString());
+ //System.out.println("*** DEBUG: correcting moddate = " + moddate.toString() + " to now = " + now.toString());
moddate = now;
}
headers.put(HeaderFramework.LAST_MODIFIED, DateFormatter.formatRFC1123(moddate));
diff --git a/source/de/anomic/search/MediaSnippet.java b/source/de/anomic/search/MediaSnippet.java
index 82c1ab00e..c74df64a5 100644
--- a/source/de/anomic/search/MediaSnippet.java
+++ b/source/de/anomic/search/MediaSnippet.java
@@ -57,10 +57,18 @@ public class MediaSnippet implements Comparable<MediaSnippet>, Comparator<MediaS
@Override
public int hashCode() {
- return href.hashCode();
+ return href.hash().hashCode();
}
- public boolean equals(MediaSnippet other) {
+ public String toString() {
+ return href.hash();
+ }
+
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof MediaSnippet)) return false;
+ MediaSnippet other = (MediaSnippet) obj;
return this.href.hash().equals(other.href.hash());
}
diff --git a/source/de/anomic/search/ResultEntry.java b/source/de/anomic/search/ResultEntry.java
index c32259216..ebc59e522 100644
--- a/source/de/anomic/search/ResultEntry.java
+++ b/source/de/anomic/search/ResultEntry.java
@@ -103,7 +103,11 @@ public class ResultEntry implements Comparable<ResultEntry>, Comparator<ResultEn
public int hashCode() {
return urlentry.hash().hashCode();
}
- public boolean equals(ResultEntry other) {
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof ResultEntry)) return false;
+ ResultEntry other = (ResultEntry) obj;
return urlentry.hash().equals(other.urlentry.hash());
}
public String hash() {
diff --git a/source/de/anomic/search/ResultFetcher.java b/source/de/anomic/search/ResultFetcher.java
index 93f867790..56d2f4fd8 100644
--- a/source/de/anomic/search/ResultFetcher.java
+++ b/source/de/anomic/search/ResultFetcher.java
@@ -339,9 +339,8 @@ public class ResultFetcher {
if (imagemedia != null) {
for (int j = 0; j < imagemedia.size(); j++) {
ms = imagemedia.get(j);
- int b = images.size();
images.push(ms, Long.valueOf(ms.ranking));
- System.out.println("*** image " + ms.href.hash() + " images.size = " + b + "/" + images.size());
+ //System.out.println("*** image " + ms.href.hash() + " images.size = " + images.size() + "/" + images.size());
}
}
}
diff --git a/source/de/anomic/search/TextSnippet.java b/source/de/anomic/search/TextSnippet.java
index 436bc39ae..01ce68b0e 100644
--- a/source/de/anomic/search/TextSnippet.java
+++ b/source/de/anomic/search/TextSnippet.java
@@ -27,6 +27,7 @@ package de.anomic.search;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
@@ -54,7 +55,7 @@ import de.anomic.http.client.Cache;
import de.anomic.http.server.ResponseHeader;
import de.anomic.yacy.yacySearch;
-public class TextSnippet {
+public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnippet> {
private static final int maxCache = 1000;
@@ -168,6 +169,16 @@ public class TextSnippet {
public boolean exists() {
return line != null;
}
+ public int compareTo(TextSnippet o) {
+ return Base64Order.enhancedCoder.compare(this.url.hash().getBytes(), o.url.hash().getBytes());
+ }
+ public int compare(TextSnippet o1, TextSnippet o2) {
+ return o1.compareTo(o2);
+ }
+ public int hashCode() {
+ return this.url.hash().hashCode();
+ }
+
@Override
public String toString() {
return (line == null) ? "" : line;
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 9fea2dd09..a5221f6d3 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -407,7 +407,7 @@ public final class yacyClient {
if (feed == null) {
// case where the rss reader does not understand the content
yacyCore.log.logWarning("yacyClient.queryRemoteCrawlURLs failed asking peer '" + target.getName() + "': probably bad response from remote peer (2)");
- System.out.println("***DEBUG*** rss input = " + new String(result));
+ //System.out.println("***DEBUG*** rss input = " + new String(result));
target.put(yacySeed.RCOUNT, "0");
seedDB.update(target.hash, target); // overwrite number of remote-available number to avoid that this peer is called again (until update is done by peer ping)
//Log.logException(e);
diff --git a/source/net/yacy/document/geolocalization/Coordinates.java b/source/net/yacy/document/geolocalization/Coordinates.java
index d6fce283b..86a45e9e0 100644
--- a/source/net/yacy/document/geolocalization/Coordinates.java
+++ b/source/net/yacy/document/geolocalization/Coordinates.java
@@ -85,7 +85,7 @@ public class Coordinates implements Comparable<Coordinates>, Comparator<Coordina
/**
* equality test that is needed to use the class inside HashMap/HashSet
*/
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (!(o instanceof Coordinates)) return false;
Coordinates oo = (Coordinates) o;
if (this.lon == oo.lon && this.lat == oo.lat) return true;
diff --git a/source/net/yacy/document/importer/OAIPMHImporter.java b/source/net/yacy/document/importer/OAIPMHImporter.java
index fa50db6dc..d247679b5 100644
--- a/source/net/yacy/document/importer/OAIPMHImporter.java
+++ b/source/net/yacy/document/importer/OAIPMHImporter.java
@@ -164,8 +164,12 @@ public class OAIPMHImporter extends Thread implements Importer, Comparable<OAIPM
return this.serialNumber;
}
- public boolean equals(OAIPMHImporter o) {
- return this.compareTo(o) == 0;
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof OAIPMHImporter)) return false;
+ OAIPMHImporter other = (OAIPMHImporter) obj;
+ return this.compareTo(other) == 0;
}
// methods that are needed to put the object into a Tree:
diff --git a/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java b/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java
index eace808dc..1365fe849 100644
--- a/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java
+++ b/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java
@@ -181,7 +181,11 @@ public final class CitationReferenceRow implements Reference /*, Cloneable*/ {
return this.metadataHash().hashCode();
}
- public boolean equals(Reference other) {
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof CitationReferenceRow)) return false;
+ CitationReferenceRow other = (CitationReferenceRow) obj;
return this.metadataHash().equals(other.metadataHash());
}
diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.java
index ab721faff..fa778d05a 100644
--- a/source/net/yacy/kelondro/data/meta/DigestURI.java
+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java
@@ -673,65 +673,19 @@ public class DigestURI implements Serializable {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((host == null) ? 0 : host.hashCode());
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- result = prime * result + port;
- result = prime * result
- + ((protocol == null) ? 0 : protocol.hashCode());
- result = prime * result + ((quest == null) ? 0 : quest.hashCode());
- result = prime * result + ((ref == null) ? 0 : ref.hashCode());
- result = prime * result
- + ((userInfo == null) ? 0 : userInfo.hashCode());
- return result;
+ return this.hash().hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof DigestURI))
- return false;
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof DigestURI)) return false;
DigestURI other = (DigestURI) obj;
- if (host == null) {
- if (other.host != null)
- return false;
- } else if (!host.equals(other.host))
- return false;
- if (path == null) {
- if (other.path != null)
- return false;
- } else if (!path.equals(other.path))
- return false;
- if (port != other.port)
- return false;
- if (protocol == null) {
- if (other.protocol != null)
- return false;
- } else if (!protocol.equals(other.protocol))
- return false;
- if (quest == null) {
- if (other.quest != null)
- return false;
- } else if (!quest.equals(other.quest))
- return false;
- if (ref == null) {
- if (other.ref != null)
- return false;
- } else if (!ref.equals(other.ref))
- return false;
- if (userInfo == null) {
- if (other.userInfo != null)
- return false;
- } else if (!userInfo.equals(other.userInfo))
- return false;
- return true;
+ return this.toString().equals(other.toString());
}
public int compareTo(final Object h) {
diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java b/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java
index 79d938237..f0b03ddb2 100644
--- a/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java
+++ b/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java
@@ -147,8 +147,12 @@ public final class NavigationReferenceRow extends AbstractReference implements N
return this.navigationHash().hashCode();
}
- public boolean equals(Reference other) {
- return this.metadataHash().equals(other.metadataHash());
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof NavigationReferenceRow)) return false;
+ NavigationReferenceRow other = (NavigationReferenceRow) obj;
+ return this.navigationHash().equals(other.navigationHash());
}
public boolean isOlder(Reference other) {
diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java b/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java
index 16aac27d7..41ebc9498 100644
--- a/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java
+++ b/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java
@@ -119,8 +119,12 @@ public class NavigationReferenceVars extends AbstractReference implements Navig
return this.navigationHash().hashCode();
}
- public boolean equals(Reference other) {
- return this.metadataHash().equals(other.metadataHash());
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof NavigationReferenceVars)) return false;
+ NavigationReferenceVars other = (NavigationReferenceVars) obj;
+ return this.navigationHash().equals(other.navigationHash());
}
public boolean isOlder(Reference other) {
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceRow.java b/source/net/yacy/kelondro/data/word/WordReferenceRow.java
index aea2b13f5..9e14eea62 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceRow.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceRow.java
@@ -323,7 +323,11 @@ public final class WordReferenceRow extends AbstractReference implements WordRef
return false;
}
- public boolean equals(Reference other) {
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof WordReferenceRow)) return false;
+ WordReferenceRow other = (WordReferenceRow) obj;
return this.metadataHash().equals(other.metadataHash());
}
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceVars.java b/source/net/yacy/kelondro/data/word/WordReferenceVars.java
index 3063776e7..ead58f66f 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceVars.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceVars.java
@@ -358,8 +358,12 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
this.wordsintext = this.wordsintext + oe.wordsintext();
}
- public boolean equals(Reference other) {
- return this.urlHash.equals(other.metadataHash());
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof WordReferenceVars)) return false;
+ WordReferenceVars other = (WordReferenceVars) obj;
+ return this.urlHash.equals(other.urlHash);
}
public int hashCode() {
diff --git a/source/net/yacy/kelondro/index/Column.java b/source/net/yacy/kelondro/index/Column.java
index 3b7672e5d..61e23780b 100644
--- a/source/net/yacy/kelondro/index/Column.java
+++ b/source/net/yacy/kelondro/index/Column.java
@@ -260,34 +260,18 @@ public final class Column {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public final boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Column))
- return false;
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Column)) return false;
Column other = (Column) obj;
- if (celltype != other.celltype)
- return false;
- if (cellwidth != other.cellwidth)
- return false;
- if (encoder != other.encoder)
- return false;
+ if (celltype != other.celltype) return false;
+ if (cellwidth != other.cellwidth) return false;
+ if (encoder != other.encoder) return false;
if (nickname == null) {
- if (other.nickname != null)
- return false;
- } else if (!nickname.equals(other.nickname))
- return false;
+ if (other.nickname != null) return false;
+ } else if (!nickname.equals(other.nickname)) return false;
return true;
}
-// public boolean equals(final kelondroColumn otherCol) {
-// return
-// (this.celltype == otherCol.celltype) &&
-// (this.cellwidth == otherCol.cellwidth) &&
-// (this.encoder == otherCol.encoder) &&
-// (this.nickname.equals(otherCol.nickname));
-// }
-
}
diff --git a/source/net/yacy/kelondro/index/Row.java b/source/net/yacy/kelondro/index/Row.java
index 0deadb196..29e09aae2 100644
--- a/source/net/yacy/kelondro/index/Row.java
+++ b/source/net/yacy/kelondro/index/Row.java
@@ -335,17 +335,31 @@ public final class Row {
public int compare(Entry o1, Entry o2) {
return o1.compareTo(o2);
}
-
- public final boolean equals(final Entry otherEntry) {
- // compares the content of the complete entry
+
+ // compare the content of the primary key
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Entry)) return false;
+ Entry other = (Entry) obj;
final byte[] t = this.bytes();
- final byte[] o = otherEntry.bytes();
+ final byte[] o = other.bytes();
for (int i = 0; i < primaryKeyLength; i++) {
if (t[i] != o[i]) return false;
}
return true;
}
+ public int hashCode() {
+ byte[] b = this.getPrimaryKeyBytes();
+ int len = b.length;
+ int h = 1;
+ for (int i = 0; i < len; i++) {
+ h = 31 * h + b[i];
+ }
+ return h;
+ }
+
public final byte[] bytes() {
if ((offset == 0) && (rowinstance.length == objectsize)) {
return rowinstance;
@@ -716,13 +730,21 @@ public final class Row {
return true;
}
- public final boolean equals(final Row otherRow) {
- if (this.objectsize != otherRow.objectsize) return false;
- if (this.columns() != otherRow.columns()) return false;
- for (int i = 0; i < otherRow.row.length; i++) {
- if (!(this.row[i].equals(otherRow.row[i]))) return false;
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Row)) return false;
+ Row other = (Row) obj;
+ if (this.objectsize != other.objectsize) return false;
+ if (this.columns() != other.columns()) return false;
+ for (int i = 0; i < other.row.length; i++) {
+ if (!(this.row[i].equals(other.row[i]))) return false;
}
return true;
}
+ public int hashCode() {
+ return this.toString().hashCode();
+ }
+
}
diff --git a/source/net/yacy/kelondro/order/AbstractOrder.java b/source/net/yacy/kelondro/order/AbstractOrder.java
index b3cc9a254..3e4134fe6 100644
--- a/source/net/yacy/kelondro/order/AbstractOrder.java
+++ b/source/net/yacy/kelondro/order/AbstractOrder.java
@@ -26,8 +26,6 @@
package net.yacy.kelondro.order;
-
-
public abstract class AbstractOrder<A> implements Order<A> {
protected A zero = null;
@@ -53,11 +51,19 @@ public abstract class AbstractOrder<A> implements Order<A> {
this.zero = newzero;
}
- public boolean equals(final Order<A> otherOrder) {
- if (otherOrder == null) return false;
+ @SuppressWarnings("unchecked")
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Order<?>)) return false;
+ Order<A> other = (Order<A>) obj;
final String thisSig = this.signature();
- final String otherSig = otherOrder.signature();
+ final String otherSig = other.signature();
if ((thisSig == null) || (otherSig == null)) return false;
return thisSig.equals(otherSig);
}
+
+ public int hashCode() {
+ return this.signature().hashCode();
+ }
}
diff --git a/source/net/yacy/kelondro/order/Bitfield.java b/source/net/yacy/kelondro/order/Bitfield.java
index 23458eb01..345f8b66d 100644
--- a/source/net/yacy/kelondro/order/Bitfield.java
+++ b/source/net/yacy/kelondro/order/Bitfield.java
@@ -106,12 +106,20 @@ public class Bitfield implements Cloneable {
return new String(sb);
}
- public boolean equals(final Bitfield x) {
- if (x.bb.length != bb.length) return false;
- for (int i = 0; i < bb.length; i++) if (bb[i] != x.bb[i]) return false;
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Bitfield)) return false;
+ Bitfield other = (Bitfield) obj;
+ if (other.bb.length != this.bb.length) return false;
+ for (int i = 0; i < this.bb.length; i++) if (this.bb[i] != other.bb[i]) return false;
return true;
}
+ public int hashCode() {
+ return this.toString().hashCode();
+ }
+
public void and(final Bitfield x) {
final int c = Math.min(x.length(), this.length());
for (int i = 0; i < c; i++) set(i, this.get(i) && x.get(i));
diff --git a/source/net/yacy/kelondro/order/Order.java b/source/net/yacy/kelondro/order/Order.java
index fb08fbb2d..b3fdad7a0 100644
--- a/source/net/yacy/kelondro/order/Order.java
+++ b/source/net/yacy/kelondro/order/Order.java
@@ -50,6 +50,7 @@ public interface Order<A> extends Comparator<A> {
public void rotate(A zero); // defines that the ordering rotates, and sets the zero point for the rotation
- public boolean equals(Order<A> o); // used to compare different order objects; they may define the same ordering
+ public boolean equals(Object o); // used to compare different order objects; they may define the same ordering
+ public int hashCode();
}
diff --git a/source/net/yacy/kelondro/rwi/Reference.java b/source/net/yacy/kelondro/rwi/Reference.java
index d9b5342c0..eeaace717 100644
--- a/source/net/yacy/kelondro/rwi/Reference.java
+++ b/source/net/yacy/kelondro/rwi/Reference.java
@@ -44,8 +44,8 @@ public interface Reference {
public int hashCode();
- public boolean equals(Reference other);
-
+ public boolean equals(Object other);
+
public void join(final Reference oe);
public int positions();
diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerOrder.java b/source/net/yacy/kelondro/rwi/ReferenceContainerOrder.java
index 06c0640d8..4bdb9540c 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceContainerOrder.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceContainerOrder.java
@@ -76,9 +76,13 @@ public class ReferenceContainerOrder<ReferenceType extends Reference> extends Ab
return this.embeddedOrder.cardinal(key);
}
- public boolean equals(final Order<ReferenceContainer<ReferenceType>> otherOrder) {
- if (!(otherOrder instanceof ReferenceContainerOrder)) return false;
- return this.embeddedOrder.equals(((ReferenceContainerOrder<ReferenceType>) otherOrder).embeddedOrder);
+ @SuppressWarnings("unchecked")
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof ReferenceContainerOrder<?>)) return false;
+ ReferenceContainerOrder<ReferenceType> other = (ReferenceContainerOrder<ReferenceType>) obj;
+ return this.embeddedOrder.equals(other.embeddedOrder);
}
public long cardinal(final ReferenceContainer<ReferenceType> key) {
diff --git a/source/net/yacy/kelondro/table/Records.java b/source/net/yacy/kelondro/table/Records.java
index 3052dca34..0508225ff 100644
--- a/source/net/yacy/kelondro/table/Records.java
+++ b/source/net/yacy/kelondro/table/Records.java
@@ -1244,17 +1244,13 @@ public class Records {
while (s.length() < 4) s = "0" + s;
return s;
}
-
- public boolean equals(final Handle h) {
- assert (index != NUL);
- assert (h.index != NUL);
- return (this.index == h.index);
- }
-
- public boolean equals(final Object h) {
- assert (index != NUL);
- assert (h instanceof Handle && ((Handle) h).index != NUL);
- return (h instanceof Handle && this.index == ((Handle) h).index);
+
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Handle)) return false;
+ Handle other = (Handle) obj;
+ return this.index == other.index;
}
public int compare(final Handle h0, final Handle h1) {
diff --git a/source/net/yacy/kelondro/util/SortStack.java b/source/net/yacy/kelondro/util/SortStack.java
index cb4af740f..f06397829 100644
--- a/source/net/yacy/kelondro/util/SortStack.java
+++ b/source/net/yacy/kelondro/util/SortStack.java
@@ -33,7 +33,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-public class SortStack<E extends Comparable<E>> {
+public class SortStack<E> {
// implements a stack where elements 'float' on-top of the stack according to a weight value.
// objects pushed on the stack must implement the hashCode() method to provide a handle
@@ -147,5 +147,8 @@ public class SortStack<E extends Comparable<E>> {
this.element = element;
this.weight = weight;
}
+ public String toString() {
+ return element.toString() + "/" + weight;
+ }
}
}
diff --git a/source/net/yacy/kelondro/util/SortStore.java b/source/net/yacy/kelondro/util/SortStore.java
index ccb74d953..428163c4a 100644
--- a/source/net/yacy/kelondro/util/SortStore.java
+++ b/source/net/yacy/kelondro/util/SortStore.java
@@ -36,7 +36,7 @@ import java.util.Iterator;
* specific elements in the list.
* @param <E>
*/
-public class SortStore<E extends Comparable<E>> extends SortStack<E> {
+public class SortStore<E> extends SortStack<E> {
private final ArrayList<stackElement> offstack; // objects that had been on the stack but had been removed
private HashSet<E> offset; // keeps track which element has been on the stack or is now in the offstack
diff --git a/source/org/apache/tools/tar/TarEntry.java b/source/org/apache/tools/tar/TarEntry.java
index 39c2343a1..2a6c8ecec 100644
--- a/source/org/apache/tools/tar/TarEntry.java
+++ b/source/org/apache/tools/tar/TarEntry.java
@@ -31,6 +31,7 @@ import java.io.File;
import java.util.Date;
import java.util.Locale;
+
/**
* This class represents an entry in a Tar archive. It consists
* of the entry's header, as well as the entry's File. Entries
@@ -273,18 +274,7 @@ public class TarEntry implements TarConstants {
this();
this.parseTarHeader(headerBuf);
}
-
- /**
- * Determine if the two entries are equal. Equality is determined
- * by the header names being equal.
- *
- * @param it Entry to be checked for equality.
- * @return True if the entries are equal.
- */
- public boolean equals(TarEntry it) {
- return this.getName().equals(it.getName());
- }
-
+
/**
* Determine if the two entries are equal. Equality is determined
* by the header names being equal.
@@ -292,11 +282,12 @@ public class TarEntry implements TarConstants {
* @param it Entry to be checked for equality.
* @return True if the entries are equal.
*/
- public boolean equals(Object it) {
- if (it == null || getClass() != it.getClass()) {
- return false;
- }
- return equals((TarEntry) it);
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof TarEntry)) return false;
+ TarEntry other = (TarEntry) obj;
+ return this.getName().equals(other.getName());
}
/**