diff --git a/apps/i2psnark/java/src/org/klomp/snark/MetaInfo.java b/apps/i2psnark/java/src/org/klomp/snark/MetaInfo.java index 829413717cac6b54bec25dfede025bf31e366d2f..97deb7339f9e0a17f8a8dea2967883cc622ef783 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/MetaInfo.java +++ b/apps/i2psnark/java/src/org/klomp/snark/MetaInfo.java @@ -615,31 +615,42 @@ public class MetaInfo if (_log.shouldLog(Log.WARN)) _log.warn("Creating new infomap", new Exception()); // otherwise we must create it - Map info = new HashMap(); - info.put("name", name); + Map<String, BEValue> info = new HashMap<String, BEValue>(); + info.put("name", new BEValue(DataHelper.getUTF8(name))); if (name_utf8 != null) - info.put("name.utf-8", name_utf8); + info.put("name.utf-8", new BEValue(DataHelper.getUTF8(name_utf8))); // BEP 27 if (privateTorrent) - info.put("private", "1"); + info.put("private", new BEValue(DataHelper.getUTF8("1"))); - info.put("piece length", Integer.valueOf(piece_length)); - info.put("pieces", piece_hashes); + info.put("piece length", new BEValue(Integer.valueOf(piece_length))); + info.put("pieces", new BEValue(piece_hashes)); if (files == null) - info.put("length", Long.valueOf(length)); + info.put("length", new BEValue(Long.valueOf(length))); else { - List l = new ArrayList(); + List<BEValue> l = new ArrayList<BEValue>(); for (int i = 0; i < files.size(); i++) { - Map file = new HashMap(); - file.put("path", files.get(i)); - if ( (files_utf8 != null) && (files_utf8.size() > i) ) - file.put("path.utf-8", files_utf8.get(i)); - file.put("length", lengths.get(i)); - l.add(file); + Map<String, BEValue> file = new HashMap<String, BEValue>(); + List<String> fi = files.get(i); + List<BEValue> befiles = new ArrayList<BEValue>(fi.size()); + for (int j = 0; j < fi.size(); j++) { + befiles.add(new BEValue(DataHelper.getUTF8(fi.get(j)))); + } + file.put("path", new BEValue(befiles)); + if ( (files_utf8 != null) && (files_utf8.size() > i) ) { + List<String> fiu = files_utf8.get(i); + List<BEValue> beufiles = new ArrayList<BEValue>(fiu.size()); + for (int j = 0; j < fiu.size(); j++) { + beufiles.add(new BEValue(DataHelper.getUTF8(fiu.get(j)))); + } + file.put("path.utf-8", new BEValue(beufiles)); + } + file.put("length", new BEValue(lengths.get(i))); + l.add(new BEValue(file)); } - info.put("files", l); + info.put("files", new BEValue(l)); } // TODO if we add the ability for other keys in the first constructor diff --git a/apps/i2psnark/java/src/org/klomp/snark/bencode/BDecoder.java b/apps/i2psnark/java/src/org/klomp/snark/bencode/BDecoder.java index db00813641b3eab2e4c98d8687cd0788e68a0778..5384154d1bbe1b12ae9ac49578040c512cbb7f2a 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/bencode/BDecoder.java +++ b/apps/i2psnark/java/src/org/klomp/snark/bencode/BDecoder.java @@ -308,7 +308,7 @@ public class BDecoder + (char)c + "'"); indicator = 0; - Map result = new HashMap(); + Map<String, BEValue> result = new HashMap<String, BEValue>(); c = getNextIndicator(); while (c != 'e') { diff --git a/apps/i2psnark/java/src/org/klomp/snark/bencode/BEValue.java b/apps/i2psnark/java/src/org/klomp/snark/bencode/BEValue.java index 4cae2881ae6c7d70a5e809c7187348b2d6484cd8..eeee145d789bd95309adc1642c6c9e381e7f2719 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/bencode/BEValue.java +++ b/apps/i2psnark/java/src/org/klomp/snark/bencode/BEValue.java @@ -49,12 +49,12 @@ public class BEValue this.value = value; } - public BEValue(List value) + public BEValue(List<BEValue> value) { this.value = value; } - public BEValue(Map value) + public BEValue(Map<String, BEValue> value) { this.value = value; } @@ -146,7 +146,7 @@ public class BEValue { try { - return (List)value; + return (List<BEValue>)value; } catch (ClassCastException cce) { @@ -163,7 +163,7 @@ public class BEValue { try { - return (Map)value; + return (Map<String, BEValue>)value; } catch (ClassCastException cce) {