Class AbstractSessionScopeMap<S,R>

java.lang.Object
org.apache.commons.chain.web.AbstractSessionScopeMap<S,R>
Type Parameters:
S - the type of the session-class
R - the type of the request-class
All Implemented Interfaces:
Map<String,Object>

public abstract class AbstractSessionScopeMap<S,R> extends Object implements Map<String,Object>
Implementation of Map for session attributes with a parameter-provider.
Since:
Chain 1.3
Author:
Graff Stefan
  • Constructor Details

    • AbstractSessionScopeMap

      public AbstractSessionScopeMap(R request)
      The constructor for the session attributes.
      Parameters:
      request - the request-class
  • Method Details

    • clear

      public void clear()
      Removes all of the mappings from this session-map. The session-map will be empty after this call returns.
      Specified by:
      clear in interface Map<S,R>
    • containsKey

      public boolean containsKey(Object key)
      Returns true if this session-map contains a mapping for the specified key.
      Specified by:
      containsKey in interface Map<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

      public boolean containsValue(Object value)
      Returns true if this session-map maps one or more keys to the specified value.
      Specified by:
      containsValue in interface Map<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 a Set 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.
      Specified by:
      entrySet in interface Map<S,R>
      Returns:
      a set view of the mappings contained in this session-map
    • get

      public Object get(Object key)
      Returns the value to which the specified key is mapped, or null 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 to null. The containsKey operation may be used to distinguish these two cases.

      Specified by:
      get in interface Map<S,R>
      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      the value to which the specified key is mapped, or null if this session-map contains no mapping for the key
      See Also:
    • isEmpty

      public boolean isEmpty()
      Returns true if this session-map contains no key-value mappings.
      Specified by:
      isEmpty in interface Map<S,R>
      Returns:
      true if this session-map contains no key-value mappings
    • keySet

      public Set<String> keySet()
      Returns a Set 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.
      Specified by:
      keySet in interface Map<S,R>
      Returns:
      a set view of the keys contained in this session-map
    • put

      public Object put(String key, Object value)
      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 interface Map<S,R>
      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. (A null return can also indicate that the session-map previously associated null with key.)
    • putAll

      public void putAll(Map<? extends String,? extends Object> map)
      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 interface Map<S,R>
      Parameters:
      map - mappings to be stored in this session-map
      Throws:
      NullPointerException - if the specified map is null
    • remove

      public Object remove(Object key)
      Removes the mapping for the specified key from this session-map if present.
      Specified by:
      remove in interface Map<S,R>
      Parameters:
      key - key whose mapping is to be removed from the session-map
      Returns:
      the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the session-map previously associated null with key.)
    • size

      public int size()
      Returns the number of key-value mappings in this session-map.
      Specified by:
      size in interface Map<S,R>
      Returns:
      the number of key-value mappings in this session-map
    • values

      Returns a Collection 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.
      Specified by:
      values in interface Map<S,R>
      Returns:
      a view of the values contained in this session-map
    • hashCode

      public int 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's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two session-maps m1 and m2, as required by the general contract of Object.hashCode().
      Specified by:
      hashCode in interface Map<S,R>
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this session-map
    • equals

      public boolean equals(Object obj)
      Compares the specified object with this session-map for equality. Returns true if the given object is also a session-map and the two session-maps represent the same mappings. More formally, two session-maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()).
      Specified by:
      equals in interface Map<S,R>
      Overrides:
      equals in class Object
      Parameters:
      obj - object to be compared for equality with this session-map
      Returns:
      true if the specified object is equal to this session-map
    • toString

      public String toString()
      Returns a string representation of this session-map.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this session-map
    • getSession

      protected S getSession()
      Returns the session-class.
      Returns:
      the session-class
    • getRequest

      protected R getRequest()
      Returns the request-class.
      Returns:
      the request-class
    • sessionExists

      protected boolean sessionExists()
      Returns true if a session exists.
      Returns:
      true if a session exists
    • sessionExists

      protected boolean sessionExists(boolean create)
      Returns true if a session exists or creates a new session if the parameter create is set to true.
      Parameters:
      create - true to create a new session if no session exists
      Returns:
      true if a session exists
    • getSession

      protected abstract S getSession(boolean create)
      Returns the current session or, if there is no current session and the given flag is true, creates one and returns the new session.

      If the given flag is false and there is no current session, this method returns null.

      Parameters:
      create - true to create a new session, false to return null 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