Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added missing serialization to remove all warnings
Michael Peter Christen15db70380888
diff --git a/source/net/yacy/kelondro/data/citation/CitationReference.java b/source/net/yacy/kelondro/data/citation/CitationReference.javaindex ce1fb73ce..38e3612e1 100644--- a/source/net/yacy/kelondro/data/citation/CitationReference.java+++ b/source/net/yacy/kelondro/data/citation/CitationReference.java@@ -20,6 +20,7 @@package net.yacy.kelondro.data.citation;+import java.io.Serializable;import java.util.Collection;import net.yacy.cora.document.ASCII;@@ -33,10 +34,12 @@ import net.yacy.kelondro.order.MicroDate;import net.yacy.kelondro.rwi.Reference;import net.yacy.kelondro.util.ByteArray;-public class CitationReference implements Reference /*, Cloneable*/ {+public class CitationReference implements Reference, Serializable {// this object stores citation attributes to URL references+ private static final long serialVersionUID=1920200210928897131L;+public static final Row citationRow = new Row(new Column[]{new Column("h", Column.celltype_string, Column.encoder_bytes, Word.commonHashLength, "urlhash"),new Column("m", Column.celltype_cardinal, Column.encoder_b256, 2, "lastModified"),diff --git a/source/net/yacy/kelondro/data/citation/CitationReferenceFactory.java b/source/net/yacy/kelondro/data/citation/CitationReferenceFactory.javaindex 4fe251ac6..c827a64a8 100644--- a/source/net/yacy/kelondro/data/citation/CitationReferenceFactory.java+++ b/source/net/yacy/kelondro/data/citation/CitationReferenceFactory.java@@ -20,11 +20,15 @@package net.yacy.kelondro.data.citation;+import java.io.Serializable;+import net.yacy.kelondro.index.Row;import net.yacy.kelondro.index.Row.Entry;import net.yacy.kelondro.rwi.ReferenceFactory;-public class CitationReferenceFactory implements ReferenceFactory<CitationReference> {+public class CitationReferenceFactory implements ReferenceFactory<CitationReference>, Serializable {++ private static final long serialVersionUID=-1098504892965986149L;@Overridepublic CitationReference produceSlow(final Entry e) {diff --git a/source/net/yacy/kelondro/data/image/ImageReferenceFactory.java b/source/net/yacy/kelondro/data/image/ImageReferenceFactory.javaindex 7564f7c67..692912900 100644--- a/source/net/yacy/kelondro/data/image/ImageReferenceFactory.java+++ b/source/net/yacy/kelondro/data/image/ImageReferenceFactory.java@@ -9,7 +9,7 @@// $LastChangedBy$//// 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@@ -26,21 +26,28 @@package net.yacy.kelondro.data.image;+import java.io.Serializable;+import net.yacy.kelondro.index.Row;import net.yacy.kelondro.index.Row.Entry;import net.yacy.kelondro.rwi.ReferenceFactory;-public class ImageReferenceFactory implements ReferenceFactory<ImageReference> {+public class ImageReferenceFactory implements ReferenceFactory<ImageReference>, Serializable {+ private static final long serialVersionUID=-2209473508756878863L;++ @Overridepublic ImageReference produceSlow(Entry e) {return null; //new ImageReferenceRow(e);}-++ @Overridepublic ImageReference produceFast(ImageReference r) {if (r instanceof ImageReferenceVars) return r;return new ImageReferenceVars(r);}+ @Overridepublic Row getRow() {return ImageReferenceRow.urlEntryRow;}diff --git a/source/net/yacy/kelondro/data/image/ImageReferenceVars.java b/source/net/yacy/kelondro/data/image/ImageReferenceVars.javaindex 5a75be5a8..e4415f155 100644--- a/source/net/yacy/kelondro/data/image/ImageReferenceVars.java+++ b/source/net/yacy/kelondro/data/image/ImageReferenceVars.java@@ -26,6 +26,7 @@package net.yacy.kelondro.data.image;+import java.io.Serializable;import java.util.Collection;import java.util.Queue;import java.util.concurrent.LinkedBlockingQueue;@@ -38,9 +39,12 @@ import net.yacy.kelondro.rwi.Reference;import net.yacy.kelondro.util.ByteArray;-public class ImageReferenceVars extends AbstractReference implements ImageReference, Reference, Cloneable {+public class ImageReferenceVars extends AbstractReference implements ImageReference, Reference, Cloneable, Serializable {- /**+ private static final long serialVersionUID=3669156620967277347L;+++ /*** object for termination of concurrent blocking queue processing*/public static final ImageReferenceVars poison = new ImageReferenceVars();diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReferenceFactory.java b/source/net/yacy/kelondro/data/navigation/NavigationReferenceFactory.javaindex 8359dfb1e..e0d3547d2 100644--- a/source/net/yacy/kelondro/data/navigation/NavigationReferenceFactory.java+++ b/source/net/yacy/kelondro/data/navigation/NavigationReferenceFactory.java@@ -9,7 +9,7 @@// $LastChangedBy$//// 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@@ -26,21 +26,28 @@package net.yacy.kelondro.data.navigation;+import java.io.Serializable;+import net.yacy.kelondro.index.Row;import net.yacy.kelondro.index.Row.Entry;import net.yacy.kelondro.rwi.ReferenceFactory;-public class NavigationReferenceFactory implements ReferenceFactory<NavigationReference> {+public class NavigationReferenceFactory implements ReferenceFactory<NavigationReference>, Serializable {++ private static final long serialVersionUID=-3440570952034279619L;+ @Overridepublic NavigationReference produceSlow(final Entry e) {return new NavigationReferenceRow(e);}-++ @Overridepublic NavigationReference produceFast(final NavigationReference r) {if (r instanceof NavigationReferenceVars) return r;return new NavigationReferenceVars(r);}-++ @Overridepublic Row getRow() {return NavigationReferenceRow.navEntryRow;}diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java b/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.javaindex d9137db3b..2c90cf8fb 100644--- a/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java+++ b/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java@@ -9,7 +9,7 @@// $LastChangedBy$//// 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@@ -26,6 +26,7 @@package net.yacy.kelondro.data.navigation;+import java.io.Serializable;import java.util.Collection;import net.yacy.cora.document.ASCII;@@ -33,12 +34,14 @@ import net.yacy.kelondro.index.Row.Entry;import net.yacy.kelondro.rwi.AbstractReference;import net.yacy.kelondro.rwi.Reference;-public class NavigationReferenceVars extends AbstractReference implements NavigationReference, Reference, Cloneable {+public class NavigationReferenceVars extends AbstractReference implements NavigationReference, Reference, Cloneable, Serializable {++ private static final long serialVersionUID=2873544331190937594L;public byte[] termhash, refhash;public int hitcount, position;byte flags;-+public NavigationReferenceVars(final byte[] termhash,final byte[] refhash,@@ -52,7 +55,7 @@ public class NavigationReferenceVars extends AbstractReference implements Navigthis.position = pos;this.flags = flags;}-+public NavigationReferenceVars(final NavigationReference e) {this.refhash = e.urlhash();this.termhash = e.termHash();@@ -60,7 +63,7 @@ public class NavigationReferenceVars extends AbstractReference implements Navigthis.position = e.position(0);this.flags = e.flags();}-+@Overridepublic NavigationReferenceVars clone() {final NavigationReferenceVars c = new NavigationReferenceVars(@@ -72,7 +75,7 @@ public class NavigationReferenceVars extends AbstractReference implements Navig);return c;}-+public NavigationReferenceRow toRowEntry() {return new NavigationReferenceRow(this.termhash,@@ -81,50 +84,58 @@ public class NavigationReferenceVars extends AbstractReference implements Navigthis.position,this.flags);}-++ @Overridepublic String toPropertyForm() {return toRowEntry().toPropertyForm();}+ @Overridepublic Entry toKelondroEntry() {return toRowEntry().toKelondroEntry();}+ @Overridepublic String navigationHash() {return ASCII.String(this.termhash) + ASCII.String(this.refhash);}-++ @Overridepublic byte[] urlhash() {return this.refhash;}+ @Overridepublic byte[] termHash() {return this.termhash;}-++ @Overridepublic int hitcount() {return this.hitcount;}+ @Overridepublic int position(final int p) {assert p == 0 : "p = " + p;return this.position;}-++ @Overridepublic byte flags() {return this.flags;}-+@Overridepublic String toString() {return toPropertyForm();}-+@Overridepublic int hashCode() {return this.navigationHash().hashCode();}-+@Overridepublic boolean equals(final Object obj) {if (this == obj) return true;@@ -133,24 +144,28 @@ public class NavigationReferenceVars extends AbstractReference implements NavigNavigationReferenceVars other = (NavigationReferenceVars) obj;return this.navigationHash().equals(other.navigationHash());}-++ @Overridepublic boolean isOlder(final Reference other) {return false;}-+// unsupported operations:+ @Overridepublic void join(final Reference oe) {throw new UnsupportedOperationException();}+ @Overridepublic long lastModified() {throw new UnsupportedOperationException();}+ @Overridepublic Collection<Integer> positions() {throw new UnsupportedOperationException();}-+}diff --git a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java b/source/net/yacy/kelondro/data/word/WordReferenceFactory.javaindex 908355daa..85d57e7d4 100644--- a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java+++ b/source/net/yacy/kelondro/data/word/WordReferenceFactory.java@@ -9,7 +9,7 @@// $LastChangedBy$//// 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@@ -26,6 +26,7 @@package net.yacy.kelondro.data.word;+import java.io.Serializable;import java.util.Collections;import java.util.Iterator;import java.util.Map;@@ -39,13 +40,15 @@ import net.yacy.kelondro.rwi.ReferenceContainer;import net.yacy.kelondro.rwi.ReferenceFactory;import net.yacy.kelondro.util.ByteBuffer;-public class WordReferenceFactory implements ReferenceFactory<WordReference> {+public class WordReferenceFactory implements ReferenceFactory<WordReference>, Serializable {++ private static final long serialVersionUID=-7168706947127349876L;@Overridepublic WordReference produceSlow(final Entry e) {return new WordReferenceRow(e);}-+@Overridepublic WordReference produceFast(final WordReference r) {if (r instanceof WordReferenceVars) return r;@@ -134,7 +137,7 @@ public class WordReferenceFactory implements ReferenceFactory<WordReference> {urlsb.append(dom);url = urlsb.toString();ci.trim(6);-+peers = target.get(url);if (peers == null) {peers = new StringBuilder(24);diff --git a/source/net/yacy/kelondro/index/Row.java b/source/net/yacy/kelondro/index/Row.javaindex 1b0def059..6f1e40cae 100644--- a/source/net/yacy/kelondro/index/Row.java+++ b/source/net/yacy/kelondro/index/Row.java@@ -237,7 +237,9 @@ public final class Row implements Serializable {}- public class Entry implements Comparable<Entry>, Comparator<Entry>, Cloneable {+ public class Entry implements Comparable<Entry>, Comparator<Entry>, Cloneable, Serializable {++ private static final long serialVersionUID=-2576312347345553495L;private byte[] rowinstance;private int offset; // the offset where the row starts within rowinstance@@ -634,7 +636,10 @@ public final class Row implements Serializable {}- public final class EntryIndex extends Entry {+ public final class EntryIndex extends Entry implements Serializable {++ private static final long serialVersionUID=153069052590699231L;+private final int index;public EntryIndex(final byte[] row, final int i) {super(row, false);diff --git a/source/net/yacy/kelondro/order/Bitfield.java b/source/net/yacy/kelondro/order/Bitfield.javaindex f338bd3c0..79e8ea29c 100644--- a/source/net/yacy/kelondro/order/Bitfield.java+++ b/source/net/yacy/kelondro/order/Bitfield.java@@ -7,7 +7,7 @@// $LastChangedBy$//// 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@@ -24,88 +24,91 @@package net.yacy.kelondro.order;+import java.io.Serializable;+-public class Bitfield implements Cloneable {+public class Bitfield implements Cloneable, Serializable {// the bitfield implements a binary array. Such arrays may be exported in a base64-String-- private byte[] bb;++ private static final long serialVersionUID=3605122793792478052L;+ private byte[] bb;public Bitfield() {this(0);}-+public Bitfield(final byte[] b) {if (b == null) this.bb = new byte[0]; else this.bb = b;}-+public Bitfield(final int bytelength) {this.bb= new byte[bytelength];- for (int i = 0 ; i < bytelength; i++) bb[i] = 0;+ for (int i = 0 ; i < bytelength; i++) this.bb[i] = 0;}public Bitfield(final int bytelength, final String exported) {// imports a b64-encoded bitfieldfinal byte[] b = Base64Order.enhancedCoder.decode(exported);if (b.length == bytelength) {- bb = b;+ this.bb = b;} else {- bb = new byte[bytelength];+ this.bb = new byte[bytelength];assert (b.length <= bytelength) : "exported = " + exported + " has bytelength = " + b.length + " > " + bytelength;- System.arraycopy(b, 0, bb, 0, Math.min(b.length, bytelength));+ System.arraycopy(b, 0, this.bb, 0, Math.min(b.length, bytelength));}}-+@Overridepublic Bitfield clone() {final Bitfield theClone = new Bitfield(new byte[this.bb.length]);System.arraycopy(this.bb, 0, theClone.bb, 0, this.bb.length);return theClone;}-+public void set(final int pos, final boolean value) {assert (pos >= 0);final int slot = pos >> 3; // /8- if (slot >= bb.length) {+ if (slot >= this.bb.length) {// extend capacitybyte[] nb = new byte[slot + 1];- System.arraycopy(bb, 0, nb, 0, bb.length);- for (int i = bb.length; i < nb.length; i++) nb[i] = 0;- bb = nb;+ System.arraycopy(this.bb, 0, nb, 0, this.bb.length);+ for (int i = this.bb.length; i < nb.length; i++) nb[i] = 0;+ this.bb = nb;}if (value) {- bb[slot] = (byte) (bb[slot] | (1 << (pos % 8)));+ this.bb[slot] = (byte) (this.bb[slot] | (1 << (pos % 8)));} else {- bb[slot] = (byte) (bb[slot] & (0xff ^ (1 << (pos % 8))));+ this.bb[slot] = (byte) (this.bb[slot] & (0xff ^ (1 << (pos % 8))));}}-+public boolean get(final int pos) {assert (pos >= 0);final int slot = pos >> 3; // /8- if (slot >= bb.length) return false;- return (bb[slot] & (1 << (pos % 8))) > 0;+ if (slot >= this.bb.length) return false;+ return (this.bb[slot] & (1 << (pos % 8))) > 0;}public int length() {- return bb.length << 3;+ return this.bb.length << 3;}-+public String exportB64() {- return Base64Order.enhancedCoder.encode(bb);+ return Base64Order.enhancedCoder.encode(this.bb);}-+public byte[] bytes() {- return bb;+ return this.bb;}-+@Overridepublic String toString() {final StringBuilder sb = new StringBuilder(length());for (int i = length() - 1; i >= 0; i--) sb.append((this.get(i)) ? '1' : '0');return sb.toString();}-+@Overridepublic boolean equals(final Object obj) {if (this == obj) return true;@@ -116,17 +119,17 @@ public class Bitfield implements Cloneable {for (int i = 0; i < this.bb.length; i++) if (this.bb[i] != other.bb[i]) return false;return true;}-+@Overridepublic 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));}-+public void or(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));@@ -134,7 +137,7 @@ public class Bitfield implements Cloneable {for (int i = c; i < x.length(); i++) set(i, x.get(i));}}-+public void xor(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));@@ -142,13 +145,13 @@ public class Bitfield implements Cloneable {for (int i = c; i < x.length(); i++) set(i, x.get(i));}}-+public boolean anyOf(final Bitfield x) {final int c = Math.min(x.length(), this.length());for (int i = 0; i < c; i++) if ((x.get(i)) && (this.get(i))) return true;return false;}-+public boolean allOf(final Bitfield x) {final int c = Math.min(x.length(), this.length());for (int i = 0; i < c; i++) if ((x.get(i)) && (!(this.get(i)))) return false;@@ -157,7 +160,7 @@ public class Bitfield implements Cloneable {}return true;}-+public static void main(final String[] args) {Bitfield test = new Bitfield(4);final int l = test.length();@@ -166,19 +169,19 @@ public class Bitfield implements Cloneable {for (int i = 0; i < l/2; i++) {System.out.println(test.exportB64());test.set(i, true);- System.out.println(i + ":" + test.toString());+ System.out.println(i + ":" + test.toString());}for (int i = l/2; i < l; i++) {System.out.println(test.exportB64());test = new Bitfield(4, test.exportB64());test.set(i, true);- System.out.println(i + ":" + test.toString());+ System.out.println(i + ":" + test.toString());}System.out.println(test.exportB64());for (int i = l - 1; i >= 0; i--) {test.set(i, false);- System.out.println(i + ":" + test.toString());+ System.out.println(i + ":" + test.toString());}- System.out.println("after: " + test.toString());+ System.out.println("after: " + test.toString());}}diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainer.java b/source/net/yacy/kelondro/rwi/ReferenceContainer.javaindex f799abb8f..5b5382501 100644--- a/source/net/yacy/kelondro/rwi/ReferenceContainer.java+++ b/source/net/yacy/kelondro/rwi/ReferenceContainer.java@@ -54,6 +54,8 @@ import net.yacy.kelondro.order.Base64Order;*/public class ReferenceContainer<ReferenceType extends Reference> extends RowSet {+ private static final long serialVersionUID=-540567425172727979L;+private byte[] termHash;protected ReferenceFactory<ReferenceType> factory;public static int maxReferences = 0; // overwrite this to enable automatic index shrinking. 0 means no shrinking@@ -255,16 +257,19 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSetthis.rowEntryIterator = iterator();}+ @Overridepublic boolean hasNext() {return this.rowEntryIterator.hasNext();}+ @Overridepublic ReferenceType next() {final Row.Entry rentry = this.rowEntryIterator.next();if (rentry == null) return null;return ReferenceContainer.this.factory.produceSlow(rentry);}+ @Overridepublic void remove() {this.rowEntryIterator.remove();}@@ -562,10 +567,12 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSetreturn pivot;}+ @Overridepublic synchronized String toString() {return "C[" + ASCII.String(this.termHash) + "] has " + size() + " entries";}+ @Overridepublic int hashCode() {return (int) Base64Order.enhancedCoder.decodeLong(this.termHash, 0, 4);}diff --git a/source/net/yacy/peers/graphics/WebStructureGraph.java b/source/net/yacy/peers/graphics/WebStructureGraph.javaindex 9530f9bd5..9b38ca136 100644--- a/source/net/yacy/peers/graphics/WebStructureGraph.java+++ b/source/net/yacy/peers/graphics/WebStructureGraph.java@@ -28,6 +28,7 @@package net.yacy.peers.graphics;import java.io.File;+import java.io.Serializable;import java.text.ParseException;import java.util.ArrayList;import java.util.Collection;@@ -342,8 +343,9 @@ public class WebStructureGraphhosthashes);}- public static class HostReferenceFactory implements ReferenceFactory<HostReference>- {+ public static class HostReferenceFactory implements ReferenceFactory<HostReference>, Serializable {++ private static final long serialVersionUID=7461135579006223155L;private static final Row hostReferenceRow = new Row("String h-6, Cardinal m-4 {b256}, Cardinal c-4 {b256}",@@ -369,8 +371,9 @@ public class WebStructureGraph}- public static class HostReference extends AbstractReference implements Reference- {+ public static class HostReference extends AbstractReference implements Reference, Serializable {++ private static final long serialVersionUID=-9170091435821206765L;private final Row.Entry entry;