org.barracudamvc.plankton.data
Class DefaultStateMap

java.lang.Object
  extended byorg.barracudamvc.plankton.data.DefaultStateMap
All Implemented Interfaces:
StateMap
Direct Known Subclasses:
FilterContext, ObjectRepository

public class DefaultStateMap
extends Object
implements StateMap

A StateMap is an object that is capable of carrying state information along with it--you can put properties into the state and then get them back out.

This class provides the default implementation of a StateMap. The underlying storage structure is a HashMap, so it a) isn't threadsafe and b) accepts nulls. If you need more than the minimal functionality exposed in the StateMap interface, you should work with the underlying Map structure.

Key entities that implement StateMap:


Field Summary
protected static org.apache.log4j.Logger logger
           
protected  Map props
           
 
Constructor Summary
DefaultStateMap()
           
 
Method Summary
 void clearState()
          clear all state information
 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

logger

protected static final org.apache.log4j.Logger logger

props

protected Map props
Constructor Detail

DefaultStateMap

public DefaultStateMap()
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_101803_2 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 backed by 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 the underlying data store itself

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


Copyright © 2004 BarracudaMVC.org All Rights Reserved.