Router: more type arguments, for each

This commit is contained in:
str4d
2013-11-22 10:16:34 +00:00
parent 15bf94b479
commit e853d9a40b
7 changed files with 15 additions and 18 deletions

View File

@ -8,7 +8,7 @@ package net.i2p.router;
* *
*/ */
import java.util.Iterator; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import net.i2p.data.Hash; import net.i2p.data.Hash;
@ -49,9 +49,9 @@ public class ClientTunnelSettings {
writeToProperties(p); writeToProperties(p);
buf.append("Client tunnel settings:\n"); buf.append("Client tunnel settings:\n");
buf.append("====================================\n"); buf.append("====================================\n");
for (Iterator iter = p.keySet().iterator(); iter.hasNext(); ) { for (Map.Entry<Object, Object> entry : p.entrySet()) {
String name = (String)iter.next(); String name = (String) entry.getKey();
String val = p.getProperty(name); String val = (String) entry.getValue();
buf.append(name).append(" = [").append(val).append("]\n"); buf.append(name).append(" = [").append(val).append("]\n");
} }
buf.append("====================================\n"); buf.append("====================================\n");

View File

@ -3,8 +3,6 @@ package net.i2p.router;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.Iterator;
import net.i2p.data.DataFormatException; import net.i2p.data.DataFormatException;
import net.i2p.data.Destination; import net.i2p.data.Destination;
import net.i2p.data.Hash; import net.i2p.data.Hash;
@ -43,8 +41,7 @@ public class PersistentKeyRing extends KeyRing {
} }
private void addFromProperties() { private void addFromProperties() {
for (Iterator iter = _ctx.getPropertyNames().iterator(); iter.hasNext(); ) { for (String prop : _ctx.getPropertyNames()) {
String prop = (String) iter.next();
if (!prop.startsWith(PROP_PFX)) if (!prop.startsWith(PROP_PFX))
continue; continue;
String key = _ctx.getProperty(prop); String key = _ctx.getProperty(prop);

View File

@ -201,7 +201,7 @@ public class TunnelPoolSettings {
* @param prefix non-null * @param prefix non-null
*/ */
public void readFromProperties(String prefix, Map<Object, Object> props) { public void readFromProperties(String prefix, Map<Object, Object> props) {
for (Map.Entry e : props.entrySet()) { for (Map.Entry<Object, Object> e : props.entrySet()) {
String name = (String) e.getKey(); String name = (String) e.getKey();
String value = (String) e.getValue(); String value = (String) e.getValue();
if (name.startsWith(prefix)) { if (name.startsWith(prefix)) {
@ -250,7 +250,7 @@ public class TunnelPoolSettings {
props.setProperty(prefix + PROP_IP_RESTRICTION, ""+_IPRestriction); props.setProperty(prefix + PROP_IP_RESTRICTION, ""+_IPRestriction);
if (!_isInbound) if (!_isInbound)
props.setProperty(prefix + PROP_PRIORITY, Integer.toString(_priority)); props.setProperty(prefix + PROP_PRIORITY, Integer.toString(_priority));
for (Map.Entry e : _unknownOptions.entrySet()) { for (Map.Entry<Object, Object> e : _unknownOptions.entrySet()) {
String name = (String) e.getKey(); String name = (String) e.getKey();
String val = (String) e.getValue(); String val = (String) e.getValue();
props.setProperty(prefix + name, val); props.setProperty(prefix + name, val);
@ -264,7 +264,7 @@ public class TunnelPoolSettings {
writeToProperties("", p); writeToProperties("", p);
buf.append("Tunnel pool settings:\n"); buf.append("Tunnel pool settings:\n");
buf.append("====================================\n"); buf.append("====================================\n");
for (Map.Entry e : p.entrySet()) { for (Map.Entry<Object, Object> e : p.entrySet()) {
String name = (String) e.getKey(); String name = (String) e.getKey();
String val = (String) e.getValue(); String val = (String) e.getValue();
buf.append(name).append(" = [").append(val).append("]\n"); buf.append(name).append(" = [").append(val).append("]\n");

View File

@ -280,8 +280,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
*/ */
private void discoverService() { private void discoverService() {
synchronized (lock) { synchronized (lock) {
for (Iterator iter = _router.getDeviceList().iterator();iter.hasNext();) { for (Device current : _router.getDeviceList()) {
Device current = (Device)iter.next();
if (!current.getDeviceType().equals(WAN_DEVICE)) if (!current.getDeviceType().equals(WAN_DEVICE))
continue; continue;

View File

@ -69,7 +69,7 @@ class NTCPSendFinisher {
public CustomThreadPoolExecutor(int num) { public CustomThreadPoolExecutor(int num) {
// use unbounded queue, so maximumPoolSize and keepAliveTime have no effect // use unbounded queue, so maximumPoolSize and keepAliveTime have no effect
super(num, num, 1000, TimeUnit.MILLISECONDS, super(num, num, 1000, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue(), new CustomThreadFactory()); new LinkedBlockingQueue<Runnable>(), new CustomThreadFactory());
} }
} }

View File

@ -24,7 +24,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
super(context); super(context);
} }
public List<Hash> selectPeers(TunnelPoolSettings settings) { public List<Hash> selectPeers(TunnelPoolSettings settings) {
Log l = ctx.logManager().getLog(getClass()); Log l = ctx.logManager().getLog(getClass());
int length = getLength(settings); int length = getLength(settings);
if (length < 0) { if (length < 0) {
@ -34,7 +34,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
} }
if (false && shouldSelectExplicit(settings)) { if (false && shouldSelectExplicit(settings)) {
List rv = selectExplicit(settings, length); List<Hash> rv = selectExplicit(settings, length);
if (l.shouldLog(Log.DEBUG)) if (l.shouldLog(Log.DEBUG))
l.debug("Explicit peers selected: " + rv); l.debug("Explicit peers selected: " + rv);
return rv; return rv;

View File

@ -6,7 +6,7 @@ import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Properties;
import java.util.TreeSet; import java.util.TreeSet;
import net.i2p.data.Hash; import net.i2p.data.Hash;
@ -123,7 +123,8 @@ public class TunnelPool {
return; // don't override client specified settings return; // don't override client specified settings
} else { } else {
if (_settings.isExploratory()) { if (_settings.isExploratory()) {
Map props = _context.router().getConfigMap(); Properties props = new Properties();
props.putAll(_context.router().getConfigMap());
if (_settings.isInbound()) if (_settings.isInbound())
_settings.readFromProperties(TunnelPoolSettings.PREFIX_INBOUND_EXPLORATORY, props); _settings.readFromProperties(TunnelPoolSettings.PREFIX_INBOUND_EXPLORATORY, props);
else else