Class MapContext
java.lang.Object
org.apache.shiro.util.MapContext
- All Implemented Interfaces:
Serializable,Map<String,Object>
- Direct Known Subclasses:
DefaultSessionContext,DefaultSubjectContext
A
MapContext provides a common base for context-based data storage in a Map. Type-safe attribute
retrieval is provided for subclasses with the getTypedValue(String, Class) method.- Since:
- 1.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleanbooleanentrySet()protected <E> EgetTypedValue(String key, Class<E> type) Performs agetoperation but additionally ensures that the value returned is of the specifiedtype.booleanisEmpty()keySet()protected voidnullSafePut(String key, Object value) Places a value in this context map under the given key only if the givenvalueargument is not null.voidintsize()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
MapContext
public MapContext() -
MapContext
-
-
Method Details
-
getTypedValue
Performs agetoperation but additionally ensures that the value returned is of the specifiedtype. If there is no value,nullis returned.- Type Parameters:
E- the expected type of the value- Parameters:
key- the attribute key to look up a valuetype- the expected type of the value- Returns:
- the typed value or
nullif the attribute does not exist.
-
nullSafePut
Places a value in this context map under the given key only if the givenvalueargument is not null.- Parameters:
key- the attribute key under which the non-null value will be storedvalue- the non-null value to store. Ifnull, this method does nothing and returns immediately.
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
get
-
put
-
remove
-
putAll
-
clear
-
keySet
-
values
-
entrySet
-