org.barracudamvc.plankton.data
Class HttpSessionStateMap

java.lang.Object
  extended by org.barracudamvc.plankton.data.HttpSessionStateMap
All Implemented Interfaces:
StateMap

public class HttpSessionStateMap
extends Object
implements StateMap

The implementation provides a StateMap bridge to a HttpSession object. By this, we mean that this class allows you to treat an HttpSession as a StateMap. Unlike the HttpSession, this class will handle null keys, values.


Field Summary
protected  javax.servlet.http.HttpSession session
           
 
Constructor Summary
HttpSessionStateMap(javax.servlet.http.HttpSession isession)
          Public constructor.
 
Method Summary
 void clearState()
          clear all state information
 javax.servlet.http.HttpSession getSession()
          get a reference to the underlying HttpSession
 Object getState(Object key)
          get a property in this StateMap
 Set getStateKeys()
          get a keyset for this StateMap (whether or not the set is backed by the data store depends on the implementation).
 Map getStateStore()
          get a Map that holds the state values (whether or not the Map is backed by the data store depends on the implementation).
 void putState(Object key, Object val)
          set a property in this StateMap
 Object removeState(Object key)
          remove a property in this StateMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected javax.servlet.http.HttpSession session
Constructor Detail

HttpSessionStateMap

public HttpSessionStateMap(javax.servlet.http.HttpSession isession)
Public constructor.

Parameters:
isession - the underlying servlet session structure
Method Detail

putState

public void putState(Object key,
                     Object val)
set a property in this StateMap

Specified by:
putState in interface StateMap
Parameters:
key - the key object
val - the value object

getState

public Object getState(Object key)
get a property in this StateMap

Specified by:
getState in interface StateMap
Parameters:
key - the key object
Returns:
the value for the given key

removeState

public Object removeState(Object key)
remove a property in this StateMap. This function was expanded in csc_082103_1 to support the notion of wildcarding, allowing you to remove multiple keys in one fell swoop. Basically, if the key is a String, which ends with an '*', then any keys that start with that string will be removed (and in this case, the method returns a Map of key/val pairs that got removed, rather than a single object that got removed). This approach is not quite as flexible as using regular expressions, but that would make us dependent on jdk1.4 (so we won't go there for now). Note that this class backs the ObjectRepository data structures, so this functionality applies there as well.

Specified by:
removeState in interface StateMap
Parameters:
key - the key object
Returns:
the object which was removed

getStateKeys

public Set getStateKeys()
get a keyset for this StateMap (whether or not the set is backed by the data store depends on the implementation). In this particular case, the set is just a COPY of the underlying data structure

Specified by:
getStateKeys in interface StateMap
Returns:
a Set of keys for this StateMap

getStateStore

public Map getStateStore()
get a Map that holds the state values (whether or not the Map is backed by the data store depends on the implementation). In this particular case, the map is just a COPY of the underlying data store (session)

Specified by:
getStateStore in interface StateMap
Returns:
a Map of key/val pairs for this StateMap

clearState

public void clearState()
clear all state information

Specified by:
clearState in interface StateMap

getSession

public javax.servlet.http.HttpSession getSession()
get a reference to the underlying HttpSession

Returns:
a reference to the underlying HttpSession


Copyright © 2006 BarracudaMVC.org All Rights Reserved.