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(); int cost = addr.getCost();
if (!((style.equals("SSU") && cost == 5) || (style.equals("NTCP") && cost == 10))) if (!((style.equals("SSU") && cost == 5) || (style.equals("NTCP") && cost == 10)))
buf.append('[').append(_("cost")).append('=').append("" + cost).append("] "); buf.append('[').append(_("cost")).append('=').append("" + cost).append("] ");
Map p = addr.getOptionsMap(); Map<Object, Object> p = addr.getOptionsMap();
for (Map.Entry e : (Set<Map.Entry>) 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('[').append(_(DataHelper.stripHTML(name))).append('=').append(DataHelper.stripHTML(val)).append("] "); buf.append('[').append(_(DataHelper.stripHTML(name))).append('=').append(DataHelper.stripHTML(val)).append("] ");
@ -428,8 +428,8 @@ public class NetDbRenderer {
buf.append("</td></tr>\n"); buf.append("</td></tr>\n");
if (full) { if (full) {
buf.append("<tr><td>" + _("Stats") + ": <br><code>"); buf.append("<tr><td>" + _("Stats") + ": <br><code>");
Map p = info.getOptionsMap(); Map<Object, Object> p = info.getOptionsMap();
for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) { for (Map.Entry<Object, Object> e : p.entrySet()) {
String key = (String) e.getKey(); String key = (String) e.getKey();
String val = (String) e.getValue(); String val = (String) e.getValue();
buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br>\n"); 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 * @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 // 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) if (_overrideProps != null)
names.addAll(_overrideProps.keySet()); names.addAll((Set<String>) (Set) _overrideProps.keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
return names; return names;
} }

View File

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

View File

@ -6,7 +6,6 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties; 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"); System.out.println("Attempting to verify using " + sz + " hosts, this may take a while");
} }
for (Iterator iter = hosts.entrySet().iterator(); iter.hasNext(); ) { for (Map.Entry<Object, Object> entry : hosts.entrySet()) {
Map.Entry entry = (Map.Entry)iter.next();
String s = (String) entry.getValue(); String s = (String) entry.getValue();
Destination signer = new Destination(s); Destination signer = new Destination(s);
// make it go faster if we have the signerHash hint // 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 * @return an unmodifiable view, non-null, sorted
* @since 0.8.13 * @since 0.8.13
*/ */
public Map getOptionsMap() { public Map<Object, Object> getOptionsMap() {
return Collections.unmodifiableMap(_options); return Collections.unmodifiableMap(_options);
} }
@ -324,7 +324,7 @@ public class RouterAddress extends DataStructureImpl {
buf.append("\n\tCost: ").append(_cost); buf.append("\n\tCost: ").append(_cost);
//buf.append("\n\tExpiration: ").append(_expiration); //buf.append("\n\tExpiration: ").append(_expiration);
buf.append("\n\tOptions (").append(_options.size()).append("):"); 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 key = (String) e.getKey();
String val = (String) e.getValue(); String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]"); 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 * @return an unmodifiable view, non-null, sorted
* @since 0.8.13 * @since 0.8.13
*/ */
public Map getOptionsMap() { public Map<Object, Object> getOptionsMap() {
return Collections.unmodifiableMap(_options); return Collections.unmodifiableMap(_options);
} }
@ -626,7 +626,7 @@ public class RouterInfo extends DatabaseEntry {
} }
} }
buf.append("\n\tOptions (").append(_options.size()).append("):"); 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 key = (String) e.getKey();
String val = (String) e.getValue(); String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]"); 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()); buf.append("\n\tOptions: #: ").append(_options.size());
Properties sorted = new OrderedProperties(); Properties sorted = new OrderedProperties();
sorted.putAll(_options); sorted.putAll(_options);
for (Map.Entry e : sorted.entrySet()) { for (Map.Entry<Object, Object> e : sorted.entrySet()) {
String key = (String) e.getKey(); String key = (String) e.getKey();
String val = (String) e.getValue(); String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]"); buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@ -186,7 +186,7 @@ public class LogManager {
/** now used by ConfigLogingHelper */ /** now used by ConfigLogingHelper */
public List<Log> getLogs() { 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) { private void parseLimits(Properties config, String recordPrefix) {
_limits.clear(); _limits.clear();
if (config != null) { if (config != null) {
for (Map.Entry e : config.entrySet()) { for (Map.Entry<Object, Object> e : config.entrySet()) {
String key = (String) e.getKey(); String key = (String) e.getKey();
// if we're filtering the records (e.g. logger.record.*) then // if we're filtering the records (e.g. logger.record.*) then

View File

@ -35,19 +35,19 @@ public class OrderedProperties extends Properties {
} }
@Override @Override
public Set keySet() { public Set<Object> keySet() {
return Collections.unmodifiableSortedSet(new TreeSet(super.keySet())); return Collections.unmodifiableSortedSet(new TreeSet<Object>(super.keySet()));
} }
@Override @Override
public Set<Map.Entry<Object, Object>> entrySet() { 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()); rv.addAll(super.entrySet());
return Collections.unmodifiableSortedSet(rv); return Collections.unmodifiableSortedSet(rv);
} }
private static class EntryComparator implements Comparator<Map.Entry> { private static class EntryComparator implements Comparator<Map.Entry<Object, Object>> {
public int compare(Map.Entry l, Map.Entry r) { public int compare(Map.Entry<Object, Object> l, Map.Entry<Object, Object> r) {
return ((String)l.getKey()).compareTo(((String)r.getKey())); 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.Collections;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
@ -22,7 +23,8 @@ public class BlockfileNamingServiceTest extends TestCase {
List<String> _names; List<String> _names;
File hostsTxt, routerDir; File hostsTxt, routerDir;
public void setUp() throws Exception { @SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() throws Exception {
I2PAppContext ctx = new I2PAppContext(); I2PAppContext ctx = new I2PAppContext();
routerDir = ctx.getRouterDir(); routerDir = ctx.getRouterDir();
@ -31,7 +33,7 @@ public class BlockfileNamingServiceTest extends TestCase {
Properties props = new Properties(); Properties props = new Properties();
assertNotNull("test classpath not set correctly",is); assertNotNull("test classpath not set correctly",is);
DataHelper.loadProps(props, is, true); 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); Collections.shuffle(_names);
is.close(); is.close();