Core: type arguments, unused imports

This commit is contained in:
str4d committed 2013-11-20 04:02:28 +00:00
1 parent bacce17990
commit 89dcceefee
76 files changed
+174 -221

No files matched your search

+2 -2
View File
@@ -83,7 +83,7 @@ public abstract class Addresses {
boolean includeIPv6) {
boolean haveIPv4 = false;
boolean haveIPv6 = false;
SortedSet<String> rv = new TreeSet();
SortedSet<String> rv = new TreeSet<String>();
try {
InetAddress localhost = InetAddress.getLocalHost();
InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());
@@ -236,7 +236,7 @@ public abstract class Addresses {
} else {
size = 32;
}
_IPAddress = new LHMCache(size);
_IPAddress = new LHMCache<String, byte[]>(size);
}
/**
+3 -3
View File
@@ -52,7 +52,7 @@ import net.i2p.data.ByteArray;
public final class ByteCache {
//private static final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(ByteCache.class);
private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap(16);
private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap<Integer, ByteCache>(16);
/**
* max size in bytes of each cache
@@ -119,7 +119,7 @@ public final class ByteCache {
private ByteCache(int maxCachedEntries, int entrySize) {
if (_cache)
_available = new LinkedBlockingQueue(maxCachedEntries);
_available = new LinkedBlockingQueue<ByteArray>(maxCachedEntries);
_maxCached = maxCachedEntries;
_entrySize = entrySize;
_lastOverflow = -1;
@@ -131,7 +131,7 @@ public final class ByteCache {
if (_maxCached >= maxCachedEntries) return;
_maxCached = maxCachedEntries;
// make a bigger one, move the cached items over
Queue<ByteArray> newLBQ = new LinkedBlockingQueue(maxCachedEntries);
Queue<ByteArray> newLBQ = new LinkedBlockingQueue<ByteArray>(maxCachedEntries);
ByteArray ba;
while ((ba = _available.poll()) != null)
newLBQ.offer(ba);
+1 -1
View File
@@ -27,7 +27,7 @@ public class Clock implements Timestamper.UpdateListener {
public Clock(I2PAppContext context) {
_context = context;
_listeners = new CopyOnWriteArraySet();
_listeners = new CopyOnWriteArraySet<ClockUpdateListener>();
_startedOn = System.currentTimeMillis();
}
@@ -17,10 +17,10 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements Set<E> {
private final Map<E, Object> _map;
public ConcurrentHashSet() {
_map = new ConcurrentHashMap();
_map = new ConcurrentHashMap<E, Object>();
}
public ConcurrentHashSet(int capacity) {
_map = new ConcurrentHashMap(capacity);
_map = new ConcurrentHashMap<E, Object>(capacity);
}
@Override
+3 -3
View File
@@ -143,7 +143,7 @@ public class EepGet {
_postData = postData;
_bytesRemaining = -1;
_fetchHeaderTimeout = CONNECT_TIMEOUT;
_listeners = new ArrayList(1);
_listeners = new ArrayList<StatusListener>(1);
_etag = etag;
_lastModified = lastModified;
_etagOrig = etag;
@@ -190,7 +190,7 @@ public class EepGet {
lineLen = Integer.parseInt(args[++i]);
} else if (args[i].equals("-h")) {
if (extra == null)
extra = new ArrayList(2);
extra = new ArrayList<String>(2);
extra.add(args[++i]);
extra.add(args[++i]);
} else if (args[i].equals("-u")) {
@@ -1241,7 +1241,7 @@ public class EepGet {
*/
public void addHeader(String name, String value) {
if (_extraHeaders == null)
_extraHeaders = new ArrayList();
_extraHeaders = new ArrayList<String>();
_extraHeaders.add(name + ": " + value);
}
@@ -82,7 +82,7 @@ public interface EventDispatcher {
*
* @return A set of event names
*/
public Set getEvents();
public Set<String> getEvents();
/**
* Ignore further event notifications
@@ -35,8 +35,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class EventDispatcherImpl implements EventDispatcher {
private boolean _ignore = false;
private final Map<String, Object> _events = new ConcurrentHashMap(4);
private final List<EventDispatcher> _attached = new CopyOnWriteArrayList();
private final Map<String, Object> _events = new ConcurrentHashMap<String, Object>(4);
private final List<EventDispatcher> _attached = new CopyOnWriteArrayList<EventDispatcher>();
public EventDispatcher getEventDispatcher() {
return this;
@@ -72,8 +72,8 @@ public class EventDispatcherImpl implements EventDispatcher {
}
public Set<String> getEvents() {
if (_ignore) return Collections.EMPTY_SET;
return new HashSet(_events.keySet());
if (_ignore) return Collections.emptySet();
return new HashSet<String>(_events.keySet());
}
public void ignoreEvents() {
+3 -3
View File
@@ -106,7 +106,7 @@ public class FileUtil {
try {
byte buf[] = new byte[16*1024];
zip = new ZipFile(zipfile);
Enumeration entries = zip.entries();
Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
if (entry.getName().indexOf("..") != -1) {
@@ -215,7 +215,7 @@ public class FileUtil {
try {
byte buf[] = new byte[16*1024];
zip = new ZipFile(zipfile);
Enumeration entries = zip.entries();
Enumeration<? extends ZipEntry> entries = zip.entries();
boolean p200TestRequired = true;
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
@@ -358,7 +358,7 @@ public class FileUtil {
try {
fis = new FileInputStream(f);
BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
List lines = new ArrayList(maxNumLines > 0 ? maxNumLines : 64);
List<String> lines = new ArrayList<String>(maxNumLines > 0 ? maxNumLines : 64);
String line = null;
while ( (line = in.readLine()) != null) {
lines.add(line);
+3 -3
View File
@@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
*/
public class I2PAppThread extends I2PThread {
private final Set _threadListeners = new CopyOnWriteArraySet();
private final Set<OOMEventListener> _threadListeners = new CopyOnWriteArraySet<OOMEventListener>();
public I2PAppThread() {
super();
@@ -45,8 +45,8 @@ public class I2PAppThread extends I2PThread {
@Override
protected void fireOOM(OutOfMemoryError oom) {
for (Iterator iter = _threadListeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = (OOMEventListener)iter.next();
for (Iterator<OOMEventListener> iter = _threadListeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = iter.next();
listener.outOfMemory(oom);
}
}
@@ -1,9 +1,7 @@
package net.i2p.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyStore;
+3 -3
View File
@@ -26,7 +26,7 @@ public class I2PThread extends Thread {
* Logging removed, too much trouble with extra contexts
*/
//private volatile Log _log;
private static final Set _listeners = new CopyOnWriteArraySet();
private static final Set<OOMEventListener> _listeners = new CopyOnWriteArraySet<OOMEventListener>();
//private String _name;
//private Exception _createdBy;
@@ -112,8 +112,8 @@ public class I2PThread extends Thread {
****/
protected void fireOOM(OutOfMemoryError oom) {
for (Iterator iter = _listeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = (OOMEventListener)iter.next();
for (Iterator<OOMEventListener> iter = _listeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = iter.next();
listener.outOfMemory(oom);
}
}
@@ -24,7 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue;
* @since 0.7.9
*/
public class InternalServerSocket extends ServerSocket {
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4);
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap<Integer, InternalServerSocket>(4);
private final BlockingQueue<InternalSocket> _acceptQueue;
private final Integer _port;
private volatile boolean _running;
@@ -41,7 +41,7 @@ public class InternalServerSocket extends ServerSocket {
if (previous != null)
throw new IOException("Internal port in use: " + port);
_running = true;
_acceptQueue = new LinkedBlockingQueue();
_acceptQueue = new LinkedBlockingQueue<InternalSocket>();
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("Registered " + _port);
}
@@ -36,8 +36,8 @@ public class LogConsoleBuffer {
lim = Math.max(limit, 4);
// Add some extra room to minimize the chance of losing a message,
// since we are doing offer() below.
_buffer = new LinkedBlockingQueue(lim + 4);
_critBuffer = new LinkedBlockingQueue(lim + 4);
_buffer = new LinkedBlockingQueue<String>(lim + 4);
_critBuffer = new LinkedBlockingQueue<String>(lim + 4);
}
void add(String msg) {
@@ -64,7 +64,7 @@ public class LogConsoleBuffer {
* @return oldest first
*/
public List<String> getMostRecentMessages() {
return new ArrayList(_buffer);
return new ArrayList<String>(_buffer);
}
/**
@@ -75,7 +75,7 @@ public class LogConsoleBuffer {
* @return oldest first
*/
public List<String> getMostRecentCriticalMessages() {
return new ArrayList(_critBuffer);
return new ArrayList<String>(_critBuffer);
}
/**
+4 -4
View File
@@ -131,14 +131,14 @@ public class LogManager {
public LogManager(I2PAppContext context) {
_displayOnScreen = true;
_alreadyNoticedMissingConfig = false;
_limits = new ConcurrentHashSet();
_logs = new ConcurrentHashMap(128);
_limits = new ConcurrentHashSet<LogLimit>();
_logs = new ConcurrentHashMap<Object, Log>(128);
_defaultLimit = Log.ERROR;
_context = context;
_log = getLog(LogManager.class);
String location = context.getProperty(CONFIG_LOCATION_PROP, CONFIG_LOCATION_DEFAULT);
setConfig(location);
_records = new LinkedBlockingQueue(_logBufferSize);
_records = new LinkedBlockingQueue<LogRecord>(_logBufferSize);
_consoleBuffer = new LogConsoleBuffer(_consoleBufferSize);
// If we aren't in the router context, delay creating the LogWriter until required,
// so it doesn't create a log directory and log files unless there is output.
@@ -582,7 +582,7 @@ public class LogManager {
for (LogLimit limit : _limits) {
if (limit.matches(log)) {
if (limits == null)
limits = new ArrayList(4);
limits = new ArrayList<LogLimit>(4);
limits.add(limit);
}
}
@@ -35,7 +35,6 @@ import freenet.support.CPUInformation.UnknownCPUException;
import net.i2p.I2PAppContext;
import net.i2p.crypto.CryptoConstants;
import net.i2p.data.DataHelper;
/**
* <p>BigInteger that takes advantage of the jbigi library for the modPow operation,
@@ -627,8 +626,8 @@ public class NativeBigInteger extends BigInteger {
*/
private static List<String> getResourceList() {
if (_isAndroid)
return Collections.EMPTY_LIST;
List<String> rv = new ArrayList(8);
return Collections.emptyList();
List<String> rv = new ArrayList<String>(8);
String primary = getMiddleName2(true);
if (primary != null) {
if (_is64) {
@@ -708,7 +707,7 @@ public class NativeBigInteger extends BigInteger {
* @since 0.9.1
*/
private static Map<String, String> getCPUInfo() {
Map<String, String> rv = new HashMap(32);
Map<String, String> rv = new HashMap<String, String>(32);
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/cpuinfo"), "ISO-8859-1"), 4096);
+1 -1
View File
@@ -32,7 +32,7 @@ public class PortMapper {
* @param context unused for now
*/
public PortMapper(I2PAppContext context) {
_dir = new ConcurrentHashMap(8);
_dir = new ConcurrentHashMap<String, Integer>(8);
}
/**
@@ -14,7 +14,7 @@ public class ReusableGZIPInputStream extends ResettableGZIPInputStream {
private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available;
static {
if (ENABLE_CACHING)
_available = new LinkedBlockingQueue(8);
_available = new LinkedBlockingQueue<ReusableGZIPInputStream>(8);
else
_available = null;
}
@@ -25,7 +25,7 @@ public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
static {
if (ENABLE_CACHING)
_available = new LinkedBlockingQueue(16);
_available = new LinkedBlockingQueue<ReusableGZIPOutputStream>(16);
else
_available = null;
}
@@ -39,10 +39,8 @@ package net.i2p.util;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
@@ -50,8 +48,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyStore;
import java.security.GeneralSecurityException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Locale;
@@ -1,6 +1,5 @@
package net.i2p.util;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
@@ -16,7 +15,7 @@ import java.util.concurrent.LinkedBlockingQueue;
*/
public final class SimpleByteCache {
private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap(8);
private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap<Integer, SimpleByteCache>(8);
private static final int DEFAULT_SIZE = 64;
@@ -89,8 +88,8 @@ public final class SimpleByteCache {
*/
private Queue<byte[]> createQueue() {
if (_entrySize <= MAX_FOR_ABQ)
return new ArrayBlockingQueue(_maxCached);
return new LinkedBlockingQueue(_maxCached);
return new ArrayBlockingQueue<byte[]>(_maxCached);
return new LinkedBlockingQueue<byte[]>(_maxCached);
}
/**
+6 -6
View File
@@ -54,9 +54,9 @@ public class SimpleTimer {
private SimpleTimer(I2PAppContext context, String name) {
runn = new SimpleStore(true);
_log = context.logManager().getLog(SimpleTimer.class);
_events = new TreeMap();
_eventTimes = new HashMap(256);
_readyEvents = new ArrayList(4);
_events = new TreeMap<Long, TimedEvent>();
_eventTimes = new HashMap<TimedEvent, Long>(256);
_readyEvents = new ArrayList<TimedEvent>(4);
I2PThread runner = new I2PThread(new SimpleTimerRunner());
runner.setName(name);
runner.setDaemon(true);
@@ -155,8 +155,8 @@ public class SimpleTimer {
if ( (_events.size() != _eventTimes.size()) ) {
_log.error("Skewed events: " + _events.size() + " for " + _eventTimes.size());
for (Iterator iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) {
TimedEvent evt = (TimedEvent)iter.next();
for (Iterator<TimedEvent> iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) {
TimedEvent evt = iter.next();
Long when = _eventTimes.get(evt);
TimedEvent cur = _events.get(when);
if (cur != evt) {
@@ -209,7 +209,7 @@ public class SimpleTimer {
// private TimedEvent _recentEvents[] = new TimedEvent[5];
private class SimpleTimerRunner implements Runnable {
public void run() {
List<TimedEvent> eventsToFire = new ArrayList(1);
List<TimedEvent> eventsToFire = new ArrayList<TimedEvent>(1);
while(runn.getAnswer()) {
try {
synchronized (_events) {
+2 -2
View File
@@ -26,8 +26,8 @@ import net.i2p.util.ConcurrentHashSet;
public abstract class Translate {
public static final String PROP_LANG = "routerconsole.lang";
private static final String _localeLang = Locale.getDefault().getLanguage();
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(16);
private static final Set<String> _missing = new ConcurrentHashSet(16);
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap<String, ResourceBundle>(16);
private static final Set<String> _missing = new ConcurrentHashSet<String>(16);
/** use to look for untagged strings */
private static final String TEST_LANG = "xx";
private static final String TEST_STRING = "XXXX";
@@ -71,7 +71,7 @@ public class TranslateReader extends FilterReader {
super(new BufferedReader(new InputStreamReader(in, "UTF-8")));
_ctx = ctx;
_bundle = bundle;
_args = new ArrayList(4);
_args = new ArrayList<String>(4);
_inBuf = new StringBuilder(64);
_outBuf = new StringBuilder(64);
_argBuf = new StringBuilder(64);
@@ -415,7 +415,7 @@ public class TranslateReader extends FilterReader {
File[] listing = dir.listFiles();
if (listing == null)
throw new IOException();
filelist = new ArrayList(listing.length);
filelist = new ArrayList<String>(listing.length);
for (int i = 0; i < listing.length; i++) {
File f = listing[i];
if (!f.isDirectory())