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

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

public class ListChange
extends java.lang.Object

Represents a change to a list.

Since:
ICF 0.0
Version:
$Id$

Field Summary
static int add
          Code for adding an element to the list.
private  int addDel
          indicates whether the element was added or deleted
static int del
          Code for removing an element from the list
private  java.lang.Object elem
          the element inserted/deleted
private  int index
          the index of the element inserted/deleted
private  java.util.List list
          the list that was modified
 
Constructor Summary
private ListChange(int add_del, java.util.List list, int index, java.lang.Object elem)
          Constructs a list change of the appopriate type.
 
Method Summary
 void make()
          Makes the change to the list.
static ListChange makeListChange(int add_del, java.util.List list, int index, java.lang.Object elem)
          Performs the designated operation and returns a list change that can be used to undo the operation.
 void undo()
          Undoes the change to the list.
 
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 list.
Since:
ICF 0.0

del

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

addDel

private int addDel
indicates whether the element was added or deleted
Since:
ICF 0.0

list

private java.util.List list
the list that was modified
Since:
ICF 0.0

index

private int index
the index of the element inserted/deleted
Since:
ICF 0.0

elem

private java.lang.Object elem
the element inserted/deleted
Since:
ICF 0.0
Constructor Detail

ListChange

private ListChange(int add_del,
                   java.util.List list,
                   int index,
                   java.lang.Object elem)
Constructs a list change of the appopriate type.
Parameters:
add_del - ListChange.add if the elemented is added to the list, ListChange.del if the elemented is deleted to the list,
list - the list that is modified
index - the index to use for the element to added/removed from the list
elem - the element that is added/removed from the list
Since:
ICF 0.0
Method Detail

undo

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

make

public void make()
Makes the change to the list.
Since:
ICF 0.0

makeListChange

public static ListChange makeListChange(int add_del,
                                        java.util.List list,
                                        int index,
                                        java.lang.Object elem)
Performs the designated operation and returns a list change that can be used to undo the operation.
Parameters:
add_del - ListChange.add if the element is added to the list, ListChange.del if the element is deleted from the list,
list - the list that is modified
index - the index to use for the element to added/removed from the list (ignored for deletions with an element provided, use -1)
elem - the element that is added/removed from the list (for deletion, null to use index to find element). For deletion, the the first element of the list == to this element will be removed.
Returns:
a ListChange object that can undo the requested operation or null if no change resulted
Since:
ICF 0.0