Core: type arguments

This commit is contained in:
str4d
2013-11-22 09:34:42 +00:00
parent 6314f33d8f
commit 15bf94b479
10 changed files with 30 additions and 29 deletions

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

@ -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

@ -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

@ -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

@ -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

@ -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();