mirror of
https://github.com/processing/processing4.git
synced 2026-06-08 08:31:28 +02:00
Replace instances of Hashtable with HashMap
This commit is contained in:
@@ -2821,7 +2821,7 @@ public class Base {
|
||||
* @return array of possible package names
|
||||
*/
|
||||
static public String[] packageListFromClassPath(String path) {
|
||||
Hashtable table = new Hashtable();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String pieces[] =
|
||||
PApplet.split(path, File.pathSeparatorChar);
|
||||
|
||||
@@ -2832,24 +2832,24 @@ public class Base {
|
||||
if (pieces[i].toLowerCase().endsWith(".jar") ||
|
||||
pieces[i].toLowerCase().endsWith(".zip")) {
|
||||
//System.out.println("checking " + pieces[i]);
|
||||
packageListFromZip(pieces[i], table);
|
||||
packageListFromZip(pieces[i], map);
|
||||
|
||||
} else { // it's another type of file or directory
|
||||
File dir = new File(pieces[i]);
|
||||
if (dir.exists() && dir.isDirectory()) {
|
||||
packageListFromFolder(dir, null, table);
|
||||
packageListFromFolder(dir, null, map);
|
||||
//importCount = magicImportsRecursive(dir, null,
|
||||
// table);
|
||||
// map);
|
||||
//imports, importCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
int tableCount = table.size();
|
||||
String output[] = new String[tableCount];
|
||||
int mapCount = map.size();
|
||||
String output[] = new String[mapCount];
|
||||
int index = 0;
|
||||
Enumeration e = table.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
output[index++] = ((String) e.nextElement()).replace('/', '.');
|
||||
Set<String> set = map.keySet();
|
||||
for (String s : set) {
|
||||
output[index++] = s.replace('/', '.');
|
||||
}
|
||||
//System.arraycopy(imports, 0, output, 0, importCount);
|
||||
//PApplet.printarr(output);
|
||||
@@ -2857,7 +2857,7 @@ public class Base {
|
||||
}
|
||||
|
||||
|
||||
static private void packageListFromZip(String filename, Hashtable table) {
|
||||
static private void packageListFromZip(String filename, Map<String, Object> map) {
|
||||
try {
|
||||
ZipFile file = new ZipFile(filename);
|
||||
Enumeration entries = file.entries();
|
||||
@@ -2872,8 +2872,8 @@ public class Base {
|
||||
if (slash == -1) continue;
|
||||
|
||||
String pname = name.substring(0, slash);
|
||||
if (table.get(pname) == null) {
|
||||
table.put(pname, new Object());
|
||||
if (map.get(pname) == null) {
|
||||
map.put(pname, new Object());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2893,7 +2893,7 @@ public class Base {
|
||||
* walk down into that folder and continue.
|
||||
*/
|
||||
static private void packageListFromFolder(File dir, String sofar,
|
||||
Hashtable table) {
|
||||
Map<String, Object> map) {
|
||||
//String imports[],
|
||||
//int importCount) {
|
||||
//System.err.println("checking dir '" + dir + "'");
|
||||
@@ -2907,7 +2907,7 @@ public class Base {
|
||||
if (sub.isDirectory()) {
|
||||
String nowfar =
|
||||
(sofar == null) ? files[i] : (sofar + "." + files[i]);
|
||||
packageListFromFolder(sub, nowfar, table);
|
||||
packageListFromFolder(sub, nowfar, map);
|
||||
//System.out.println(nowfar);
|
||||
//imports[importCount++] = nowfar;
|
||||
//importCount = magicImportsRecursive(sub, nowfar,
|
||||
@@ -2915,7 +2915,7 @@ public class Base {
|
||||
} else if (!foundClass) { // if no classes found in this folder yet
|
||||
if (files[i].endsWith(".class")) {
|
||||
//System.out.println("unique class: " + files[i] + " for " + sofar);
|
||||
table.put(sofar, new Object());
|
||||
map.put(sofar, new Object());
|
||||
foundClass = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,13 +109,13 @@ public class WebServer implements HttpConstants {
|
||||
//public static void main(String[] a) throws Exception {
|
||||
static public int launch(String zipPath) throws IOException {
|
||||
final ZipFile zip = new ZipFile(zipPath);
|
||||
final HashMap<String, ZipEntry> entries = new HashMap();
|
||||
final Map<String, ZipEntry> entries = new HashMap<String, ZipEntry>();
|
||||
Enumeration en = zip.entries();
|
||||
while (en.hasMoreElements()) {
|
||||
ZipEntry entry = (ZipEntry) en.nextElement();
|
||||
entries.put(entry.getName(), entry);
|
||||
}
|
||||
|
||||
|
||||
// if (a.length > 0) {
|
||||
// port = Integer.parseInt(a[0]);
|
||||
// }
|
||||
@@ -164,9 +164,9 @@ public class WebServer implements HttpConstants {
|
||||
|
||||
|
||||
class WebServerWorker /*extends WebServer*/ implements HttpConstants, Runnable {
|
||||
ZipFile zip;
|
||||
HashMap<String, ZipEntry> entries;
|
||||
|
||||
private final ZipFile zip;
|
||||
private final Map<String, ZipEntry> entries;
|
||||
|
||||
final static int BUF_SIZE = 2048;
|
||||
|
||||
static final byte[] EOL = { (byte)'\r', (byte)'\n' };
|
||||
@@ -176,10 +176,10 @@ class WebServerWorker /*extends WebServer*/ implements HttpConstants, Runnable {
|
||||
/* Socket to client we're handling */
|
||||
private Socket s;
|
||||
|
||||
WebServerWorker(ZipFile zip, HashMap entries) {
|
||||
WebServerWorker(ZipFile zip, Map<String, ZipEntry> entries) {
|
||||
this.entries = entries;
|
||||
this.zip = zip;
|
||||
|
||||
|
||||
buf = new byte[BUF_SIZE];
|
||||
s = null;
|
||||
}
|
||||
@@ -468,7 +468,7 @@ outerloop:
|
||||
}
|
||||
|
||||
/* mapping of file extensions to content-types */
|
||||
static java.util.Hashtable map = new java.util.Hashtable();
|
||||
static Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
fillMap();
|
||||
|
||||
@@ -12,7 +12,8 @@ package processing.app.syntax;
|
||||
import javax.swing.KeyStroke;
|
||||
import java.awt.event.*;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
@@ -28,7 +29,7 @@ public class DefaultInputHandler extends InputHandler
|
||||
*/
|
||||
public DefaultInputHandler()
|
||||
{
|
||||
bindings = currentBindings = new Hashtable();
|
||||
bindings = currentBindings = new HashMap();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +89,7 @@ public class DefaultInputHandler extends InputHandler
|
||||
*/
|
||||
public void addKeyBinding(String keyBinding, ActionListener action)
|
||||
{
|
||||
Hashtable current = bindings;
|
||||
Map current = bindings;
|
||||
|
||||
StringTokenizer st = new StringTokenizer(keyBinding);
|
||||
while(st.hasMoreTokens())
|
||||
@@ -100,13 +101,13 @@ public class DefaultInputHandler extends InputHandler
|
||||
if(st.hasMoreTokens())
|
||||
{
|
||||
Object o = current.get(keyStroke);
|
||||
if(o instanceof Hashtable)
|
||||
current = (Hashtable)o;
|
||||
if(o instanceof Map)
|
||||
current = (Map)o;
|
||||
else
|
||||
{
|
||||
o = new Hashtable();
|
||||
o = new HashMap();
|
||||
current.put(keyStroke,o);
|
||||
current = (Hashtable)o;
|
||||
current = (Map)o;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -222,9 +223,9 @@ public class DefaultInputHandler extends InputHandler
|
||||
evt.consume();
|
||||
return;
|
||||
}
|
||||
else if(o instanceof Hashtable)
|
||||
else if(o instanceof Map)
|
||||
{
|
||||
currentBindings = (Hashtable)o;
|
||||
currentBindings = (Map)o;
|
||||
evt.consume();
|
||||
return;
|
||||
}
|
||||
@@ -257,9 +258,9 @@ public class DefaultInputHandler extends InputHandler
|
||||
Character.toUpperCase(c));
|
||||
Object o = currentBindings.get(keyStroke);
|
||||
|
||||
if(o instanceof Hashtable)
|
||||
if(o instanceof Map)
|
||||
{
|
||||
currentBindings = (Hashtable)o;
|
||||
currentBindings = (Map)o;
|
||||
return;
|
||||
}
|
||||
else if(o instanceof ActionListener)
|
||||
@@ -368,8 +369,8 @@ public class DefaultInputHandler extends InputHandler
|
||||
}
|
||||
|
||||
// private members
|
||||
private Hashtable bindings;
|
||||
private Hashtable currentBindings;
|
||||
private Map bindings;
|
||||
private Map currentBindings;
|
||||
|
||||
private DefaultInputHandler(DefaultInputHandler copy)
|
||||
{
|
||||
|
||||
@@ -90,11 +90,11 @@ public abstract class InputHandler extends KeyAdapter
|
||||
// Default action
|
||||
public static final ActionListener INSERT_CHAR = new insert_char();
|
||||
|
||||
private static Hashtable actions;
|
||||
private static Map<String, ActionListener> actions;
|
||||
|
||||
static
|
||||
{
|
||||
actions = new Hashtable();
|
||||
actions = new HashMap<String, ActionListener>();
|
||||
actions.put("backspace",BACKSPACE);
|
||||
actions.put("backspace-word",BACKSPACE_WORD);
|
||||
actions.put("delete",DELETE);
|
||||
@@ -149,10 +149,9 @@ public abstract class InputHandler extends KeyAdapter
|
||||
*/
|
||||
public static String getActionName(ActionListener listener)
|
||||
{
|
||||
Enumeration en = getActions();
|
||||
while(en.hasMoreElements())
|
||||
Set<String> set = getActions();
|
||||
for (String name : set)
|
||||
{
|
||||
String name = (String)en.nextElement();
|
||||
ActionListener _listener = getAction(name);
|
||||
if(_listener == listener) {
|
||||
return name;
|
||||
@@ -164,9 +163,9 @@ public abstract class InputHandler extends KeyAdapter
|
||||
/**
|
||||
* Returns an enumeration of all available actions.
|
||||
*/
|
||||
public static Enumeration getActions()
|
||||
public static Set<String> getActions()
|
||||
{
|
||||
return actions.keys();
|
||||
return actions.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.awt.geom.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
@@ -1754,7 +1754,7 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
//if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
|
||||
if (font != null) {
|
||||
Map<TextAttribute, Object> map =
|
||||
new Hashtable<TextAttribute, Object>();
|
||||
new HashMap<TextAttribute, Object>();
|
||||
map.put(TextAttribute.SIZE, size);
|
||||
map.put(TextAttribute.KERNING,
|
||||
TextAttribute.KERNING_ON);
|
||||
|
||||
@@ -3,7 +3,8 @@ package processing.core;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class is not part of the Processing API and should not be used
|
||||
@@ -159,7 +160,7 @@ public class PShapeOBJ extends PShape {
|
||||
ArrayList<PVector> coords,
|
||||
ArrayList<PVector> normals,
|
||||
ArrayList<PVector> texcoords) {
|
||||
Hashtable<String, Integer> mtlTable = new Hashtable<String, Integer>();
|
||||
Map<String, Integer> mtlTable = new HashMap<String, Integer>();
|
||||
int mtlIdxCur = -1;
|
||||
boolean readv, readvn, readvt;
|
||||
try {
|
||||
@@ -321,7 +322,7 @@ public class PShapeOBJ extends PShape {
|
||||
static protected void parseMTL(PApplet parent, String path,
|
||||
BufferedReader reader,
|
||||
ArrayList<OBJMaterial> materials,
|
||||
Hashtable<String, Integer> materialsHash) {
|
||||
Map<String, Integer> materialsHash) {
|
||||
try {
|
||||
String line;
|
||||
OBJMaterial currentMtl = null;
|
||||
|
||||
Reference in New Issue
Block a user