Package org.apache.commons.chain.web
Class AbstractSessionScopeMap<S,R>
java.lang.Object
org.apache.commons.chain.web.AbstractSessionScopeMap<S,R>
- Type Parameters:
S
- the type of the session-classR
- the type of the request-class
Implementation of
Map
for session attributes with a
parameter-provider.- Since:
- Chain 1.3
- Author:
- Graff Stefan
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionAbstractSessionScopeMap
(R request) The constructor for the session attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the mappings from this session-map.boolean
containsKey
(Object key) Returnstrue
if this session-map contains a mapping for the specified key.boolean
containsValue
(Object value) Returnstrue
if this session-map maps one or more keys to the specified value.protected abstract MutableParameterMap
<S, Object> Creates a new mutable-parameter-map to access the session-attributes.entrySet()
Returns aSet
view of the mappings contained in this session-map.boolean
Compares the specified object with this session-map for equality.Returns the value to which the specified key is mapped, ornull
if this session-map contains no mapping for the key.protected R
Returns the request-class.protected S
Returns the session-class.protected abstract S
getSession
(boolean create) Returns the current session or, if there is no current session and the given flag istrue
, creates one and returns the new session.int
hashCode()
Returns the hash code value for this session-map.boolean
isEmpty()
Returnstrue
if this session-map contains no key-value mappings.keySet()
Returns aSet
view of the keys contained in this session-map.Associates the specified value with the specified key in this session-map.void
Copies all of the mappings from the specified map to this session-map.Removes the mapping for the specified key from this session-map if present.protected boolean
Returnstrue
if a session exists.protected boolean
sessionExists
(boolean create) Returnstrue
if a session exists or creates a new session if the parametercreate
is set totrue
.int
size()
Returns the number of key-value mappings in this session-map.toString()
Returns a string representation of this session-map.values()
Returns aCollection
view of the values contained in this session-map.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
AbstractSessionScopeMap
The constructor for the session attributes.- Parameters:
request
- the request-class
-
-
Method Details
-
clear
Removes all of the mappings from this session-map. The session-map will be empty after this call returns. -
containsKey
Returnstrue
if this session-map contains a mapping for the specified key.- Specified by:
containsKey
in interfaceMap<S,
R> - Parameters:
key
- The key whose presence in this session-map is to be tested- Returns:
true
if this session-map contains a mapping for the specified key.
-
containsValue
Returnstrue
if this session-map maps one or more keys to the specified value.- Specified by:
containsValue
in interfaceMap<S,
R> - Parameters:
value
- value whose presence in this session-map is to be tested- Returns:
true
if this session-map maps one or more keys to the specified value
-
entrySet
Returns aSet
view of the mappings contained in this session-map. The set is not backed by the session-map, so changes to the session-map are not reflected in the set, and vice-versa. -
get
Returns the value to which the specified key is mapped, ornull
if this session-map contains no mapping for the key.A return value of
null
does not necessarily indicate that the session-map contains no mapping for the key; it's also possible that the session-map explicitly maps the key tonull
. ThecontainsKey
operation may be used to distinguish these two cases. -
isEmpty
Returnstrue
if this session-map contains no key-value mappings. -
keySet
Returns aSet
view of the keys contained in this session-map. The set is not backed by the session-map, so changes to the session-map are not reflected in the set, and vice-versa. -
put
Associates the specified value with the specified key in this session-map. If the session-map previously contained a mapping for the key, the old value is replaced.- Specified by:
put
in interfaceMap<S,
R> - Parameters:
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key- Returns:
- the previous value associated with
key
, ornull
if there was no mapping forkey
. (Anull
return can also indicate that the session-map previously associatednull
withkey
.)
-
putAll
Copies all of the mappings from the specified map to this session-map. These mappings will replace any mappings that this session-map had for any of the keys currently in the specified map.- Specified by:
putAll
in interfaceMap<S,
R> - Parameters:
map
- mappings to be stored in this session-map- Throws:
NullPointerException
- if the specified map is null
-
remove
Removes the mapping for the specified key from this session-map if present. -
size
Returns the number of key-value mappings in this session-map. -
values
Returns aCollection
view of the values contained in this session-map. The collection is not backed by the session-map, so changes to the session-map are not reflected in the collection, and vice-versa. -
hashCode
Returns the hash code value for this session-map. The hash code of a session-map is defined to be the sum of the hash codes of each entry in the session-map'sentrySet()
view. This ensures thatm1.equals(m2)
implies thatm1.hashCode()==m2.hashCode()
for any two session-mapsm1
andm2
, as required by the general contract ofObject.hashCode()
. -
equals
Compares the specified object with this session-map for equality. Returnstrue
if the given object is also a session-map and the two session-maps represent the same mappings. More formally, two session-mapsm1
andm2
represent the same mappings ifm1.entrySet().equals(m2.entrySet())
. -
toString
Returns a string representation of this session-map. -
getSession
Returns the session-class.- Returns:
- the session-class
-
getRequest
Returns the request-class.- Returns:
- the request-class
-
sessionExists
Returnstrue
if a session exists.- Returns:
true
if a session exists
-
sessionExists
Returnstrue
if a session exists or creates a new session if the parametercreate
is set totrue
.- Parameters:
create
-true
to create a new session if no session exists- Returns:
true
if a session exists
-
getSession
Returns the current session or, if there is no current session and the given flag istrue
, creates one and returns the new session.If the given flag is
false
and there is no current session, this method returnsnull
.- Parameters:
create
-true
to create a new session,false
to returnnull
if there is no current session- Returns:
- the session
-
createParameterMap
Creates a new mutable-parameter-map to access the session-attributes.- Returns:
- a new mutable-parameter-map to access the session-attributes
-