Class KeyValuePairBag

    • Constructor Detail

      • KeyValuePairBag

        public KeyValuePairBag()

        Creates a new instance.

    • Method Detail

      • addKeyValuePair

        public abstract void addKeyValuePair​(KeyValuePair pair)

        Add a KeyValuePair to the collection

        Parameters:
        pair - the KeyValuePair to add, may not be null
      • add

        public boolean add​(KeyValuePair pair)
        Specified by:
        add in interface java.util.Collection<KeyValuePair>
        Overrides:
        add in class java.util.AbstractCollection<KeyValuePair>
      • getKeyValuePairs

        public abstract java.util.Collection<KeyValuePair> getKeyValuePairs()
        Returns the underlying Collection of KeyValuePair instances
        Returns:
        underlying Set of KeyValuePairs
      • setKeyValuePairs

        public void setKeyValuePairs​(java.util.Collection<KeyValuePair> list)
        Set the underlying Collection of KeyValuePair instances
        Parameters:
        list - the collection
      • getKeyValuePair

        public KeyValuePair getKeyValuePair​(java.lang.String key)
        Return the first KeyValuePair that matches the given key.
        Parameters:
        key - the key to look up
        Returns:
        the KeyValuePair for the passed key or null if none exists
      • removeKeyValuePair

        public void removeKeyValuePair​(KeyValuePair kp)
        Remove the first KeyValuePair from the underlying collection.
        Parameters:
        kp - the KeyValuePair to remove.
      • removeKeyValuePair

        public void removeKeyValuePair​(java.lang.String key)
        Convenience method to remove a KeyValuePair from the underlying collection.
        Parameters:
        key - the key.
      • contains

        public boolean contains​(KeyValuePair kp)
        Does the underlying set contain this KeyValuePair
        Parameters:
        kp - the keyvalue pair.
        Returns:
        true
      • getValue

        public java.lang.String getValue​(java.lang.String key)
        Convenience method for returning the value associated with a given key.

        Returns the String value associated with the passed key or null if none exists.

        Parameters:
        key - the key to look up
        Returns:
        the String value associated with the passed key or null if none exists
      • getValueIgnoringKeyCase

        public java.lang.String getValueIgnoringKeyCase​(java.lang.String key)

        Return the first value associated with the passed key, ignoring the case of the key. This may legitmately contain two keys "AAA" and "aaa". Calling getValueIgnoringKeyCase(aaa) may return the value associated with either of these keys.

        Parameters:
        key - the key to look up
        Returns:
        the first assoicated value.
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<KeyValuePair>
        Specified by:
        size in class java.util.AbstractCollection<KeyValuePair>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<KeyValuePair>
      • iterator

        public java.util.Iterator<KeyValuePair> iterator()
        Specified by:
        iterator in interface java.util.Collection<KeyValuePair>
        Specified by:
        iterator in interface java.lang.Iterable<KeyValuePair>
        Specified by:
        iterator in class java.util.AbstractCollection<KeyValuePair>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<KeyValuePair>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<KeyValuePair>
        Overrides:
        equals in class java.lang.Object
      • asProperties

        public static java.util.Properties asProperties​(KeyValuePairBag kvps)
        Convert a KeyValuePairBag into a Properties object.
        Parameters:
        kvps - the key value pair set to convert.
        Returns:
        a Properties object containing the key and value pairs.
      • asMap

        public static java.util.Map<java.lang.String,​java.lang.String> asMap​(KeyValuePairBag kvps)
        Convert a KeyValuePairBag into a Map object.
        Parameters:
        kvps - the key value pair set to convert.
        Returns:
        a Map object containing the key and value pairs.
      • addAll

        public void addAll​(java.util.Properties p)
        Convenience method to add all the associated properties to this collection
        Parameters:
        p - collection of properties to add.
      • addAll

        public void addAll​(java.util.Map<java.lang.String,​java.lang.String> map)
        Convenience method to add the associated map to this collection
        Parameters:
        map - the map to add.