propagate from branch 'i2p.i2p' (head d12a1fd746cd9314de5de5e1000c02cf4c59100d)

to branch 'i2p.i2p.str4d.cleanup' (head e20c143dd50a9c802999068a95e12198b07e4c36)
This commit is contained in:
str4d
2013-11-25 22:36:27 +00:00
64 changed files with 161 additions and 219 deletions

View File

@@ -15,7 +15,7 @@
*/
package net.i2p.BOB;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
/**
@@ -39,10 +39,8 @@ public class Lifted {
*
**/
public static void copyProperties(Properties src_prop, Properties dest_prop) {
for (Enumeration propertyNames = src_prop.propertyNames();
propertyNames.hasMoreElements();) {
Object key = propertyNames.nextElement();
dest_prop.put(key, src_prop.get(key));
for (Map.Entry<Object, Object> e : src_prop.entrySet()) {
dest_prop.put((String)e.getKey(), (String)e.getValue());
}
}
}

View File

@@ -7,9 +7,6 @@ package net.i2p.desktopgui;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.GraphicsEnvironment;
import net.i2p.I2PAppContext;
import net.i2p.desktopgui.router.RouterManager;
import net.i2p.desktopgui.util.*;
import net.i2p.util.Log;

View File

@@ -1,28 +1,15 @@
package net.i2p.desktopgui;
import java.awt.AWTException;
import java.awt.Desktop;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.Desktop.Action;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.swing.SwingWorker;
import net.i2p.desktopgui.i18n.DesktopguiTranslator;
import net.i2p.desktopgui.router.RouterManager;
import net.i2p.desktopgui.util.BrowseException;
import net.i2p.desktopgui.util.ConfigurationManager;
import net.i2p.desktopgui.util.I2PDesktop;
import net.i2p.util.Log;
/**

View File

@@ -32,7 +32,6 @@ public class DesktopguiConfigurationFrame extends javax.swing.JFrame {
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

View File

@@ -5,8 +5,6 @@ import java.io.IOException;
import org.tanukisoftware.wrapper.WrapperManager;
import net.i2p.I2PAppContext;
import net.i2p.desktopgui.i18n.DesktopguiTranslator;
import net.i2p.desktopgui.util.ConfigurationManager;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;

View File

@@ -1,13 +1,8 @@
package net.i2p.desktopgui.util;
import java.awt.Desktop;
import java.awt.TrayIcon;
import java.awt.Desktop.Action;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import net.i2p.desktopgui.router.RouterManager;
import net.i2p.util.Log;
public class I2PDesktop {

View File

@@ -366,7 +366,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
* @since 0.9.1
*/
public void setClientOptions(Properties opts) {
for (Iterator iter = _clientOptions.keySet().iterator(); iter.hasNext();) {
for (Iterator<Object> iter = _clientOptions.keySet().iterator(); iter.hasNext();) {
Object key = iter.next();
if (!opts.containsKey(key))
iter.remove();

View File

@@ -365,7 +365,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
*/
private void buildSocketMap(Properties props) {
_socketMap.clear();
for (Map.Entry e : props.entrySet()) {
for (Map.Entry<Object, Object> e : props.entrySet()) {
String key = (String) e.getKey();
if (key.startsWith("targetForPort.")) {
key = key.substring("targetForPort.".length());

View File

@@ -413,7 +413,7 @@ public class TunnelController implements Logging {
*/
public Properties getClientOptionProps() {
Properties opts = new Properties();
for (Map.Entry e : _config.entrySet()) {
for (Map.Entry<Object, Object> e : _config.entrySet()) {
String key = (String) e.getKey();
if (key.startsWith("option.")) {
key = key.substring("option.".length());
@@ -471,7 +471,7 @@ public class TunnelController implements Logging {
*/
public void setConfig(Properties config, String prefix) {
Properties props = new Properties();
for (Map.Entry e : config.entrySet()) {
for (Map.Entry<Object, Object> e : config.entrySet()) {
String key = (String) e.getKey();
if (key.startsWith(prefix)) {
key = key.substring(prefix.length());
@@ -516,7 +516,7 @@ public class TunnelController implements Logging {
*/
public Properties getConfig(String prefix) {
Properties rv = new Properties();
for (Map.Entry e : _config.entrySet()) {
for (Map.Entry<Object, Object> e : _config.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
rv.setProperty(prefix + key, val);
@@ -538,7 +538,7 @@ public class TunnelController implements Logging {
*/
public String getClientOptions() {
StringBuilder opts = new StringBuilder(64);
for (Map.Entry e : _config.entrySet()) {
for (Map.Entry<Object, Object> e : _config.entrySet()) {
String key = (String) e.getKey();
if (key.startsWith("option.")) {
key = key.substring("option.".length());

View File

@@ -70,7 +70,7 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase {
private void parseOptions() {
Properties opts = getTunnel().getClientOptions();
proxies = new HashMap<String, List<String>>(1);
for (Map.Entry e : opts.entrySet()) {
for (Map.Entry<Object, Object> e : opts.entrySet()) {
String prop = (String)e.getKey();
if ((!prop.startsWith(PROP_PROXY_PREFIX)) || prop.length() <= PROP_PROXY_PREFIX.length())
continue;

View File

@@ -373,7 +373,7 @@ public class EditBean extends IndexBean {
boolean isMD5Proxy = "httpclient".equals(tun.getType()) ||
"connectclient".equals(tun.getType());
Map<String, String> sorted = new TreeMap<String, String>();
for (Map.Entry e : opts.entrySet()) {
for (Map.Entry<Object, Object> e : opts.entrySet()) {
String key = (String)e.getKey();
if (_noShowSet.contains(key))
continue;

View File

@@ -5,7 +5,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -202,7 +201,7 @@ public class I2PSocketManagerFactory {
if (opts == null)
opts = new Properties();
Properties syscopy = (Properties) System.getProperties().clone();
for (Map.Entry e : syscopy.entrySet()) {
for (Map.Entry<Object, Object> e : syscopy.entrySet()) {
String name = (String) e.getKey();
if (!opts.containsKey(name))
opts.setProperty(name, (String) e.getValue());

View File

@@ -418,8 +418,8 @@ public class NetDbRenderer {
int cost = addr.getCost();
if (!((style.equals("SSU") && cost == 5) || (style.equals("NTCP") && cost == 10)))
buf.append('[').append(_("cost")).append('=').append("" + cost).append("] ");
Map p = addr.getOptionsMap();
for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) {
Map<Object, Object> p = addr.getOptionsMap();
for (Map.Entry<Object, Object> e : p.entrySet()) {
String name = (String) e.getKey();
String val = (String) e.getValue();
buf.append('[').append(_(DataHelper.stripHTML(name))).append('=').append(DataHelper.stripHTML(val)).append("] ");
@@ -428,8 +428,8 @@ public class NetDbRenderer {
buf.append("</td></tr>\n");
if (full) {
buf.append("<tr><td>" + _("Stats") + ": <br><code>");
Map p = info.getOptionsMap();
for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) {
Map<Object, Object> p = info.getOptionsMap();
for (Map.Entry<Object, Object> e : p.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br>\n");

View File

@@ -832,7 +832,7 @@ public class PluginStarter implements Runnable {
*/
private static void addPath(URL u) throws Exception {
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class urlClass = URLClassLoader.class;
Class<URLClassLoader> urlClass = URLClassLoader.class;
Method method = urlClass.getDeclaredMethod("addURL", new Class[]{URL.class});
method.setAccessible(true);
method.invoke(urlClassLoader, new Object[]{u});

View File

@@ -244,8 +244,8 @@ public class SAMBridge implements Runnable, ClientApp {
FileOutputStream out = null;
try {
out = new FileOutputStream(persistFilename);
for (Iterator iter = nameToPrivKeys.keySet().iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
for (Iterator<String> iter = nameToPrivKeys.keySet().iterator(); iter.hasNext(); ) {
String name = iter.next();
String privKeys = nameToPrivKeys.get(name);
out.write(name.getBytes());
out.write('=');

View File

@@ -381,15 +381,15 @@ public class SAMStreamSession {
*/
private void removeAllSocketHandlers() {
Integer id;
Set keySet;
Iterator iter;
Set<Integer> keySet;
Iterator<Integer> iter;
synchronized (handlersMapLock) {
keySet = handlersMap.keySet();
iter = keySet.iterator();
while (iter.hasNext()) {
id = (Integer)iter.next();
id = iter.next();
handlersMap.get(id).stopRunning();
sendersMap.get(id).shutDownGracefully();
}

View File

@@ -11,7 +11,7 @@ package net.i2p.sam;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -188,14 +188,13 @@ public class SAMUtils {
/* Dump a Properties object in an human-readable form */
private static String dumpProperties(Properties props) {
Enumeration names = props.propertyNames();
StringBuilder builder = new StringBuilder();
String key, val;
boolean firstIter = true;
while (names.hasMoreElements()) {
key = (String)names.nextElement();
val = props.getProperty(key);
for (Map.Entry<Object, Object> entry : props.entrySet()) {
key = (String) entry.getKey();
val = (String) entry.getValue();
if (!firstIter) {
builder.append(";");

View File

@@ -8,7 +8,6 @@ package net.i2p.sam;
*
*/
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ConnectException;
@@ -16,12 +15,9 @@ import java.net.NoRouteToHostException;
import java.util.Properties;
import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.client.streaming.I2PServerSocket;
import net.i2p.client.streaming.I2PSocket;
import net.i2p.client.streaming.I2PSocketManagerFactory;
import net.i2p.client.streaming.I2PSocketOptions;
import net.i2p.data.Base64;
import net.i2p.data.DataFormatException;
import net.i2p.data.Destination;
import net.i2p.util.I2PAppThread;

View File

@@ -15,7 +15,6 @@ import net.i2p.client.I2PSession;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
import net.i2p.util.SimpleTimer2;
@@ -125,7 +124,7 @@ class Connection {
// FIXME pass through a passive flush delay setting as the 4th arg
_outputStream = new MessageOutputStream(_context, timer, _receiver, (opts == null ? Packet.MAX_PAYLOAD_SIZE : opts.getMaxMessageSize()));
_timer = timer;
_outboundPackets = new TreeMap();
_outboundPackets = new TreeMap<Long, PacketLocal>();
if (opts != null) {
_localPort = opts.getLocalPort();
_remotePort = opts.getPort();
@@ -469,7 +468,7 @@ class Connection {
}
if (!nacked) { // aka ACKed
if (acked == null)
acked = new ArrayList(8);
acked = new ArrayList<PacketLocal>(8);
PacketLocal ackedPacket = e.getValue();
ackedPacket.ackReceived();
acked.add(ackedPacket);

View File

@@ -6,7 +6,6 @@ import java.util.concurrent.TimeUnit;
import net.i2p.I2PAppContext;
import net.i2p.data.Destination;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
/**

View File

@@ -767,13 +767,13 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
// but avoid concurrent modification just in case
Set<Hash> accessList, blackList;
if (accessListEnabled)
accessList = new HashSet();
accessList = new HashSet<Hash>();
else
accessList = Collections.EMPTY_SET;
accessList = Collections.emptySet();
if (blackListEnabled)
blackList = new HashSet();
blackList = new HashSet<Hash>();
else
blackList = Collections.EMPTY_SET;
blackList = Collections.emptySet();
if (accessListEnabled || blackListEnabled) {
String hashes = opts.getProperty(PROP_ACCESS_LIST);
if (hashes == null)

View File

@@ -7,7 +7,6 @@ import net.i2p.I2PException;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
/**

View File

@@ -8,6 +8,7 @@ import net.i2p.I2PAppContext;
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
import net.i2p.client.I2PSessionMuxedListener;
import net.i2p.client.streaming.I2PSocketManager.DisconnectListener;
import net.i2p.util.Log;
/**
@@ -25,7 +26,7 @@ class MessageHandler implements I2PSessionMuxedListener {
public MessageHandler(I2PAppContext ctx, ConnectionManager mgr) {
_manager = mgr;
_context = ctx;
_listeners = new CopyOnWriteArraySet();
_listeners = new CopyOnWriteArraySet<DisconnectListener>();
_log = ctx.logManager().getLog(MessageHandler.class);
_context.statManager().createRateStat("stream.packetReceiveFailure", "When do we fail to decrypt or otherwise receive a packet sent to us?", "Stream", new long[] { 60*60*1000, 24*60*60*1000 });
}

View File

@@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -63,11 +62,11 @@ class MessageInputStream extends InputStream {
public MessageInputStream(I2PAppContext ctx) {
_log = ctx.logManager().getLog(MessageInputStream.class);
_readyDataBlocks = new ArrayList(4);
_readyDataBlocks = new ArrayList<ByteArray>(4);
_highestReadyBlockId = -1;
_highestBlockId = -1;
_readTimeout = -1;
_notYetReadyBlocks = new HashMap(4);
_notYetReadyBlocks = new HashMap<Long, ByteArray>(4);
_dataLock = new Object();
//_cache = ByteCache.getInstance(128, Packet.MAX_PAYLOAD_SIZE);
}
@@ -110,7 +109,7 @@ class MessageInputStream extends InputStream {
// ACK
} else {
if (ids == null)
ids = new ArrayList(4);
ids = new ArrayList<Long>(4);
ids.add(l);
}
}

View File

@@ -2,8 +2,6 @@ package net.i2p.client.streaming;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;
import net.i2p.I2PAppContext;
import net.i2p.I2PException;
import net.i2p.data.Destination;

View File

@@ -9,7 +9,6 @@ import java.io.OutputStream;
import net.i2p.I2PAppContext;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
/**
* Write a standard pcap file with a "TCP" packet that can be analyzed with

View File

@@ -36,8 +36,8 @@ class SchedulerChooser {
return _nullScheduler;
}
private List createSchedulers() {
List rv = new ArrayList(8);
private List<TaskScheduler> createSchedulers() {
List<TaskScheduler> rv = new ArrayList<TaskScheduler>(8);
rv.add(new SchedulerHardDisconnected(_context));
rv.add(new SchedulerPreconnect(_context));
rv.add(new SchedulerConnecting(_context));

View File

@@ -2,7 +2,6 @@ package net.i2p.client.streaming;
import net.i2p.I2PAppContext;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
/**
* Base scheduler

View File

@@ -6,7 +6,6 @@ import org.junit.Test;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PSession;
import net.i2p.util.Log;

View File

@@ -6,7 +6,6 @@ import org.junit.Before;
import org.junit.Test;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PSession;
import net.i2p.util.Log;

View File

@@ -6,7 +6,6 @@ import java.util.Properties;
import org.junit.Test;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PClientFactory;
import net.i2p.client.I2PSession;
import net.i2p.data.Destination;

View File

@@ -9,7 +9,6 @@ import org.junit.Test;
import net.i2p.I2PAppContext;
import net.i2p.client.I2PSession;
import net.i2p.data.Base64;
import net.i2p.util.Log;
/**

View File

@@ -59,7 +59,7 @@ public class MessageInputStreamTest extends TestCase {
_context.random().nextBytes(orig);
MessageInputStream in = new MessageInputStream(_context);
ArrayList order = new ArrayList(32);
ArrayList<Integer> order = new ArrayList<Integer>(32);
for (int i = 0; i < orig.length / 1024; i++)
order.add(new Integer(i));
Collections.shuffle(order);
@@ -92,7 +92,7 @@ public class MessageInputStreamTest extends TestCase {
MessageInputStream in = new MessageInputStream(_context);
for (int n = 0; n < 3; n++) {
ArrayList order = new ArrayList(32);
ArrayList<Integer> order = new ArrayList<Integer>(32);
for (int i = 0; i < orig.length / 1024; i++)
order.add(new Integer(i));
Collections.shuffle(order);
@@ -126,7 +126,7 @@ public class MessageInputStreamTest extends TestCase {
_context.random().nextBytes(orig);
MessageInputStream in = new MessageInputStream(_context);
ArrayList order = new ArrayList(32);
ArrayList<Integer> order = new ArrayList<Integer>(32);
for (int i = 0; i < orig.length / 1024; i++)
order.add(new Integer(i));
Collections.shuffle(order);

View File

@@ -30,9 +30,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import net.i2p.data.DataFormatException;
@@ -151,10 +151,9 @@ public class AddressbookBean extends BaseBean
fis = new FileInputStream( getFileName() );
addressbook.load( fis );
LinkedList<AddressBean> list = new LinkedList<AddressBean>();
Enumeration e = addressbook.keys();
while( e.hasMoreElements() ) {
String name = (String)e.nextElement();
String destination = addressbook.getProperty( name );
for( Map.Entry<Object, Object> entry : addressbook.entrySet() ) {
String name = (String) entry.getKey();
String destination = (String) entry.getValue();
if( filter != null && filter.length() > 0 ) {
if( filter.compareTo( "0-9" ) == 0 ) {
char first = name.charAt(0);

View File

@@ -88,7 +88,7 @@ public class ConfigBean implements Serializable {
// use loadProps to trim
Properties props = new OrderedProperties();
DataHelper.loadProps(props, file);
for (Map.Entry e : props.entrySet()) {
for (Map.Entry<Object, Object> e : props.entrySet()) {
buf.append((String) e.getKey()).append('=')
.append((String) e.getValue()).append('\n');
}

View File

@@ -41,7 +41,7 @@ import java.util.Iterator;
*
* @author susi
*/
public class Folder {
public class Folder<O extends Object> {
public static final String PAGESIZE = "pager.pagesize";
public static final int DEFAULT_PAGESIZE = 10;
@@ -50,10 +50,10 @@ public class Folder {
public static final boolean UP = true;
private int pages, pageSize, currentPage;
private Object[] unsortedElements, elements;
private Hashtable sorter;
private O[] unsortedElements, elements;
private Hashtable<String, Comparator<O>> sorter;
private boolean sortingDirection;
Comparator currentSorter;
Comparator<O> currentSorter;
public Folder()
{
@@ -61,7 +61,7 @@ public class Folder {
pageSize = 0;
currentPage = 1;
unsortedElements = null;
sorter = new Hashtable();
sorter = new Hashtable<String, Comparator<O>>();
sortingDirection = UP;
currentSorter = null;
}
@@ -129,12 +129,13 @@ public class Folder {
* @param source Array to copy.
* @return Copy of source.
*/
private Object[] copyArray( Object[] source )
@SuppressWarnings("unchecked")
private O[] copyArray( O[] source )
{
Object[] destination = new Object[source.length];
for( int i = 0; i < source.length; i++ )
destination[i] = source[i];
return destination;
return (O[])destination;
}
/**
* Recalculates variables.
@@ -171,9 +172,9 @@ public class Folder {
/**
* Set the array of objects the folder should manage.
*
* @param elements Array of Objects.
* @param elements Array of Os.
*/
public void setElements( Object[] elements )
public void setElements( O[] elements )
{
this.unsortedElements = elements;
if( currentSorter != null )
@@ -187,9 +188,9 @@ public class Folder {
* Returns an iterator containing the elements on the current page.
* @return Iterator containing the elements on the current page.
*/
public Iterator currentPageIterator()
public Iterator<O> currentPageIterator()
{
ArrayList list = new ArrayList();
ArrayList<O> list = new ArrayList<O>();
if( elements != null ) {
int pageSize = getPageSize();
int offset = ( currentPage - 1 ) * pageSize;
@@ -249,7 +250,7 @@ public class Folder {
* @param id ID to identify the Comparator with @link sortBy()
* @param sorter a Comparator to sort the Array given by @link setElements()
*/
public void addSorter( String id, Comparator sorter )
public void addSorter( String id, Comparator<O> sorter )
{
this.sorter.put( id, sorter );
}
@@ -263,7 +264,7 @@ public class Folder {
*/
public void sortBy( String id )
{
currentSorter = (Comparator)sorter.get( id );
currentSorter = sorter.get( id );
sort();
}
@@ -273,9 +274,9 @@ public class Folder {
* @param x Position of the element on the current page.
* @return Element on the current page on the given position.
*/
public Object getElementAtPosXonCurrentPage( int x )
public O getElementAtPosXonCurrentPage( int x )
{
Object result = null;
O result = null;
if( elements != null ) {
int pageSize = getPageSize();
int offset = ( currentPage - 1 ) * pageSize;
@@ -306,7 +307,7 @@ public class Folder {
*
* @return First element.
*/
public Object getFirstElement()
public O getFirstElement()
{
/*
* sorting direction is taken into account from getElement
@@ -319,7 +320,7 @@ public class Folder {
*
* @return Last element.
*/
public Object getLastElement()
public O getLastElement()
{
/*
* sorting direction is taken into account from getElement
@@ -333,7 +334,7 @@ public class Folder {
* @param element
* @return index
*/
private int getIndexOf( Object element )
private int getIndexOf( O element )
{
if( elements != null ) {
for( int i = 0; i < elements.length; i++ )
@@ -350,9 +351,9 @@ public class Folder {
* @param element
* @return The next element
*/
public Object getNextElement( Object element )
public O getNextElement( O element )
{
Object result = null;
O result = null;
int i = getIndexOf( element );
@@ -371,9 +372,9 @@ public class Folder {
* @param element
* @return The previous element
*/
public Object getPreviousElement( Object element )
public O getPreviousElement( O element )
{
Object result = null;
O result = null;
int i = getIndexOf( element );
@@ -390,9 +391,9 @@ public class Folder {
* @param i
* @return Element at index i
*/
private Object getElement( int i )
private O getElement( int i )
{
Object result = null;
O result = null;
if( elements != null ) {
if( sortingDirection == DOWN )
@@ -424,7 +425,7 @@ public class Folder {
*
* @param element
*/
public boolean isLastElement( Object element )
public boolean isLastElement( O element )
{
if( elements == null )
return false;
@@ -437,7 +438,7 @@ public class Folder {
*
* @param element
*/
public boolean isFirstElement( Object element )
public boolean isFirstElement( O element )
{
if( elements == null )
return false;

View File

@@ -49,7 +49,6 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -316,7 +315,7 @@ public class WebMail extends HttpServlet
int state, smtpPort;
POP3MailBox mailbox;
MailCache mailCache;
Folder folder;
Folder<String> folder;
String user, pass, host, error, info;
String replyTo, replyCC;
String subject, body, showUIDL;
@@ -413,8 +412,7 @@ public class WebMail extends HttpServlet
if( mailPart.multipart ) {
if( mailPart.type.compareTo( "multipart/alternative" ) == 0 ) {
MailPart chosen = null;
for( ListIterator li = mailPart.parts.listIterator(); li.hasNext(); ) {
MailPart subPart = (MailPart)li.next();
for( MailPart subPart : mailPart.parts ) {
if( subPart.type != null && subPart.type.compareTo( "text/plain" ) == 0 )
chosen = subPart;
}
@@ -423,16 +421,12 @@ public class WebMail extends HttpServlet
return;
}
}
for( ListIterator li = mailPart.parts.listIterator(); li.hasNext(); ) {
MailPart part = (MailPart)li.next();
for( MailPart part : mailPart.parts )
showPart( out, part, level + 1, html );
}
}
else if( mailPart.message ) {
for( ListIterator li = mailPart.parts.listIterator(); li.hasNext(); ) {
MailPart part = (MailPart)li.next();
for( MailPart part : mailPart.parts )
showPart( out, part, level + 1, html );
}
}
else {
boolean showBody = false;
@@ -627,7 +621,7 @@ public class WebMail extends HttpServlet
sessionObject.smtpPort = smtpPortNo;
sessionObject.state = STATE_LIST;
sessionObject.mailCache = new MailCache( sessionObject.mailbox );
sessionObject.folder = new Folder();
sessionObject.folder = new Folder<String>();
sessionObject.folder.setElements( sessionObject.mailbox.getUIDLs() );
sessionObject.folder.addSorter( SORT_ID, new IDSorter( sessionObject.mailCache ) );
sessionObject.folder.addSorter( SORT_SENDER, new SenderSorter( sessionObject.mailCache ) );
@@ -1052,8 +1046,8 @@ public class WebMail extends HttpServlet
return part;
if( part.multipart || part.message ) {
for( Iterator it = part.parts.iterator(); it.hasNext(); ) {
MailPart subPart = getMailPartFromHashCode( (MailPart)it.next(), hashCode );
for( MailPart p : part.parts ) {
MailPart subPart = getMailPartFromHashCode( p, hashCode );
if( subPart != null )
return subPart;
}
@@ -1275,7 +1269,7 @@ public class WebMail extends HttpServlet
if( sessionObject.state == STATE_LIST ) {
processFolderButtons( sessionObject, request );
for( Iterator it = sessionObject.folder.currentPageIterator(); it != null && it.hasNext(); ) {
for( Iterator<String> it = sessionObject.folder.currentPageIterator(); it != null && it.hasNext(); ) {
String uidl = (String)it.next();
Mail mail = sessionObject.mailCache.getMail( uidl, MailCache.FETCH_HEADER );
if( mail != null && mail.error.length() > 0 ) {
@@ -1525,8 +1519,7 @@ public class WebMail extends HttpServlet
}
if( multipart ) {
for( Iterator it = sessionObject.attachments.iterator(); it.hasNext(); ) {
Attachment attachment = (Attachment)it.next();
for( Attachment attachment : sessionObject.attachments ) {
body.append( "\r\n--" + boundary + "\r\nContent-type: " + attachment.getContentType() + "\r\nContent-Disposition: attachment; filename=\"" + attachment.getFileName() + "\"\r\nContent-Transfer-Encoding: " + attachment.getTransferEncoding() + "\r\n\r\n" );
body.append( attachment.getData() );
}
@@ -1620,12 +1613,11 @@ public class WebMail extends HttpServlet
if( sessionObject.attachments != null && !sessionObject.attachments.isEmpty() ) {
boolean wroteHeader = false;
for( Iterator it = sessionObject.attachments.iterator(); it.hasNext(); ) {
for( Attachment attachment : sessionObject.attachments ) {
if( !wroteHeader ) {
out.println( "<tr><td colspan=\"2\" align=\"center\">" + _("Attachments:") + "</td></tr>" );
wroteHeader = true;
}
Attachment attachment = (Attachment)it.next();
out.println( "<tr><td colspan=\"2\" align=\"center\"><input type=\"checkbox\" class=\"optbox\" name=\"check" + attachment.hashCode() + "\" value=\"1\">&nbsp;" + attachment.getFileName() + "</td></tr>");
}
}
@@ -1687,7 +1679,7 @@ public class WebMail extends HttpServlet
thSpacer + "<th>" + sortHeader( SORT_SIZE, _("Size"), sessionObject.imgPath ) + "</th></tr>" );
int bg = 0;
int i = 0;
for( Iterator it = sessionObject.folder.currentPageIterator(); it != null && it.hasNext(); ) {
for( Iterator<String> it = sessionObject.folder.currentPageIterator(); it != null && it.hasNext(); ) {
String uidl = (String)it.next();
Mail mail = sessionObject.mailCache.getMail( uidl, MailCache.FETCH_HEADER );
String link = "<a href=\"" + myself + "?" + SHOW + "=" + i + "\">";

View File

@@ -46,7 +46,7 @@ public class EncodingFactory {
String[] classNames = list.split( ";" );
for( int i = 0; i < classNames.length; i++ ) {
try {
Class c = Class.forName( classNames[i] );
Class<?> c = Class.forName( classNames[i] );
Encoding e = (Encoding)c.newInstance();
encodings.put( e.getName(), e );
Debug.debug( Debug.DEBUG, "Registered " + e.getClass().getName() );

View File

@@ -59,8 +59,6 @@ public class POP3MailBox {
private Object synchronizer = null;
private Object[] uidls = null;
/**
* @param host
* @param port
@@ -275,7 +273,6 @@ public class POP3MailBox {
uidlToID.clear();
uidlList.clear();
uidls = null;
readBuffer = sendCmdNa( "UIDL", DEFAULT_BUFSIZE );
if( readBuffer != null ) {
@@ -295,7 +292,6 @@ public class POP3MailBox {
}
}
}
uidls = uidlList.toArray();
}
else {
System.err.println( "Error getting UIDL list from pop3 server.");
@@ -350,7 +346,6 @@ public class POP3MailBox {
uidlList.clear();
uidlToID.clear();
sizes.clear();
uidls = null;
mails = 0;
}
/**
@@ -649,7 +644,7 @@ public class POP3MailBox {
private int getIDfromUIDL( String uidl )
{
int result = -1;
Integer intObject = (Integer)uidlToID.get( uidl );
Integer intObject = uidlToID.get( uidl );
if( intObject != null ) {
result = intObject.intValue();
}
@@ -662,15 +657,15 @@ public class POP3MailBox {
*/
public String getUIDLfromID( int id )
{
return (String)uidlList.get( id );
return uidlList.get( id );
}
/**
*
* @return A list of the available UIDLs.
*/
public Object[] getUIDLs()
public String[] getUIDLs()
{
return uidls;
return uidlList.toArray(new String[uidlList.size()]);
}
/**
*

View File

@@ -535,11 +535,12 @@ public class I2PAppContext {
*
* @return set of Strings containing the names of defined system properties
*/
public Set<String> getPropertyNames() {
@SuppressWarnings({ "unchecked", "rawtypes" })
public Set<String> getPropertyNames() {
// clone to avoid ConcurrentModificationException
Set names = new HashSet(((Properties) System.getProperties().clone()).keySet());
Set<String> names = new HashSet<String>((Set<String>) (Set) ((Properties) System.getProperties().clone()).keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
if (_overrideProps != null)
names.addAll(_overrideProps.keySet());
names.addAll((Set<String>) (Set) _overrideProps.keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
return names;
}

View File

@@ -38,8 +38,8 @@ public class MetaNamingService extends DummyNamingService {
_services = new CopyOnWriteArrayList<NamingService>();
while (tok.hasMoreTokens()) {
try {
Class cls = Class.forName(tok.nextToken());
Constructor con = cls.getConstructor(new Class[] { I2PAppContext.class });
Class<?> cls = Class.forName(tok.nextToken());
Constructor<?> con = cls.getConstructor(new Class[] { I2PAppContext.class });
addNamingService((NamingService)con.newInstance(new Object[] { context }), false);
} catch (Exception ex) {
}

View File

@@ -462,8 +462,8 @@ public abstract class NamingService {
NamingService instance = null;
String impl = context.getProperty(PROP_IMPL, DEFAULT_IMPL);
try {
Class cls = Class.forName(impl);
Constructor con = cls.getConstructor(new Class[] { I2PAppContext.class });
Class<?> cls = Class.forName(impl);
Constructor<?> con = cls.getConstructor(new Class[] { I2PAppContext.class });
instance = (NamingService)con.newInstance(new Object[] { context });
} catch (Exception ex) {
Log log = context.logManager().getLog(NamingService.class);

View File

@@ -41,8 +41,8 @@ class ECConstants {
boolean loaded;
if (Security.getProvider("BC") == null) {
try {
Class cls = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
Constructor con = cls.getConstructor(new Class[0]);
Class<?> cls = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
Constructor<?> con = cls.getConstructor(new Class[0]);
Provider bc = (Provider)con.newInstance(new Object[0]);
Security.addProvider(bc);
log("Added BC provider");

View File

@@ -226,7 +226,7 @@ public class DataHelper {
p = props;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream(p.size() * 64);
for (Map.Entry entry : p.entrySet()) {
for (Map.Entry<Object, Object> entry : p.entrySet()) {
String key = (String) entry.getKey();
String val = (String) entry.getValue();
if (utf8)
@@ -273,7 +273,7 @@ public class DataHelper {
OrderedProperties p = new OrderedProperties();
p.putAll(props);
ByteArrayOutputStream baos = new ByteArrayOutputStream(p.size() * 64);
for (Map.Entry entry : p.entrySet()) {
for (Map.Entry<Object, Object> entry : p.entrySet()) {
String key = (String) entry.getKey();
String val = (String) entry.getValue();
writeStringUTF8(baos, key);
@@ -367,7 +367,7 @@ public class DataHelper {
* (unless the options param is an OrderedProperties)
*/
public static String toString(Properties options) {
return toString((Map) options);
return toString((Map<?, ?>) options);
}
/**
@@ -378,7 +378,7 @@ public class DataHelper {
public static String toString(Map<?, ?> options) {
StringBuilder buf = new StringBuilder();
if (options != null) {
for (Map.Entry entry : options.entrySet()) {
for (Map.Entry<?, ?> entry : options.entrySet()) {
String key = (String) entry.getKey();
String val = (String) entry.getValue();
buf.append("[").append(key).append("] = [").append(val).append("]");
@@ -470,7 +470,7 @@ public class DataHelper {
try {
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8")));
out.println("# NOTE: This I2P config file must use UTF-8 encoding");
for (Map.Entry entry : props.entrySet()) {
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String name = (String) entry.getKey();
String val = (String) entry.getValue();
if (name.contains("#") ||

View File

@@ -6,7 +6,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -402,8 +401,7 @@ public class PrivateKeyFile {
System.out.println("Attempting to verify using " + sz + " hosts, this may take a while");
}
for (Iterator iter = hosts.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry)iter.next();
for (Map.Entry<Object, Object> entry : hosts.entrySet()) {
String s = (String) entry.getValue();
Destination signer = new Destination(s);
// make it go faster if we have the signerHash hint

View File

@@ -157,7 +157,7 @@ public class RouterAddress extends DataStructureImpl {
* @return an unmodifiable view, non-null, sorted
* @since 0.8.13
*/
public Map getOptionsMap() {
public Map<Object, Object> getOptionsMap() {
return Collections.unmodifiableMap(_options);
}
@@ -324,7 +324,7 @@ public class RouterAddress extends DataStructureImpl {
buf.append("\n\tCost: ").append(_cost);
//buf.append("\n\tExpiration: ").append(_expiration);
buf.append("\n\tOptions (").append(_options.size()).append("):");
for (Map.Entry e : _options.entrySet()) {
for (Map.Entry<Object, Object> e : _options.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@@ -244,7 +244,7 @@ public class RouterInfo extends DatabaseEntry {
* @return an unmodifiable view, non-null, sorted
* @since 0.8.13
*/
public Map getOptionsMap() {
public Map<Object, Object> getOptionsMap() {
return Collections.unmodifiableMap(_options);
}
@@ -626,7 +626,7 @@ public class RouterInfo extends DatabaseEntry {
}
}
buf.append("\n\tOptions (").append(_options.size()).append("):");
for (Map.Entry e : _options.entrySet()) {
for (Map.Entry<Object, Object> e : _options.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@@ -225,7 +225,7 @@ public class SessionConfig extends DataStructureImpl {
buf.append("\n\tOptions: #: ").append(_options.size());
Properties sorted = new OrderedProperties();
sorted.putAll(_options);
for (Map.Entry e : sorted.entrySet()) {
for (Map.Entry<Object, Object> e : sorted.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@@ -295,7 +295,7 @@ public class FileUtil {
//Pack200.newUnpacker().unpack(in, out);
if (!_failedOracle) {
try {
Class p200 = Class.forName("java.util.jar.Pack200", true, ClassLoader.getSystemClassLoader());
Class<?> p200 = Class.forName("java.util.jar.Pack200", true, ClassLoader.getSystemClassLoader());
Method newUnpacker = p200.getMethod("newUnpacker", (Class[]) null);
Object unpacker = newUnpacker.invoke(null,(Object[]) null);
Method unpack = unpacker.getClass().getMethod("unpack", new Class[] {InputStream.class, JarOutputStream.class});
@@ -316,8 +316,8 @@ public class FileUtil {
//(new Archive(in, out)).unpack();
if (!_failedApache) {
try {
Class p200 = Class.forName("org.apache.harmony.unpack200.Archive", true, ClassLoader.getSystemClassLoader());
Constructor newUnpacker = p200.getConstructor(new Class[] {InputStream.class, JarOutputStream.class});
Class<?> p200 = Class.forName("org.apache.harmony.unpack200.Archive", true, ClassLoader.getSystemClassLoader());
Constructor<?> newUnpacker = p200.getConstructor(new Class[] {InputStream.class, JarOutputStream.class});
Object unpacker = newUnpacker.newInstance(new Object[] {in, out});
Method unpack = unpacker.getClass().getMethod("unpack", (Class[]) null);
// throws IOException or Pack200Exception

View File

@@ -25,7 +25,7 @@ import net.i2p.I2PAppContext;
* @author jrandom
*/
public class Log {
private final Class _class;
private final Class<?> _class;
private final String _className;
private final String _name;
private int _minPriority;
@@ -75,7 +75,7 @@ public class Log {
* Warning - not recommended.
* Use I2PAppContext.getGlobalContext().logManager().getLog(cls)
*/
public Log(Class cls) {
public Log(Class<?> cls) {
this(I2PAppContext.getGlobalContext().logManager(), cls, null);
_manager.addLog(this);
}
@@ -89,7 +89,7 @@ public class Log {
_manager.addLog(this);
}
Log(LogManager manager, Class cls) {
Log(LogManager manager, Class<?> cls) {
this(manager, cls, null);
}
@@ -97,7 +97,7 @@ public class Log {
this(manager, null, name);
}
Log(LogManager manager, Class cls, String name) {
Log(LogManager manager, Class<?> cls, String name) {
_manager = manager;
_class = cls;
_className = cls != null ? cls.getName() : null;
@@ -229,7 +229,7 @@ public class Log {
/** @return the LogScope (private class) */
public Object getScope() { return _scope; }
static String getScope(String name, Class cls) {
static String getScope(String name, Class<?> cls) {
if ( (name == null) && (cls == null) ) return "f00";
if (cls == null) return name;
if (name == null) return cls.getName();
@@ -239,7 +239,7 @@ public class Log {
private static final class LogScope {
private final String _scopeCache;
public LogScope(String name, Class cls) {
public LogScope(String name, Class<?> cls) {
_scopeCache = getScope(name, cls);
}

View File

@@ -166,9 +166,9 @@ public class LogManager {
t.start();
}
public Log getLog(Class cls) { return getLog(cls, null); }
public Log getLog(Class<?> cls) { return getLog(cls, null); }
public Log getLog(String name) { return getLog(null, name); }
public Log getLog(Class cls, String name) {
public Log getLog(Class<?> cls, String name) {
String scope = Log.getScope(name, cls);
boolean isNew = false;
Log rv = _logs.get(scope);
@@ -186,7 +186,7 @@ public class LogManager {
/** now used by ConfigLogingHelper */
public List<Log> getLogs() {
return new ArrayList(_logs.values());
return new ArrayList<Log>(_logs.values());
}
/**
@@ -407,7 +407,7 @@ public class LogManager {
private void parseLimits(Properties config, String recordPrefix) {
_limits.clear();
if (config != null) {
for (Map.Entry e : config.entrySet()) {
for (Map.Entry<Object, Object> e : config.entrySet()) {
String key = (String) e.getKey();
// if we're filtering the records (e.g. logger.record.*) then

View File

@@ -15,14 +15,14 @@ package net.i2p.util;
*/
class LogRecord {
private final long _date;
private final Class _source;
private final Class<?> _source;
private final String _name;
private final String _threadName;
private final int _priority;
private final String _message;
private final Throwable _throwable;
public LogRecord(Class src, String name, String threadName, int priority, String msg, Throwable t) {
public LogRecord(Class<?> src, String name, String threadName, int priority, String msg, Throwable t) {
_date = Clock.getInstance().now();
_source = src;
_name = name;
@@ -36,7 +36,7 @@ class LogRecord {
return _date;
}
public Class getSource() {
public Class<?> getSource() {
return _source;
}

View File

@@ -35,19 +35,19 @@ public class OrderedProperties extends Properties {
}
@Override
public Set keySet() {
return Collections.unmodifiableSortedSet(new TreeSet(super.keySet()));
public Set<Object> keySet() {
return Collections.unmodifiableSortedSet(new TreeSet<Object>(super.keySet()));
}
@Override
public Set<Map.Entry<Object, Object>> entrySet() {
TreeSet<Map.Entry<Object, Object>> rv = new TreeSet(new EntryComparator());
TreeSet<Map.Entry<Object, Object>> rv = new TreeSet<Map.Entry<Object, Object>>(new EntryComparator());
rv.addAll(super.entrySet());
return Collections.unmodifiableSortedSet(rv);
}
private static class EntryComparator implements Comparator<Map.Entry> {
public int compare(Map.Entry l, Map.Entry r) {
private static class EntryComparator implements Comparator<Map.Entry<Object, Object>> {
public int compare(Map.Entry<Object, Object> l, Map.Entry<Object, Object> r) {
return ((String)l.getKey()).compareTo(((String)r.getKey()));
}
}

View File

@@ -47,7 +47,7 @@ public abstract class SystemVersion {
int sdk = 0;
if (_isAndroid) {
try {
Class ver = Class.forName("android.os.Build.VERSION", true, ClassLoader.getSystemClassLoader());
Class<?> ver = Class.forName("android.os.Build.VERSION", true, ClassLoader.getSystemClassLoader());
Field field = ver.getField("SDK_INT");
sdk = field.getInt(null);
} catch (Exception e) {}

View File

@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper;
@@ -22,7 +23,8 @@ public class BlockfileNamingServiceTest extends TestCase {
List<String> _names;
File hostsTxt, routerDir;
public void setUp() throws Exception {
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() throws Exception {
I2PAppContext ctx = new I2PAppContext();
routerDir = ctx.getRouterDir();
@@ -31,7 +33,7 @@ public class BlockfileNamingServiceTest extends TestCase {
Properties props = new Properties();
assertNotNull("test classpath not set correctly",is);
DataHelper.loadProps(props, is, true);
_names = new ArrayList(props.keySet());
_names = new ArrayList<String>((Set<String>) (Set) props.keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
Collections.shuffle(_names);
is.close();

View File

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

View File

@@ -277,7 +277,7 @@ public class JobQueue {
if (_maxWaitingJobs <= 0) return false; // dont ever drop jobs
if (!_allowParallelOperation) return false; // dont drop during startup [duh]
if (numReady > _maxWaitingJobs) {
Class cls = job.getClass();
Class<? extends Job> cls = job.getClass();
// lets not try to drop too many tunnel messages...
//if (cls == HandleTunnelMessageJob.class)
// return true;

View File

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

View File

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

View File

@@ -197,7 +197,7 @@ public class LoadClientAppsJob extends JobImpl {
log.info("Loading up the client application " + clientName + ": " + className + " " + Arrays.toString(args));
if (args == null)
args = new String[0];
Class cls = Class.forName(className, true, cl);
Class<?> cls = Class.forName(className, true, cl);
Method method = cls.getMethod("main", new Class[] { String[].class });
method.invoke(cls, new Object[] { args });
}
@@ -264,15 +264,15 @@ public class LoadClientAppsJob extends JobImpl {
public void run() {
try {
Class cls = Class.forName(_className, true, _cl);
Class<?> cls = Class.forName(_className, true, _cl);
if (isRouterApp(cls)) {
Constructor con = cls.getConstructor(RouterContext.class, ClientAppManager.class, String[].class);
Constructor<?> con = cls.getConstructor(RouterContext.class, ClientAppManager.class, String[].class);
RouterAppManager mgr = _ctx.clientAppManager();
Object[] conArgs = new Object[] {_ctx, _ctx.clientAppManager(), _args};
RouterApp app = (RouterApp) con.newInstance(conArgs);
mgr.addAndStart(app, _args);
} else if (isClientApp(cls)) {
Constructor con = cls.getConstructor(I2PAppContext.class, ClientAppManager.class, String[].class);
Constructor<?> con = cls.getConstructor(I2PAppContext.class, ClientAppManager.class, String[].class);
RouterAppManager mgr = _ctx.clientAppManager();
Object[] conArgs = new Object[] {_ctx, _ctx.clientAppManager(), _args};
ClientApp app = (ClientApp) con.newInstance(conArgs);
@@ -288,17 +288,17 @@ public class LoadClientAppsJob extends JobImpl {
_log.info("Done running client application " + _appName);
}
private static boolean isRouterApp(Class cls) {
private static boolean isRouterApp(Class<?> cls) {
return isInterface(cls, RouterApp.class);
}
private static boolean isClientApp(Class cls) {
private static boolean isClientApp(Class<?> cls) {
return isInterface(cls, ClientApp.class);
}
private static boolean isInterface(Class cls, Class intfc) {
private static boolean isInterface(Class<?> cls, Class<?> intfc) {
try {
Class[] intfcs = cls.getInterfaces();
Class<?>[] intfcs = cls.getInterfaces();
for (int i = 0; i < intfcs.length; i++) {
if (intfcs[i] == intfc)
return true;

View File

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

View File

@@ -69,7 +69,7 @@ class NTCPSendFinisher {
public CustomThreadPoolExecutor(int num) {
// use unbounded queue, so maximumPoolSize and keepAliveTime have no effect
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);
}
public List<Hash> selectPeers(TunnelPoolSettings settings) {
public List<Hash> selectPeers(TunnelPoolSettings settings) {
Log l = ctx.logManager().getLog(getClass());
int length = getLength(settings);
if (length < 0) {
@@ -34,7 +34,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
}
if (false && shouldSelectExplicit(settings)) {
List rv = selectExplicit(settings, length);
List<Hash> rv = selectExplicit(settings, length);
if (l.shouldLog(Log.DEBUG))
l.debug("Explicit peers selected: " + rv);
return rv;

View File

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