Advertisement
Chiddix

DictionaryType

May 31st, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package me.rabrg.bencode.type.impl;
  2.  
  3. import java.util.Map;
  4. import java.util.Map.Entry;
  5.  
  6. import me.rabrg.bencode.type.BaseType;
  7.  
  8. public final class DictionaryType extends BaseType<Map<StringType, BaseType<Object>>> {
  9.  
  10.     public DictionaryType(final Map<StringType, BaseType<Object>> value) {
  11.         super(value);
  12.     }
  13.  
  14.     @Override
  15.     public String encode() {
  16.         final StringBuffer encoded = new StringBuffer().append('d');
  17.         for (final Entry<StringType, BaseType<Object>> entry : getValue().entrySet()) {
  18.             encoded.append(entry.getKey().encode()).append(entry.getValue().encode());
  19.         }
  20.         return encoded.append('e').toString();
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement