net.sourceforge.stripes.util.bean
Class MapPropertyAccessor

java.lang.Object
  extended by net.sourceforge.stripes.util.bean.MapPropertyAccessor
All Implemented Interfaces:
PropertyAccessor<Map<?,?>>

public class MapPropertyAccessor
extends Object
implements PropertyAccessor<Map<?,?>>

Implementation of PropertyAccessor for interacting with Maps. Uses information stored in the node evaluation to determine the correct type for the Map key and converts the key using Stripes' type conversion system.

Since:
Stripes 1.4
Author:
Tim Fennell

Constructor Summary
MapPropertyAccessor()
           
 
Method Summary
protected  Object getKey(NodeEvaluation evaluation)
          Attempts to convert the key to from the expression node to the correct type as determined by reflection (using generics to find the Map key type).
 Object getValue(NodeEvaluation evaluation, Map<?,?> map)
          Gets the value stored in the Map under the key specified by the current node.
 void setValue(NodeEvaluation evaluation, Map map, Object value)
          Sets the value stored in the Map under the key specified by the current node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapPropertyAccessor

public MapPropertyAccessor()
Method Detail

getValue

public Object getValue(NodeEvaluation evaluation,
                       Map<?,?> map)
Gets the value stored in the Map under the key specified by the current node.

Specified by:
getValue in interface PropertyAccessor<Map<?,?>>
Parameters:
evaluation - the current node evaluation
map - the target Map
Returns:
the value stored in the map under the specified key

setValue

public void setValue(NodeEvaluation evaluation,
                     Map map,
                     Object value)
Sets the value stored in the Map under the key specified by the current node.

Specified by:
setValue in interface PropertyAccessor<Map<?,?>>
Parameters:
evaluation - the current node evaluation
map - the target Map
value - the value to be stored in the map under the specified key

getKey

protected Object getKey(NodeEvaluation evaluation)
Attempts to convert the key to from the expression node to the correct type as determined by reflection (using generics to find the Map key type). If generics information is not present then the type found in the expression is used (String, int etc.).

Parameters:
evaluation - the current node evaluation
Returns:
the key to use when interacting with the Map


? Copyright 2005-2006, Stripes Development Team.