Class MapAttributes

    • Constructor Detail

      • MapAttributes

        public MapAttributes()
        Construct an instance using a hash map for backing store.
      • MapAttributes

        public MapAttributes​(Map<String,​? extends Collection<String>> original)
        Construct a new instance copying mappings from an original map.
        Parameters:
        original - the original map
      • MapAttributes

        public MapAttributes​(Attributes original)
        Construct a new instance copying mappings from an original attributes collection.
        Parameters:
        original - the original collection
    • Method Detail

      • keySet

        public Set<String> keySet()
        Description copied from interface: Attributes
        Get a set comprised of all the keys in this collection. The returned set can be used to modify this attributes collection.
        Specified by:
        keySet in interface Attributes
        Returns:
        the set of all keys (not null)
      • values

        public Collection<String> values()
        Description copied from interface: Attributes
        Get all the values of all the keys in this collection. The returned collection can be used to modify this attributes collection.
        Specified by:
        values in interface Attributes
        Returns:
        the collection of all values (not null)
      • entries

        public Collection<Attributes.Entry> entries()
        Description copied from interface: Attributes
        Get the entry collection. Changes to the entry collection will modify this attribute collection, if it is writable. The returned entries will remain up to date with the state of this collection.
        Specified by:
        entries in interface Attributes
        Returns:
        the entry collection
      • size

        public int size​(String key)
        Description copied from interface: Attributes
        Get the number of values mapped to the given key.
        Specified by:
        size in interface Attributes
        Parameters:
        key - the key
        Returns:
        the number of mapped values
      • remove

        public boolean remove​(String key)
        Description copied from interface: Attributes
        Remove all values for the given key from this collection.
        Specified by:
        remove in interface Attributes
        Parameters:
        key - the key
        Returns:
        true if the key was found, false otherwise
      • add

        public void add​(String key,
                        int idx,
                        String value)
        Description copied from interface: Attributes
        Add a mapping for the given key at the given position.
        Specified by:
        add in interface Attributes
        Parameters:
        key - the key
        idx - the index
        value - the mapping value
      • get

        public String get​(String key,
                          int idx)
        Description copied from interface: Attributes
        Get the mapping for the given key at the given position.
        Specified by:
        get in interface Attributes
        Parameters:
        key - the key
        idx - the index
        Returns:
        the mapping value
      • set

        public String set​(String key,
                          int idx,
                          String value)
        Description copied from interface: Attributes
        Modify the mapping for the given key at the given position.
        Specified by:
        set in interface Attributes
        Parameters:
        key - the key
        idx - the index
        value - the mapping value
        Returns:
        the previous mapping value
      • remove

        public String remove​(String key,
                             int idx)
        Description copied from interface: Attributes
        Remove and return the mapping for the given key at the given position. All later entries for that key are shifted up to fill in the gap left by the removed element.
        Specified by:
        remove in interface Attributes
        Parameters:
        key - the key
        idx - the index
        Returns:
        the previous mapping value
      • copyAndRemove

        public List<String> copyAndRemove​(String key)
        Description copied from interface: Attributes
        Remove all values for the given key from this collection, copying the values into a list which is returned.
        Specified by:
        copyAndRemove in interface Attributes
        Parameters:
        key - the key
        Returns:
        the values as a list (not null)
      • copyAndReplace

        public List<String> copyAndReplace​(String key,
                                           Collection<String> values)
        Description copied from interface: Attributes
        Replace the mapping for the given key with the values copied from the given collection.
        Specified by:
        copyAndReplace in interface Attributes
        Parameters:
        key - the key
        values - the new values
        Returns:
        a list containing the previously mapped values
      • containsKey

        public boolean containsKey​(String key)
        Description copied from interface: Attributes
        Determine if the given key has values in this collection.
        Specified by:
        containsKey in interface Attributes
        Parameters:
        key - the key
        Returns:
        true if the key has values, false otherwise
      • containsValue

        public boolean containsValue​(String key,
                                     String value)
        Description copied from interface: Attributes
        Determine if the given key has a mapping for the given value in this collection.
        Specified by:
        containsValue in interface Attributes
        Parameters:
        key - the key
        value - the value
        Returns:
        true if the key has a mapping to the given value, false otherwise
      • removeRange

        public void removeRange​(String key,
                                int from,
                                int to)
        Description copied from interface: Attributes
        Remove all the values for the given key between the from index (inclusive) and the to index (exclusive).
        Specified by:
        removeRange in interface Attributes
        Parameters:
        key - the key
        from - the start index (inclusive)
        to - the end index (exclusive)
      • indexOf

        public int indexOf​(String key,
                           String value)
        Description copied from interface: Attributes
        Get the index of the first occurrence of the given value at the given key, if any.
        Specified by:
        indexOf in interface Attributes
        Parameters:
        key - the key
        value - the value
        Returns:
        the index, or -1 if the value was not found at the given key
      • lastIndexOf

        public int lastIndexOf​(String key,
                               String value)
        Description copied from interface: Attributes
        Get the index of the last occurrence of the given value at the given key, if any.
        Specified by:
        lastIndexOf in interface Attributes
        Parameters:
        key - the key
        value - the value
        Returns:
        the index, or -1 if the value was not found at the given key
      • set

        public boolean set​(String key,
                           int idx,
                           String expect,
                           String update)
        Description copied from interface: Attributes
        Conditionally set a specific value of a given key to a new value, if the existing value matches the expect parameter.
        Specified by:
        set in interface Attributes
        Parameters:
        key - the key
        idx - the index
        expect - the expected value
        update - the value to set
        Returns:
        true if the actual value matched the expected value and was updated, false otherwise
      • getFirst

        public String getFirst​(String key)
        Description copied from interface: Attributes
        Get the first value mapped to the given key.
        Specified by:
        getFirst in interface Attributes
        Parameters:
        key - the key
        Returns:
        the value
      • getLast

        public String getLast​(String key)
        Description copied from interface: Attributes
        Get the last value mapped to the given key.
        Specified by:
        getLast in interface Attributes
        Parameters:
        key - the key
        Returns:
        the value
      • addFirst

        public void addFirst​(String key,
                             String value)
        Description copied from interface: Attributes
        Add a value before the first mapping for the given key.
        Specified by:
        addFirst in interface Attributes
        Parameters:
        key - the key
        value - the value
      • addLast

        public void addLast​(String key,
                            String value)
        Description copied from interface: Attributes
        Add a value after the last mapping for the given key.
        Specified by:
        addLast in interface Attributes
        Parameters:
        key - the key
        value - the value
      • removeFirst

        public boolean removeFirst​(String key,
                                   String value)
        Description copied from interface: Attributes
        Remove the first occurrence of the given value under the given key, if any.
        Specified by:
        removeFirst in interface Attributes
        Parameters:
        key - the key
        value - the value to remove
        Returns:
        true if the value was found and removed, false otherwise
      • removeLast

        public boolean removeLast​(String key,
                                  String value)
        Description copied from interface: Attributes
        Remove the last occurrence of the given value under the given key, if any.
        Specified by:
        removeLast in interface Attributes
        Parameters:
        key - the key
        value - the value to remove
        Returns:
        true if the value was found and removed, false otherwise
      • removeFirst

        public String removeFirst​(String key)
        Description copied from interface: Attributes
        Remove the first value mapped to the given key.
        Specified by:
        removeFirst in interface Attributes
        Parameters:
        key - the key
        Returns:
        the value
      • removeLast

        public String removeLast​(String key)
        Description copied from interface: Attributes
        Remove the last value mapped to the given key.
        Specified by:
        removeLast in interface Attributes
        Parameters:
        key - the key
        Returns:
        the value
      • remove

        public boolean remove​(String key,
                              int idx,
                              String value)
        Description copied from interface: Attributes
        Remove the mapping for the given key at the given position if it matches the given existing value. All later entries for that key are shifted up to fill in the gap left by the removed element.
        Specified by:
        remove in interface Attributes
        Parameters:
        key - the key
        idx - the index
        value - the expected previous mapping value
        Returns:
        true if the value matched and was removed, false otherwise
      • removeAll

        public boolean removeAll​(String key,
                                 String value)
        Description copied from interface: Attributes
        Remove the all occurrences of the given value under the given key, if any.
        Specified by:
        removeAll in interface Attributes
        Parameters:
        key - the key
        value - the value to remove
        Returns:
        true if the value was found and removed, false otherwise
      • get

        public Attributes.Entry get​(String key)
        Description copied from interface: Attributes
        Get the collection of values for the given key. The result may implement Attributes.SetEntry if the values are distinct (for example, a role or group set).
        Specified by:
        get in interface Attributes
        Parameters:
        key - the attribute name
        Returns:
        the (possibly empty) attribute value collection
      • size

        public int size()
        Description copied from interface: Attributes
        Get the number of keys in this attribute collection.
        Specified by:
        size in interface Attributes
        Returns:
        the number of keys
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Attributes
        Determine if this collection is empty.
        Specified by:
        isEmpty in interface Attributes
        Returns:
        true if the collection is empty, false otherwise
      • clear

        public void clear()
        Description copied from interface: Attributes
        Clear this collection, resetting its size to zero.
        Specified by:
        clear in interface Attributes