This commit is contained in:
zzz
2010-12-22 22:23:34 +00:00
parent 97f0c13c15
commit b97ad6c5f0

View File

@ -59,7 +59,7 @@ public class BEncoder
else if (o instanceof List)
bencode((List)o, out);
else if (o instanceof Map)
bencode((Map)o, out);
bencode((Map<String, Object>)o, out);
else if (o instanceof BEValue)
bencode(((BEValue)o).getValue(), out);
else
@ -153,7 +153,7 @@ public class BEncoder
out.write(bs);
}
public static byte[] bencode(Map m)
public static byte[] bencode(Map<String, Object> m)
{
try
{
@ -167,20 +167,20 @@ public class BEncoder
}
}
public static void bencode(Map m, OutputStream out) throws IOException
public static void bencode(Map<String, Object> m, OutputStream out) throws IOException
{
out.write('d');
// Keys must be sorted. XXX - But is this the correct order?
Set s = m.keySet();
List l = new ArrayList(s);
Set<String> s = m.keySet();
List<String> l = new ArrayList(s);
Collections.sort(l);
Iterator it = l.iterator();
Iterator<String> it = l.iterator();
while(it.hasNext())
{
// Keys must be Strings.
String key = (String)it.next();
String key = it.next();
Object value = m.get(key);
bencode(key, out);
bencode(value, out);