View Javadoc

1   package org.springframework.roo.file.undo;
2   
3   import java.util.Stack;
4   
5   /**
6    * Provides the ability to undo changes to a file system.
7    * 
8    * <p>
9    * Note that the complexities of file system I/O are significant and Java does not provide full
10   * access to a file lock API that would simplify coding of implementations. Therefore undoing
11   * changes to the file system is a best-effort basis only, and designs should not rely on
12   * robust, guaranteed, fail-safe undo semantics. 
13   * 
14   * @author Ben Alex
15   * @since 1.0
16   *
17   */
18  public interface UndoManager {
19  
20  	/**
21  	 * Registers an undoable operation in the {@link Stack}.
22  	 * 
23  	 * @param undoableOperation to register in a {@link Stack} (required)
24  	 */
25  	void add(UndoableOperation undoableOperation);
26  	
27  	/**
28  	 * Replays the undo {@link Stack}, and guarantees to clear the {@link Stack}.
29  	 * 
30  	 * <p>
31  	 * The first operation that returns false to {@link UndoableOperation#undo()} will cause the remainder
32  	 * of the {@link Stack} to stop undoing.
33  	 * 
34  	 * <p>
35  	 * Executing this command guarantees the {@link Stack} will be empty upon return, with every element either
36  	 * undone or reset.
37  	 * 
38  	 * @return true if all {@link UndoableOperation}s in the {@link Stack} were successfully undone
39  	 */
40  	boolean undo();
41  	
42  	/**
43  	 * Resets the undo {@link Stack}, and guarantees to clear the {@link Stack}.
44  	 * 
45  	 * <p>
46  	 * Executing this command guarantees the {@link Stack} will be empty upon return, with every element reset.
47  	 */
48  	void reset();
49  }