diff --git a/.classpath b/.classpath index f12631ede..94731343b 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,11 @@ - - + + + diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java index 764354169..81674ee58 100644 --- a/source/de/anomic/http/httpd.java +++ b/source/de/anomic/http/httpd.java @@ -1036,7 +1036,7 @@ public final class httpd implements serverHandler { return true; } - public Object clone() { + public httpd clone() { return new httpd(switchboard); } diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.java index caaf03b24..915580d71 100644 --- a/source/de/anomic/icap/icapd.java +++ b/source/de/anomic/icap/icapd.java @@ -105,7 +105,7 @@ public class icapd implements serverHandler { } - public Object clone(){ + public icapd clone(){ return new icapd(); } diff --git a/source/de/anomic/index/indexRWIRowEntry.java b/source/de/anomic/index/indexRWIRowEntry.java index 476d6f2ea..a66eb180f 100644 --- a/source/de/anomic/index/indexRWIRowEntry.java +++ b/source/de/anomic/index/indexRWIRowEntry.java @@ -163,7 +163,7 @@ public final class indexRWIRowEntry implements indexRWIEntry { return (int) (time / 86400000); } - public Object clone() { + public indexRWIRowEntry clone() { byte[] b = new byte[urlEntryRow.objectsize]; System.arraycopy(entry.bytes(), 0, b, 0, urlEntryRow.objectsize); return new indexRWIRowEntry(b); diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.java index 956fc8ae4..69aa633f5 100644 --- a/source/de/anomic/kelondro/kelondroAbstractRecords.java +++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java @@ -720,7 +720,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords { // check handle seekp = seekpos(h); if (seekp > entryFile.length()) { - // repair last hande store position + // repair last handle store position this.theLogger.severe("KELONDRO WARNING " + this.filename + ": seek position " + seekp + "/" + h.index + " out of file size " + entryFile.length() + "/" + ((entryFile.length() - POS_NODES) / recordsize) + " after " + markedDeleted.size() + " iterations; patched wrong node"); entryFile.writeInt(repair_position, kelondroHandle.NUL); return markedDeleted; @@ -871,6 +871,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords { return new contentRowIterator(maxInitTime); } + /* public final class contentRowIterator implements Iterator { // iterator that iterates all kelondroRow.Entry-objects in the file // all records that are marked as deleted are omitted @@ -885,6 +886,15 @@ public abstract class kelondroAbstractRecords implements kelondroRecords { return nodeIterator.hasNext(); } + public EntryIndex next0() { + try { + kelondroNode n = (kelondroNode) nodeIterator.next(); + return row().newEntryIndex(n.getValueRow(), n.handle().index); + } catch (IOException e) { + throw new kelondroException(filename, e.getMessage()); + } + } + public EntryIndex next() { try { kelondroNode n = (kelondroNode) nodeIterator.next(); @@ -898,6 +908,54 @@ public abstract class kelondroAbstractRecords implements kelondroRecords { throw new UnsupportedOperationException(); } + } + */ + + public final class contentRowIterator implements Iterator { + // iterator that iterates all kelondroRow.Entry-objects in the file + // all records that are marked as deleted are omitted + + private Iterator nodeIterator; + private EntryIndex nextEntry; + + public contentRowIterator(long maxInitTime) { + nodeIterator = contentNodes(maxInitTime); + if (nodeIterator.hasNext()) nextEntry = next0(); else nextEntry = null; + } + + public boolean hasNext() { + return nextEntry != null; + } + + public EntryIndex next0() { + if (!nodeIterator.hasNext()) { + return null; + } + try { + kelondroNode n = (kelondroNode) nodeIterator.next(); + return row().newEntryIndex(n.getValueRow(), n.handle().index); + } catch (IOException e) { + throw new kelondroException(filename, e.getMessage()); + } + } + + public EntryIndex next() { + EntryIndex ni = nextEntry; + byte[] b; + nextEntry = null; + while (nodeIterator.hasNext()) { + nextEntry = next0(); + if (nextEntry == null) break; + b = nextEntry.bytes(); + if ((b[0] != -128) || (b[1] != 0)) break; + } + return ni; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + } protected final Iterator contentNodes(long maxInitTime) throws kelondroException { diff --git a/source/de/anomic/kelondro/kelondroBitfield.java b/source/de/anomic/kelondro/kelondroBitfield.java index a9193bd3b..0500cf41a 100644 --- a/source/de/anomic/kelondro/kelondroBitfield.java +++ b/source/de/anomic/kelondro/kelondroBitfield.java @@ -55,7 +55,7 @@ public class kelondroBitfield implements Cloneable { } } - public Object clone() { + public kelondroBitfield clone() { kelondroBitfield theClone = new kelondroBitfield(new byte[this.bb.length]); System.arraycopy(this.bb, 0, theClone.bb, 0, this.bb.length); return theClone; diff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/kelondroMScoreCluster.java index e720fbb1c..520e9f690 100644 --- a/source/de/anomic/kelondro/kelondroMScoreCluster.java +++ b/source/de/anomic/kelondro/kelondroMScoreCluster.java @@ -272,13 +272,13 @@ public final class kelondroMScoreCluster { return (int) ((keyrefDB.firstKey().longValue() & 0xFFFFFFFF00000000L) >> 32); } - public synchronized Object getMaxObject() { + public synchronized E getMaxObject() { if (refkeyDB.size() == 0) return null; //return getScores(1, false)[0]; return keyrefDB.get(keyrefDB.lastKey()); } - public synchronized Object getMinObject() { + public synchronized E getMinObject() { if (refkeyDB.size() == 0) return null; //return getScores(1, true)[0]; return keyrefDB.get(keyrefDB.firstKey()); diff --git a/source/de/anomic/kelondro/kelondroProfile.java b/source/de/anomic/kelondro/kelondroProfile.java index 8c43f2e62..648b39749 100644 --- a/source/de/anomic/kelondro/kelondroProfile.java +++ b/source/de/anomic/kelondro/kelondroProfile.java @@ -81,7 +81,7 @@ public class kelondroProfile implements Cloneable { accDelete += System.currentTimeMillis() - handle; } - public Object clone() { + public kelondroProfile clone() { kelondroProfile clone = new kelondroProfile(); clone.accRead = this.accRead; clone.accWrite = this.accWrite; diff --git a/source/de/anomic/net/ftpc.java b/source/de/anomic/net/ftpc.java index 0b1cb97ae..71f7dd9a1 100644 --- a/source/de/anomic/net/ftpc.java +++ b/source/de/anomic/net/ftpc.java @@ -1705,7 +1705,7 @@ cd .. // write remote file to local file byte[] block = new byte[blockSize]; int numRead; - long length = 0; + int length = 0; while ((numRead = ClientStream.read(block)) != -1) { outFile.write(block, 0, numRead); @@ -1726,7 +1726,7 @@ cd .. // write statistics long stop = System.currentTimeMillis(); out.print("---- downloaded " + - ((length < 2048) ? length + " bytes" : ((int) length / 1024) + " kbytes") + + ((length < 2048) ? length + " bytes" : (length / 1024) + " kbytes") + " in " + (((stop - start) < 2000) ? (stop - start) + " milliseconds" : (((int) ((stop - start) / 100)) / 10) + " seconds")); if (start == stop) err.println(logPrefix + ""); else diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java index 1c9237a47..f940bed6f 100644 --- a/source/de/anomic/plasma/plasmaHTCache.java +++ b/source/de/anomic/plasma/plasmaHTCache.java @@ -1020,7 +1020,7 @@ public final class plasmaHTCache { */ private IResourceInfo resInfo; - protected Object clone() throws CloneNotSupportedException { + protected Entry clone() throws CloneNotSupportedException { return new Entry( this.initDate, this.depth, diff --git a/source/de/anomic/server/serverHandler.java b/source/de/anomic/server/serverHandler.java index d4e5de0b4..3233a175c 100644 --- a/source/de/anomic/server/serverHandler.java +++ b/source/de/anomic/server/serverHandler.java @@ -109,7 +109,7 @@ public interface serverHandler { // each time a server makes a new connection it clones the hanlder prototype // the clone method does not need to clone every detail of a handler connection, // but only the necessary one for a newly initialized instance - public Object clone(); + public serverHandler clone(); /** * Instead of using clone this function can be used to reset an existing diff --git a/source/de/anomic/tools/disorderSet.java b/source/de/anomic/tools/disorderSet.java index d32faa18c..df7c0a3f5 100644 --- a/source/de/anomic/tools/disorderSet.java +++ b/source/de/anomic/tools/disorderSet.java @@ -58,7 +58,7 @@ public class disorderSet extends HashSet implements Set { return (this.size() > 0); } - public Object any() { + public String any() { // return just any element if ((dh == null) || (dh.size() == 0)) { if (this.size() == 0) return null; diff --git a/source/de/anomic/urlRedirector/urlRedirectord.java b/source/de/anomic/urlRedirector/urlRedirectord.java index ee66aee43..d157e1f92 100644 --- a/source/de/anomic/urlRedirector/urlRedirectord.java +++ b/source/de/anomic/urlRedirector/urlRedirectord.java @@ -90,7 +90,7 @@ public class urlRedirectord implements serverHandler { return null; } - public Object clone() { + public urlRedirectord clone() { return null; } diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index b34731bdc..2a88db450 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -860,9 +860,9 @@ public class yacySeed { } @SuppressWarnings("unchecked") - public final Object clone() { + public final yacySeed clone() { synchronized (this.dna) { - return new yacySeed(this.hash, (HashMap) (new HashMap(this.dna)).clone()); + return new yacySeed(this.hash, (HashMap) (new HashMap(this.dna).clone())); } }