org.apache.commons.betwixt.expression
Class MapEntryAdder

java.lang.Object
  extended by org.apache.commons.betwixt.expression.MapEntryAdder

public class MapEntryAdder
extends java.lang.Object

MapEntryAdder is used to add entries to a map.

MapEntryAdder supplies two updaters:

When both of these updaters have been called, the entry adder method is called. Once this has happened then the values can be updated again. Note that only the Context passed by the last update will be used.

Since:
0.5
Author:
Robert Burrell Donkin

Field Summary
private  java.lang.reflect.Method adderMethod
          The method to be called to add a new map entry
private  java.lang.Object key
          The entry key
private  boolean keyUpdated
          Has the entry key been updated?
private static org.apache.commons.logging.Log log
          Log used by this class
private  java.lang.Object value
          The entry value
private  boolean valueUpdated
          Has the entry value been updated?
 
Constructor Summary
MapEntryAdder(java.lang.reflect.Method method)
          Construct a MapEntryAdder which adds entries to given method.
 
Method Summary
private  void callAdderMethod(Context context)
          Call the adder method on the bean associated with the Context with the key, value entry values stored previously.
 Updater getKeyUpdater()
          Gets the entry key Updater.
 Updater getValueUpdater()
          Gets the entry value Updater.
static void setLog(org.apache.commons.logging.Log newLog)
          Sets the logger used by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log used by this class


adderMethod

private java.lang.reflect.Method adderMethod
The method to be called to add a new map entry


keyUpdated

private boolean keyUpdated
Has the entry key been updated?


key

private java.lang.Object key
The entry key


valueUpdated

private boolean valueUpdated
Has the entry value been updated?


value

private java.lang.Object value
The entry value

Constructor Detail

MapEntryAdder

public MapEntryAdder(java.lang.reflect.Method method)
Construct a MapEntryAdder which adds entries to given method.

Parameters:
method - the Method called to add a key-value entry
Throws:
java.lang.IllegalArgumentException - if the given method does not take two parameters
Method Detail

setLog

public static void setLog(org.apache.commons.logging.Log newLog)
Sets the logger used by this class.

Parameters:
newLog - log to this

getKeyUpdater

public Updater getKeyUpdater()
Gets the entry key Updater. This is used to update the entry key value to the read value. If getValueUpdater() has been called previously, then this trigger the updating of the adder method.

Returns:
the Updater which should be used to populate the entry key

getValueUpdater

public Updater getValueUpdater()
Gets the entry value Updater. This is used to update the entry key value to the read value. If getKeyUpdater() has been called previously, then this trigger the updating of the adder method.

Returns:
the Updater which should be used to populate the entry value

callAdderMethod

private void callAdderMethod(Context context)
Call the adder method on the bean associated with the Context with the key, value entry values stored previously.

Parameters:
context - the Context against whose bean the adder method will be invoked