edu.cmu.cs.coral.icf.plan_based.planners.pip
Class MapChange

java.lang.Object
  |
  +--edu.cmu.cs.coral.icf.plan_based.planners.pip.MapChange

public class MapChange
extends java.lang.Object

Represents a addition/deletion of an element in a map. Null keys and values are not supported.

Since:
ICF 0.0
Version:
$Id$

Field Summary
static int add
          Code for adding an element to the map.
private  int addDel
          the type of change made to the map (addition[or change]/deletion)
static int del
          Code for removing an element from the map
private  java.lang.Object key
          the key affected
private  java.util.Map map
          the map changed
private  java.lang.Object newValue
          the new value associated with the key or null if not applicable
private  java.lang.Object oldValue
          the old value associated with the key or null if not applicable
 
Constructor Summary
private MapChange(int add_del, java.util.Map map, java.lang.Object key, java.lang.Object old_value, java.lang.Object new_value)
          Constructs a map change of the appopriate type.
 
Method Summary
 void apply()
          Applies the change to the map.
static MapChange makeMapChange(int add_del, java.util.Map map, java.lang.Object key, java.lang.Object value)
          Performs the designated operation and returns a map change that can be used to undo the operation.
 void undo()
          Undoes the change to the map.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

add

public static final int add
Code for adding an element to the map.
Since:
ICF 0.0

del

public static final int del
Code for removing an element from the map
Since:
ICF 0.0

addDel

private int addDel
the type of change made to the map (addition[or change]/deletion)
Since:
ICF 0.0

map

private java.util.Map map
the map changed
Since:
ICF 0.0

key

private java.lang.Object key
the key affected
Since:
ICF 0.0

oldValue

private java.lang.Object oldValue
the old value associated with the key or null if not applicable
Since:
ICF 0.0

newValue

private java.lang.Object newValue
the new value associated with the key or null if not applicable
Since:
ICF 0.0
Constructor Detail

MapChange

private MapChange(int add_del,
                  java.util.Map map,
                  java.lang.Object key,
                  java.lang.Object old_value,
                  java.lang.Object new_value)
Constructs a map change of the appopriate type.
Parameters:
add_del - MapChange.add if the elemented is added to the map, MapChange.del if the elemented is deleted to the map,
map - the map that is modified
key - the key that is used to index into the map
old_value - the new value for the key (when no old value, pass in null)
new_value - the new value for the key (when add_del==del, pass in null)
Since:
ICF 0.0
Method Detail

undo

public void undo()
Undoes the change to the map.
Since:
ICF 0.0

apply

public void apply()
Applies the change to the map.
Since:
ICF 0.0

makeMapChange

public static MapChange makeMapChange(int add_del,
                                      java.util.Map map,
                                      java.lang.Object key,
                                      java.lang.Object value)
Performs the designated operation and returns a map change that can be used to undo the operation.
Parameters:
add_del - MapChange.add if the elemented is added to the map, MapChange.del if the elemented is deleted to the map,
map - the map that is modified
key - the key that is used to index into the map
value - the new value for the key (ignored when add_del==del, pass in null)
Returns:
a MapChange object that can undo the requested operation or null if no change resulted
Since:
ICF 0.0