Package org.sourceid.util.log
Class AttributeMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,AttributeValue>
-
- org.sourceid.util.log.AttributeMap
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,AttributeValue>
public class AttributeMap extends HashMap<String,AttributeValue>
An attribute map that maps the name of the attribute to theAttributeValue. The class extendsHashMapand should be treated as such.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description AttributeMap()Create an empty AttributeMapAttributeMap(Map<String,AttributeValue> attributes)Create an AttributeMap based on the specified map
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getMaskedAttributeNames()Gets the names of the attributes in this map that are flagged as masked.booleangetMaskOgnlValues()Gets whether the OGNL values should be masked.StringgetSingleValue(String name)Gets the value associated with the specified attribute name.StringgetSingleValue(String name, boolean enforceMasking)Gets the real or masked value associated with the specified attribute name.voidput(String key, String value)Adds a key value pair to this map.AttributeValueput(String key, AttributeValue value)Adds theAttributeValueto this map.voidputAll(Map<? extends String,? extends AttributeValue> m)Copies all of the mappings from the specified map to this map.voidputIfNotPresent(String key, AttributeValue value)Puts the key/value entry if the key doesn't already exist in this map.voidsetMaskOgnlValues(boolean maskOgnlValues)Sets whether the OGNL values should be masked.StringtoString()static StringtoString(Map<String,AttributeValue> map)Static method to stringify the specified map.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
-
-
-
Constructor Detail
-
AttributeMap
public AttributeMap(Map<String,AttributeValue> attributes)
Create an AttributeMap based on the specified map- Parameters:
attributes- A map containing the attributes to add
-
AttributeMap
public AttributeMap()
Create an empty AttributeMap
-
-
Method Detail
-
put
public void put(String key, String value)
Adds a key value pair to this map. The value is wrapped by anAttributeValueand added withput(String, AttributeValue).- Parameters:
key- The key with which the specified value is to be associated.value- The value to be associated with the specified key.
-
putAll
public void putAll(Map<? extends String,? extends AttributeValue> m)
Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map.- Specified by:
putAllin interfaceMap<String,AttributeValue>- Overrides:
putAllin classHashMap<String,AttributeValue>- Parameters:
m- mappings to be stored in this map- Throws:
NullPointerException- if the specified map is null
-
put
public AttributeValue put(String key, AttributeValue value)
Adds theAttributeValueto this map. The entry is not added if the value is null.- Specified by:
putin interfaceMap<String,AttributeValue>- Overrides:
putin classHashMap<String,AttributeValue>- Parameters:
key- Key with which the specified value is to be associated.value- Value to be associated with the specified key.- Returns:
- The previous value associated with key, or null if there was no mapping for key or the passed-in value is null.
-
putIfNotPresent
public void putIfNotPresent(String key, AttributeValue value)
Puts the key/value entry if the key doesn't already exist in this map.- Parameters:
key- The key to put if it doesn't already exist in the map.value- The value to put if the key doesn't already exist in the map.
-
toString
public static String toString(Map<String,AttributeValue> map)
Static method to stringify the specified map.- Parameters:
map- The map to convert to a String.- Returns:
- A String representation of the map.
-
toString
public String toString()
- Overrides:
toStringin classAbstractMap<String,AttributeValue>
-
getMaskedAttributeNames
public Set<String> getMaskedAttributeNames()
Gets the names of the attributes in this map that are flagged as masked.- Returns:
- The set of attribute names that are flagged to be masked.
-
getSingleValue
public String getSingleValue(String name)
Gets the value associated with the specified attribute name. If the value is a multi-value attribute, the first value is returned.- Parameters:
name- The name of the attribute to look up.- Returns:
- The value associated with the specified attribute name. If the value is a multi-value attribute, the first value is returned. Returns null if the attribute does not exist.
-
getSingleValue
public String getSingleValue(String name, boolean enforceMasking)
Gets the real or masked value associated with the specified attribute name. If the value is a multi-value attribute, the first value is returned.- Parameters:
name- The name of the attribute to lookup.enforceMasking- Whether the returned value should be masked if the attribute is flagged for masking.- Returns:
- The value associated with the specified attribute name. If the value is a multi-value attribute, the first value is returned. Can also return a masked value if enforceMasking and attribute masking is set to true. Returns null if the attribute does not exist.
-
getMaskOgnlValues
public boolean getMaskOgnlValues()
Gets whether the OGNL values should be masked.- Returns:
- True, if the OGNL values should be masked.
-
setMaskOgnlValues
public void setMaskOgnlValues(boolean maskOgnlValues)
Sets whether the OGNL values should be masked.- Parameters:
maskOgnlValues- Whether the OGNL values should be masked.
-
-