Package com.adaptris.util
Class KeyValuePairBag
- java.lang.Object
-
- java.util.AbstractCollection<KeyValuePair>
-
- com.adaptris.util.KeyValuePairBag
-
- All Implemented Interfaces:
java.lang.Iterable<KeyValuePair>
,java.util.Collection<KeyValuePair>
- Direct Known Subclasses:
KeyValuePairCollection
,KeyValuePairList
,KeyValuePairSet
public abstract class KeyValuePairBag extends java.util.AbstractCollection<KeyValuePair>
A Collection of of KeyValuePair instances.
-
-
Constructor Summary
Constructors Constructor Description KeyValuePairBag()
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
add(KeyValuePair pair)
void
addAll(java.util.Map<java.lang.String,java.lang.String> map)
Convenience method to add the associated map to this collectionvoid
addAll(java.util.Properties p)
Convenience method to add all the associated properties to this collectionabstract void
addKeyValuePair(KeyValuePair pair)
Add a KeyValuePair to the collectionstatic java.util.Map<java.lang.String,java.lang.String>
asMap(KeyValuePairBag kvps)
Convert aKeyValuePairBag
into a Map object.static java.util.Properties
asProperties(KeyValuePairBag kvps)
Convert aKeyValuePairBag
into a Properties object.boolean
contains(KeyValuePair kp)
Does the underlying set contain this KeyValuePairboolean
equals(java.lang.Object o)
KeyValuePair
getKeyValuePair(java.lang.String key)
Return the first KeyValuePair that matches the given key.abstract java.util.Collection<KeyValuePair>
getKeyValuePairs()
Returns the underlying Collection of KeyValuePair instancesjava.lang.String
getValue(java.lang.String key)
Convenience method for returning the value associated with a given key.java.lang.String
getValueIgnoringKeyCase(java.lang.String key)
Return the first value associated with the passed key, ignoring the case of the key.int
hashCode()
java.util.Iterator<KeyValuePair>
iterator()
void
removeKeyValuePair(KeyValuePair kp)
Remove the first KeyValuePair from the underlying collection.void
removeKeyValuePair(java.lang.String key)
Convenience method to remove a KeyValuePair from the underlying collection.void
setKeyValuePairs(java.util.Collection<KeyValuePair> list)
Set the underlying Collection of KeyValuePair instancesint
size()
java.lang.String
toString()
-
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
addKeyValuePair
public abstract void addKeyValuePair(KeyValuePair pair)
Add a KeyValuePair to the collection
- Parameters:
pair
- theKeyValuePair
to add, may not be null
-
add
public boolean add(KeyValuePair pair)
- Specified by:
add
in interfacejava.util.Collection<KeyValuePair>
- Overrides:
add
in classjava.util.AbstractCollection<KeyValuePair>
-
getKeyValuePairs
public abstract java.util.Collection<KeyValuePair> getKeyValuePairs()
Returns the underlying Collection of KeyValuePair instances- Returns:
- underlying
Set
ofKeyValuePair
s
-
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 interfacejava.util.Collection<KeyValuePair>
- Specified by:
size
in classjava.util.AbstractCollection<KeyValuePair>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<KeyValuePair>
-
iterator
public java.util.Iterator<KeyValuePair> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<KeyValuePair>
- Specified by:
iterator
in interfacejava.lang.Iterable<KeyValuePair>
- Specified by:
iterator
in classjava.util.AbstractCollection<KeyValuePair>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<KeyValuePair>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Collection<KeyValuePair>
- Overrides:
equals
in classjava.lang.Object
-
asProperties
public static java.util.Properties asProperties(KeyValuePairBag kvps)
Convert aKeyValuePairBag
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 aKeyValuePairBag
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.
-
-