!Important: move from Hashtable to HashMap

Hashtable is an obsolete collection v1, now since v2 offers HashMap with same or better
functionality. Please review, almost all code was already moved, so only a few changes. That is not the issue,
but I found notices that some (ugly big) helper classes had to be created in past
to compensate missing Hashtable's functionality. I'd like input if we can remove some of them.
look for //FIX: if these commits

Signed-off-by: Marek Otahal <markotahal@gmail.com>
pull/1/head
Marek Otahal 13 years ago committed by Michael Peter Christen
parent c1af123ddd
commit 72adbeae90

@ -80,7 +80,7 @@ public class Translator {
/**
* Load multiple translationLists from one File. Each List starts with #File: relative/path/to/file
* @param translationFile the File, which contains the Lists
* @return a Hashtable, which contains for each File a Hashtable with translations.
* @return a HashMap, which contains for each File a HashMap with translations.
*/
public static Map<String, Map<String, String>> loadTranslationsLists(final File translationFile){
final Map<String, Map<String, String>> lists = new HashMap<String, Map<String, String>>(); //list of translationLists for different files.

@ -87,10 +87,10 @@ import net.yacy.kelondro.util.FileUtils;
* &lt;/body&gt;&lt;/html&gt;
* </pre>
* <p>
* The corresponding Hashtable to use this Template:<br>
* The corresponding HashMap to use this Template:<br>
* <b>Java Example</b><br>
* <pre>
* Hashtable pattern;
* HashMap pattern;
* pattern.put("times", 10); //10 greetings
* for(int i=0;i<=9;i++){
* pattern.put("times_"+i+"_daytime", 1); //index: 1, second Entry, evening
@ -112,7 +112,7 @@ import net.yacy.kelondro.util.FileUtils;
* <li>Multi templates: multitemplatename_index_</li>
* <li>Alterantives: alternativename_</li>
* </ul>
* So the Names in the Hashtable are:
* So the Names in the HashMap are:
* <ul>
* <li>Multi templates: multitemplatename_index_templatename</li>
* <li>Alterantives: alternativename_templatename</li>

@ -33,6 +33,7 @@
Properties - setProperty would be needed, but only available in 1.2
HashMap, TreeMap - only in 1.2
Hashtable - available in 1.0, but 'put' does not accept null values
//FIXME: it's 2012, do we still need support for Java 1.0?!
So this class was created as a convenience.
It will also contain special methods that read data from internet-resources

@ -24,7 +24,9 @@
package de.anomic.tools;
import java.util.Hashtable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.http.ProxySettings;
@ -39,8 +41,8 @@ public class loaderThreads {
protected ProxySettings remoteProxyConfig;
// management objects for collection of threads
Hashtable<String, Thread> threads;
int completed, failed;
private Map<String, Thread> threads;
private int completed, failed;
public loaderThreads() {
this(10000, null, null);
@ -54,7 +56,7 @@ public class loaderThreads {
this.timeout = timeout;
this.user = user;
this.password = password;
this.threads = new Hashtable<String, Thread>();
this.threads = new HashMap<String, Thread>();
this.completed = 0;
this.failed = 0;
}

@ -118,6 +118,7 @@ public class OAIPMHImporter extends Thread implements Importer, Comparable<OAIPM
return (int) (1000L * ((long) count()) / runningTime());
}
@Override
public void run() {
while (runningJobs.size() > 50) {
try {Thread.sleep(10000 + 3000 * (System.currentTimeMillis() % 6));} catch (InterruptedException e) {}

@ -37,6 +37,8 @@ import net.yacy.cora.order.ByteOrder;
* a byte[] in a Hashtable does not work because the hash computation does not
* work for byte[]. This class extends byte[] with a cached hashing function,
* so it can be used in hashtables.
* //FIXME: so does storing byte[] in HashMap help? as I'm moving use of Hashtable to
* //FIXME: HashMap, if so, please remove this class- or notify me
*/
public class ByteArray {

@ -27,7 +27,6 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;
import java.util.Vector;
@ -35,6 +34,7 @@ import java.util.Vector;
import net.yacy.cora.document.UTF8;
import net.yacy.kelondro.logging.Log;
import de.anomic.server.serverCore;
import java.util.*;
public final class OS {
@ -63,8 +63,8 @@ public final class OS {
public static int maxPathLength = 65535;
// Macintosh-specific statics
public static final Hashtable<String, String> macFSTypeCache = new Hashtable<String, String>();
public static final Hashtable<String, String> macFSCreatorCache = new Hashtable<String, String>();
public static final Map<String, String> macFSTypeCache = new HashMap<String, String>();
public static final Map<String, String> macFSCreatorCache = new HashMap<String, String>();
// static initialization
static {

@ -33,7 +33,7 @@ import java.lang.ref.SoftReference;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -98,8 +98,8 @@ public final class SeedDB implements AlternativeDomainNames {
private Seed mySeed; // my own seed
private final Set<String> myBotIDs; // list of id's that this bot accepts as robots.txt identification
private final Hashtable<String, String> nameLookupCache; // a name-to-hash relation
private final Hashtable<InetAddress, SoftReference<Seed>> ipLookupCache;
private final Map<String, String> nameLookupCache; // a name-to-hash relation
private final Map<InetAddress, SoftReference<Seed>> ipLookupCache;
public SeedDB(
final File networkRoot,
@ -129,10 +129,10 @@ public final class SeedDB implements AlternativeDomainNames {
this.seedPotentialDB = openSeedTable(this.seedPotentialDBFile);
// start our virtual DNS service for yacy peers with empty cache
this.nameLookupCache = new Hashtable<String, String>();
this.nameLookupCache = new HashMap<String, String>();
// cache for reverse name lookup
this.ipLookupCache = new Hashtable<InetAddress, SoftReference<Seed>>();
this.ipLookupCache = new HashMap<InetAddress, SoftReference<Seed>>();
// check if we are in the seedCaches: this can happen if someone else published our seed
removeMySeed();

@ -56,7 +56,6 @@ import java.security.spec.InvalidKeySpecException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -260,7 +259,7 @@ public final class Switchboard extends serverSwitch
//private Object crawlingPausedSync = new Object();
//private boolean crawlingIsPaused = false;
public Hashtable<String, Object[]> crawlJobsStatus = new Hashtable<String, Object[]>();
public HashMap<String, Object[]> crawlJobsStatus = new HashMap<String, Object[]>();
private static Switchboard sb = null;

Loading…
Cancel
Save