Package org.apache.shiro.util
Class MapContext
-
- org.apache.shiro.util.MapContext
-
- All Implemented Interfaces:
,
<,>
- Direct Known Subclasses:
DefaultSessionContext
,DefaultSubjectContext
public class MapContext extends implements <,>,
AMapContext
provides a common base for context-based data storage in a . Type-safe attribute retrieval is provided for subclasses with thegetTypedValue(String, Class)
method.- Since:
- 1.0
- See Also:
SubjectContext
,SessionContext
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MapContext()
<,> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
o)
boolean
o)
<<,>>
entrySet()
o)
protected <E> E
key, <E> type)
Performs aget
operation but additionally ensures that the value returned is of the specifiedtype
.boolean
isEmpty()
<>
keySet()
protected void
key, value)
Places a value in this context map under the given key only if the givenvalue
argument is not null.s, o)
void
<? extends ,?> map)
o)
int
size()
<>
values()
-
-
-
Method Detail
-
getTypedValue
protected <E> E getTypedValue( key, <E> type)
Performs aget
operation but additionally ensures that the value returned is of the specifiedtype
. If there is no value,null
is 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
null
if the attribute does not exist.
-
nullSafePut
protected void nullSafePut( key, value)
Places a value in this context map under the given key only if the givenvalue
argument 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
public int size()
- Specified by:
in interface
<,>
-
isEmpty
public boolean isEmpty()
- Specified by:
in interface
<,>
-
containsKey
public boolean containsKey( o)
- Specified by:
in interface
<,>
-
containsValue
public boolean containsValue( o)
- Specified by:
in interface
<,>
-
get
public get( o)
- Specified by:
in interface
<,>
-
put
public put( s, o)
- Specified by:
in interface
<,>
-
remove
public remove( o)
- Specified by:
in interface
<,>
-
putAll
public void putAll(<? extends ,?> map)
- Specified by:
in interface
<,>
-
clear
public void clear()
- Specified by:
in interface
<,>
-
keySet
public <> keySet()
- Specified by:
in interface
<,>
-
values
public <> values()
- Specified by:
in interface
<,>
-
entrySet
public <<,>> entrySet()
- Specified by:
in interface
<,>
-
-