Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
more generics
orbitera6ca3b51be47
diff --git a/htroot/yacy/profile.java b/htroot/yacy/profile.javaindex 6003b8701..dd10cdfd0 100644--- a/htroot/yacy/profile.java+++ b/htroot/yacy/profile.java@@ -52,7 +52,6 @@ import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.util.Iterator;-import java.util.Map;import java.util.Properties;import de.anomic.http.httpHeader;@@ -92,9 +91,9 @@ public final class profile {if (fileIn != null) try { fileIn.close(); fileIn = null; } catch (Exception e) {}}- Iterator<String> it = ((Map)profile).keySet().iterator();+ Iterator<Object> it = profile.keySet().iterator();while (it.hasNext()) {- key = it.next();+ key = (String) it.next();value=profile.getProperty(key, "").replaceAll("\r","").replaceAll("\n","\\\\n");if( !(key.equals("")) && !(value.equals("")) ){prop.put("list_"+count+"_key", key);diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.javaindex 8e4d50173..15ba2d4a8 100644--- a/htroot/yacy/transferRWI.java+++ b/htroot/yacy/transferRWI.java@@ -137,13 +137,13 @@ public final class transferRWI {String wordHash;String urlHash;indexRWIEntry iEntry;- final HashSet unknownURL = new HashSet();- final HashSet knownURL = new HashSet();+ final HashSet<String> unknownURL = new HashSet<String>();+ final HashSet<String> knownURL = new HashSet<String>();String[] wordhashes = new String[v.size()];int received = 0;int blocked = 0;int receivedURL = 0;- Iterator i = v.iterator();+ Iterator<String> i = v.iterator();while (i.hasNext()) {serverCore.checkInterruption();estring = (String) i.next();@@ -189,10 +189,10 @@ public final class transferRWI {yacyCore.seedDB.mySeed().incRI(received);// finally compose the unknownURL hash list- final Iterator it = unknownURL.iterator();+ final Iterator<String> it = unknownURL.iterator();unknownURLs.ensureCapacity(unknownURL.size()*13);while (it.hasNext()) {- unknownURLs.append(",").append((String) it.next());+ unknownURLs.append(",").append(it.next());}if (unknownURLs.length() > 0) { unknownURLs.delete(0, 1); }if ((wordhashes.length == 0) || (received == 0)) {diff --git a/source/de/anomic/kelondro/kelondroFlexWidthArray.java b/source/de/anomic/kelondro/kelondroFlexWidthArray.javaindex feec7767f..d2fe74b3c 100644--- a/source/de/anomic/kelondro/kelondroFlexWidthArray.java+++ b/source/de/anomic/kelondro/kelondroFlexWidthArray.java@@ -266,6 +266,7 @@ public class kelondroFlexWidthArray implements kelondroArray {return index;}+ @SuppressWarnings("unchecked")protected synchronized TreeMap<Integer, byte[]> addMultiple(List<kelondroRow.Entry> rows) throws IOException {// result is a Integer/byte[] relation// of newly added rows (index, key)diff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/kelondroMScoreCluster.javaindex 1708a7c9b..e720fbb1c 100644--- a/source/de/anomic/kelondro/kelondroMScoreCluster.java+++ b/source/de/anomic/kelondro/kelondroMScoreCluster.java@@ -288,7 +288,8 @@ public final class kelondroMScoreCluster<E> {return getScores(maxCount, up, Integer.MIN_VALUE, Integer.MAX_VALUE);}- public synchronized E[] getScores(int maxCount, boolean up, int minScore, int maxScore) {+ @SuppressWarnings("unchecked")+ public synchronized E[] getScores(int maxCount, boolean up, int minScore, int maxScore) {if (maxCount > refkeyDB.size()) maxCount = refkeyDB.size();E[] s = (E[]) new Object[maxCount];Iterator<E> it = scores(up, minScore, maxScore);@@ -309,21 +310,22 @@ public final class kelondroMScoreCluster<E> {}public synchronized Iterator<E> scores(boolean up) {- if (up) return new simpleScoreIterator();- return new reverseScoreIterator();+ if (up) return new simpleScoreIterator<E>();+ return new reverseScoreIterator<E>();}public synchronized Iterator<E> scores(boolean up, int minScore, int maxScore) {- return new komplexScoreIterator(up, minScore, maxScore);+ return new komplexScoreIterator<E>(up, minScore, maxScore);}- private class komplexScoreIterator implements Iterator<E> {+ private class komplexScoreIterator<A extends E> implements Iterator<E> {boolean up;TreeMap<Long, E> keyrefDBcopy;E n;int min, max;+ @SuppressWarnings("unchecked")public komplexScoreIterator(boolean up, int minScore, int maxScore) {this.up = up;this.min = minScore;@@ -365,7 +367,7 @@ public final class kelondroMScoreCluster<E> {}- private class reverseScoreIterator implements Iterator<E> {+ private class reverseScoreIterator<A extends E> implements Iterator<E> {SortedMap<Long, E> view;Long key;@@ -393,7 +395,7 @@ public final class kelondroMScoreCluster<E> {}- private class simpleScoreIterator implements Iterator<E> {+ private class simpleScoreIterator<A extends E> implements Iterator<E> {Iterator<Map.Entry<Long, E>> ii;Map.Entry<Long, E> entry;diff --git a/source/de/anomic/kelondro/kelondroMapObjects.java b/source/de/anomic/kelondro/kelondroMapObjects.javaindex 9065ee38b..1b9c24a33 100644--- a/source/de/anomic/kelondro/kelondroMapObjects.java+++ b/source/de/anomic/kelondro/kelondroMapObjects.java@@ -45,6 +45,7 @@ public class kelondroMapObjects extends kelondroObjects {this(dyn, cachesize, null, null, null, null, null);}+ @SuppressWarnings("unchecked")public kelondroMapObjects(kelondroDyn dyn, int cachesize, String[] sortfields, String[] longaccfields, String[] doubleaccfields, Method externalInitializer, Object externalHandler) {super(dyn, cachesize);diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex fbdac85b9..3d920edb7 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -78,8 +78,8 @@ import de.anomic.plasma.plasmaCondenser;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverCodings;import de.anomic.server.serverCore;-import de.anomic.server.serverDomains;import de.anomic.server.serverDate;+import de.anomic.server.serverDomains;import de.anomic.server.serverSystem;import de.anomic.tools.bitfield;import de.anomic.tools.crypt;@@ -180,12 +180,12 @@ public class yacySeed {/** the peer-hash */public String hash;/** a set of identity founding values, eg. IP, name of the peer, YaCy-version, ...*/- private final Map dna;+ private final Map<String, String> dna;public int available;public int selectscore = -1; // only for debuggingpublic String alternativeIP = null;- public yacySeed(String theHash, Map theDna) {+ public yacySeed(String theHash, Map<String, String> theDna) {// create a seed with a pre-defined hash mapthis.hash = theHash;this.dna = theDna;@@ -195,7 +195,7 @@ public class yacySeed {}public yacySeed(String theHash) {- this.dna = Collections.synchronizedMap(new HashMap());+ this.dna = Collections.synchronizedMap(new HashMap<String, String>());// settings that can only be computed by originating peer:// at first startup -@@ -359,7 +359,7 @@ public class yacySeed {}/** @return the DNA-map of this peer */- public final Map getMap() {+ public final Map<String, String> getMap() {return this.dna;}@@ -571,17 +571,17 @@ public class yacySeed {}}- public void setPeerTags(Set keys) {+ public void setPeerTags(Set<String> keys) {dna.put(PEERTAGS, serverCodings.set2string(keys, "|", false));}- public Set getPeerTags() {+ public Set<String> getPeerTags() {return serverCodings.string2set(get(PEERTAGS, ""), "|");}- public boolean matchPeerTags(Set searchHashes) {- Set tags = serverCodings.string2set(get(PEERTAGS, ""), "|");- Iterator i = tags.iterator();+ public boolean matchPeerTags(Set<String> searchHashes) {+ Set<String> tags = serverCodings.string2set(get(PEERTAGS, ""), "|");+ Iterator<String> i = tags.iterator();while (i.hasNext()) {if (searchHashes.contains(plasmaCondenser.word2hash((String) i.next()))) return true;}@@ -704,7 +704,7 @@ public class yacySeed {String bestHash = null;double c, bestC = Double.MAX_VALUE;double segmentSize = Math.min(0.9, 4.0 / seedDB.sizeConnected());- Iterator i;+ Iterator<yacySeed> i;double d;yacySeed s;for (int t = 0; t < tries; t++) {@@ -712,7 +712,7 @@ public class yacySeed {i = seedDB.seedsConnected(true, true, hash, (float) 0.0);c = 0.0;while (i.hasNext()) {- s = (yacySeed) i.next();+ s = i.next();d = dhtDistance(hash, s.hash);if (d > segmentSize) break;c = c + 1.0/d;@@ -793,7 +793,7 @@ public class yacySeed {if (seedStr == null) { return null; }final String seed = crypt.simpleDecode(seedStr, key);if (seed == null) { return null; }- final Map dna = serverCodings.string2map(seed, ",");+ final Map<String, String> dna = serverCodings.string2map(seed, ",");final String hash = (String) dna.remove(yacySeed.HASH);final yacySeed resultSeed = new yacySeed(hash, dna);if (properTest) {@@ -856,7 +856,7 @@ public class yacySeed {public final Object clone() {synchronized (this.dna) {- return new yacySeed(this.hash, (HashMap) (new HashMap(this.dna)).clone());+ return new yacySeed(this.hash, (HashMap<String, String>) (new HashMap<String, String>(this.dna)).clone());}}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 6bd3ffc6a..af8ab6251 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -104,8 +104,8 @@ public final class yacySeedDB {private final plasmaSwitchboard sb;private yacySeed mySeed; // my own seed- private final Hashtable nameLookupCache;- private final Hashtable ipLookupCache;+ private final Hashtable<String, yacySeed> nameLookupCache;+ private final Hashtable<InetAddress, SoftReference<yacySeed>> ipLookupCache;public yacySeedDB(plasmaSwitchboard sb,File seedActiveDBFile,@@ -126,10 +126,10 @@ public final class yacySeedDB {seedPotentialDB = openSeedTable(seedPotentialDBFile);// start our virtual DNS service for yacy peers with empty cache- nameLookupCache = new Hashtable();+ nameLookupCache = new Hashtable<String, yacySeed>();// cache for reverse name lookup- ipLookupCache = new Hashtable();+ ipLookupCache = new Hashtable<InetAddress, SoftReference<yacySeed>>();// check if we are in the seedCaches: this can happen if someone else published our seedremoveMySeed();@@ -271,7 +271,7 @@ public final class yacySeedDB {return new seedEnum(up, field, seedPotentialDB);}- public TreeMap /* peer-b64-hashes/ipport */ clusterHashes(String clusterdefinition) {+ public TreeMap<String, String> /* peer-b64-hashes/ipport */ clusterHashes(String clusterdefinition) {// collects seeds according to cluster definition string, which consists of// comma-separated .yacy or .yacyh-domains// the domain may be extended by an alternative address specification of the form@@ -281,7 +281,7 @@ public final class yacySeedDB {// address ::= (<peername>'.yacy'|<peerhexhash>'.yacyh'){'='<ip>{':'<port}}// clusterdef ::= {address}{','address}*String[] addresses = (clusterdefinition.length() == 0) ? new String[0] : clusterdefinition.split(",");- TreeMap clustermap = new TreeMap(kelondroBase64Order.enhancedCoder);+ TreeMap<String, String> clustermap = new TreeMap<String, String>(kelondroBase64Order.enhancedComparator);yacySeed seed;String hash, yacydom, ipport;int p;@@ -419,7 +419,7 @@ public final class yacySeedDB {//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {nameLookupCache.put(seed.getName(), seed);- Map seedPropMap = seed.getMap();+ Map<String, String> seedPropMap = seed.getMap();synchronized(seedPropMap) {seedActiveDB.set(seed.hash, seedPropMap);}@@ -446,7 +446,7 @@ public final class yacySeedDB {} catch (Exception e) {}//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {- Map seedPropMap = seed.getMap();+ Map<String, String> seedPropMap = seed.getMap();synchronized(seedPropMap) {seedPassiveDB.set(seed.hash, seedPropMap);}@@ -472,7 +472,7 @@ public final class yacySeedDB {if (seed.isProper() != null) return;//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {- Map seedPropMap = seed.getMap();+ Map<String, String> seedPropMap = seed.getMap();synchronized(seedPropMap) {seedPotentialDB.set(seed.hash, seedPropMap);}@@ -529,7 +529,7 @@ public final class yacySeedDB {private yacySeed get(String hash, kelondroMapObjects database) {if (hash == null) return null;if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;- Map entry = database.getMap(hash);+ Map<String, String> entry = database.getMap(hash);if (entry == null) return null;return new yacySeed(hash, entry);}@@ -586,7 +586,7 @@ public final class yacySeedDB {// enumerate the cache and simultanous insert valuesString name;for (int table = 0; table < 2; table++) {- Iterator e = (table == 0) ? seedsConnected(true, false, null, (float) 0.0) : seedsDisconnected(true, false, null, (float) 0.0);+ Iterator<yacySeed> e = (table == 0) ? seedsConnected(true, false, null, (float) 0.0) : seedsDisconnected(true, false, null, (float) 0.0);while (e.hasNext()) {seed = (yacySeed) e.next();if (seed != null) {@@ -622,7 +622,7 @@ public final class yacySeedDB {}// then try to use the cache- SoftReference ref = (SoftReference) ipLookupCache.get(peerIP);+ SoftReference<yacySeed> ref = ipLookupCache.get(peerIP);if (ref != null) {seed = (yacySeed) ref.get();if (seed != null) return seed;@@ -634,7 +634,7 @@ public final class yacySeedDB {if (lookupConnected) {// enumerate the cache and simultanous insert values- Iterator e = seedsConnected(true, false, null, (float) 0.0);+ Iterator<yacySeed> e = seedsConnected(true, false, null, (float) 0.0);while (e.hasNext()) {try {@@ -649,7 +649,7 @@ public final class yacySeedDB {addressStr = addressStr.substring(0,pos);}seedIPAddress = InetAddress.getByName(addressStr);- if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(seed));+ if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference<yacySeed>(seed));if (seedIPAddress.equals(peerIP)) return seed;}} catch (UnknownHostException ex) {}@@ -658,7 +658,7 @@ public final class yacySeedDB {if (lookupDisconnected) {// enumerate the cache and simultanous insert values- Iterator e = seedsDisconnected(true, false, null, (float) 0.0);+ Iterator<yacySeed>e = seedsDisconnected(true, false, null, (float) 0.0);while (e.hasNext()) {try {@@ -673,7 +673,7 @@ public final class yacySeedDB {addressStr = addressStr.substring(0,pos);}seedIPAddress = InetAddress.getByName(addressStr);- if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(seed));+ if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference<yacySeed>(seed));if (seedIPAddress.equals(peerIP)) return seed;}} catch (UnknownHostException ex) {}@@ -682,7 +682,7 @@ public final class yacySeedDB {if (lookupPotential) {// enumerate the cache and simultanous insert values- Iterator e = seedsPotential(true, false, null, (float) 0.0);+ Iterator<yacySeed> e = seedsPotential(true, false, null, (float) 0.0);while (e.hasNext()) {try {@@ -692,7 +692,7 @@ public final class yacySeedDB {addressStr = addressStr.substring(0,pos);}seedIPAddress = InetAddress.getByName(addressStr);- if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(seed));+ if (seed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference<yacySeed>(seed));if (seedIPAddress.equals(peerIP)) return seed;}} catch (UnknownHostException ex) {}@@ -708,7 +708,7 @@ public final class yacySeedDB {addressStr = addressStr.substring(0,pos);}seedIPAddress = InetAddress.getByName(addressStr);- if (mySeed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference(mySeed));+ if (mySeed.isProper() == null) ipLookupCache.put(seedIPAddress, new SoftReference<yacySeed>(mySeed));if (seedIPAddress.equals(peerIP)) return mySeed;// nothing foundreturn null;@@ -717,13 +717,13 @@ public final class yacySeedDB {}}- public ArrayList storeCache(File seedFile) throws IOException {- return storeCache(seedFile, false);+ public ArrayList<String> storeCache(File seedFile) throws IOException {+ return storeCache(seedFile, false);}- private ArrayList storeCache(File seedFile, boolean addMySeed) throws IOException {+ private ArrayList<String> storeCache(File seedFile, boolean addMySeed) throws IOException {PrintWriter pw = null;- ArrayList v = new ArrayList(seedActiveDB.size()+1);+ ArrayList<String> v = new ArrayList<String>(seedActiveDB.size() + 1);try {pw = new PrintWriter(new BufferedWriter(new FileWriter(seedFile)));@@ -739,7 +739,7 @@ public final class yacySeedDB {// store other seedsyacySeed ys;- Iterator se = seedsConnected(true, false, null, (float) 0.0);+ Iterator<yacySeed> se = seedsConnected(true, false, null, (float) 0.0);while (se.hasNext()) {ys = (yacySeed) se.next();if (ys != null) {@@ -774,7 +774,7 @@ public final class yacySeedDB {seedFile = File.createTempFile("seedFile",".txt", plasmaHTCache.cachePath);seedFile.deleteOnExit();serverLog.logFine("YACY","SaveSeedList: Storing seedlist into tempfile " + seedFile.toString());- ArrayList uv = storeCache(seedFile, true);+ ArrayList<String> uv = storeCache(seedFile, true);// uploading the seed fileserverLog.logFine("YACY","SaveSeedList: Trying to upload seed-file, " + seedFile.length() + " bytes, " + uv.size() + " entries.");@@ -782,7 +782,7 @@ public final class yacySeedDB {// test downloadserverLog.logFine("YACY","SaveSeedList: Trying to download seed-file '" + seedURL + "'.");- ArrayList check = downloadSeedFile(seedURL);+ ArrayList<String> check = downloadSeedFile(seedURL);// Comparing if local copy and uploaded copy are equalString errorMsg = checkCache(uv, check);@@ -798,7 +798,7 @@ public final class yacySeedDB {return log;}- private ArrayList downloadSeedFile(yacyURL seedURL) throws IOException {+ private ArrayList<String> downloadSeedFile(yacyURL seedURL) throws IOException {httpc remote = null;try {// init httpc@@ -838,7 +838,7 @@ public final class yacySeedDB {}}- private String checkCache(ArrayList uv, ArrayList check) {+ private String checkCache(ArrayList<String> uv, ArrayList<String> check) {if ((check == null) || (uv == null) || (uv.size() != check.size())) {serverLog.logFine("YACY","SaveSeedList: Local and uploades seed-list " +"contains varying numbers of entries." +@@ -960,7 +960,7 @@ public final class yacySeedDB {public yacySeed internalNext() {if ((it == null) || (!(it.hasNext()))) return null;- Map dna = (Map) it.next();+ Map<String, String> dna = it.next();if (dna == null) return null;String hash = (String) dna.remove("key");//while (hash.length() < commonHashLength) { hash = hash + "_"; }diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.javaindex f5bd9dfd5..d18819c56 100644--- a/source/de/anomic/yacy/yacyVersion.java+++ b/source/de/anomic/yacy/yacyVersion.java@@ -46,7 +46,7 @@ import de.anomic.server.serverCore;import de.anomic.server.serverSystem;import de.anomic.server.logging.serverLog;-public final class yacyVersion implements Comparator, Comparable {+public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVersion> {// general release infopublic static final float YACY_SUPPORTS_PORT_FORWARDING = (float) 0.383;@@ -135,18 +135,16 @@ public final class yacyVersion implements Comparator, Comparable {// finished! we parsed a relase string}- public int compareTo(Object obj) {+ public int compareTo(yacyVersion obj) {// returns 0 if this object is equal to the obj, -1 if this is smaller than obj and 1 if this is greater than obj- yacyVersion v = (yacyVersion) obj;- return compare(this, v);+ return compare(this, obj);}- public int compare(Object arg0, Object arg1) {+ public int compare(yacyVersion v0, yacyVersion v1) {// compare-operator for two yacyVersion objects// must be implemented to make it possible to put this object into// a ordered structure, like TreeSet or TreeMap- yacyVersion a0 = (yacyVersion) arg0, a1 = (yacyVersion) arg1;- return (new Integer(a0.svn)).compareTo(new Integer(a1.svn));+ return (new Integer(v0.svn)).compareTo(new Integer(v1.svn));}public boolean equals(Object obj) {