Class BencodedMap
- java.lang.Object
-
- org.johnnei.javatorrent.bittorrent.encoding.AbstractBencodedValue
-
- org.johnnei.javatorrent.bittorrent.encoding.BencodedMap
-
- All Implemented Interfaces:
IBencodedValue
public class BencodedMap extends AbstractBencodedValue
A bencoded dictionary.
-
-
Field Summary
-
Fields inherited from class org.johnnei.javatorrent.bittorrent.encoding.AbstractBencodedValue
ENTRY_END_BYTES
-
-
Constructor Summary
Constructors Constructor Description BencodedMap()Creates a new empty bencoded map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,IBencodedValue>asMap()Optional<IBencodedValue>get(String name)Gets the value from the map if available.voidput(String name, IBencodedValue value)Associates the given bencoded value with the given key.Optional<IBencodedValue>remove(String name)Removes a value from the map.byte[]serialize()-
Methods inherited from class org.johnnei.javatorrent.bittorrent.encoding.AbstractBencodedValue
asBigInteger, asBytes, asList, asLong, asString
-
-
-
-
Method Detail
-
put
public void put(String name, IBencodedValue value)
Associates the given bencoded value with the given key. This will overwrite existing entries.- Parameters:
name- The key to assign the value to.value- The value to assign.
-
get
public Optional<IBencodedValue> get(String name)
Gets the value from the map if available.- Parameters:
name- The key to fetch the value for.- Returns:
- The value if present.
-
remove
public Optional<IBencodedValue> remove(String name)
Removes a value from the map.- Parameters:
name- The key to remove the value from.- Returns:
- The removed value (if present).
-
asMap
public Map<String,IBencodedValue> asMap()
- Specified by:
asMapin interfaceIBencodedValue- Overrides:
asMapin classAbstractBencodedValue- Returns:
- The bencoded value as a map.
-
serialize
public byte[] serialize()
- Returns:
- The value represented in bencoded format.
-
-