com.metamatrix.common.actions
Interface ModificationActionQueue

All Known Implementing Classes:
BasicModificationActionQueue

public interface ModificationActionQueue

This interface defines a queue of modification actions. Methods exist to pop the actions, add an action, clear the actions, and get the number of actions.

After a modification action is created, it may be placed within this queue. At some determined point (i.e., a user presses an "apply" button), the actions in this queue may be popped out of the queue and executed as an atomic transaction.


Method Summary
 boolean addAction(ActionDefinition newAction)
          Add to the end of this queue a modification action.
 int addActions(java.util.List newActions)
          Moved to the end of this queue the list of modification actions.
 int addActions(ModificationActionQueue queue)
          Moved to the end of this queue the modification actions in the specified queue.
 void clear()
          Remove all of the actions that are currently in this queue.
 int getActionCount()
          Return the number of actions that are currently in this queue.
 java.util.List getActions()
          Return a copy of the list of actions in this queue, possibly empty but never null
 ActionDefinition getLast()
          Return a clone of the last modification action object that was added to this queue.
 boolean hasActions()
          Return whether this queue has at least one modification action.
 java.util.List popActions()
          Remove all of the modification objects that are in the queue and return them.
 java.util.List popActions(int count)
          Remove the specified number of modification objects that are in the queue and return them.
 ActionDefinition removeLast()
          Remove and return the last modification action object that was added to this queue.
 

Method Detail

popActions

java.util.List popActions()
Remove all of the modification objects that are in the queue and return them. Immediately after this method is called, the queue will contain no actions.

Returns:
the list of actions, ordered by the time of their creation with the action created last at the end of the list; may be an empty List if there are no actions, but null should not be returned

popActions

java.util.List popActions(int count)
Remove the specified number of modification objects that are in the queue and return them.

Parameters:
count - the number of modification action objects to remove from the queue; if greater than the number of actions in this queue, all of the actions are popped.
Returns:
the list of actions that was removed from the queue, ordered by the time of their creation with the action created last at the end of the list, or an empty List if there are no actions in the queue.

getLast

ActionDefinition getLast()
Return a clone of the last modification action object that was added to this queue. This method does not alter the queue in any way.

Returns:
a clone of the last modification action instance added to this queue.

removeLast

ActionDefinition removeLast()
Remove and return the last modification action object that was added to this queue. This method reduces the number of actions in the queue by 1.

Returns:
a clone of the last modification action instance added to this queue.

addAction

boolean addAction(ActionDefinition newAction)
Add to the end of this queue a modification action.

Parameters:
newAction - the new modification action that is to be added to this queue.
Returns:
true if the action could be added, or false otherwise.
Throws:
java.lang.IllegalArgumentException - if the new action is null.

addActions

int addActions(java.util.List newActions)
Moved to the end of this queue the list of modification actions.

Parameters:
ordered - list of actions to be added to this queue.
Returns:
the number of actions added to this queue.
Throws:
java.lang.IllegalArgumentException - if the new action is null.

addActions

int addActions(ModificationActionQueue queue)
Moved to the end of this queue the modification actions in the specified queue. The actions will be removed from the specified queue.

Parameters:
queue - the queue from with all actions are to be removed and added to this queue.
Returns:
the number of actions added to this queue.
Throws:
java.lang.IllegalArgumentException - if the new action is null.

getActions

java.util.List getActions()
Return a copy of the list of actions in this queue, possibly empty but never null

Returns:
the list of actions in this queue, possibly empty but never null

getActionCount

int getActionCount()
Return the number of actions that are currently in this queue.

Returns:
the number of actions in this queue.

hasActions

boolean hasActions()
Return whether this queue has at least one modification action.

Returns:
true if there is at least one modification action in this queue, or false if there are none.

clear

void clear()
Remove all of the actions that are currently in this queue.



Copyright © 2009. All Rights Reserved.