Class BencodedMap

    • Constructor Detail

      • BencodedMap

        public BencodedMap()
        Creates a new empty bencoded map.
    • 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).
      • serialize

        public byte[] serialize()
        Returns:
        The value represented in bencoded format.