Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.rabrg.bencode.type.impl;
- import java.util.Map;
- import java.util.Map.Entry;
- import me.rabrg.bencode.type.BaseType;
- public final class DictionaryType implements BaseType {
- private final Map<StringType, BaseType> value;
- public DictionaryType(final Map<StringType, BaseType> value) {
- this.value = value;
- }
- @Override
- public String encode() {
- final StringBuffer encoded = new StringBuffer().append('d');
- for (final Entry<StringType, BaseType> entry : value.entrySet()) {
- encoded.append(entry.getKey().encode()).append(entry.getValue().encode());
- }
- return encoded.append('e').toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement