org.prorefactor.refactor
Class Rollback

java.lang.Object
  extended by org.prorefactor.refactor.Rollback

public class Rollback
extends java.lang.Object

A refactoring "roll back" restores files which were preserved before a refactoring was run.


Field Summary
static ICallback externPreModify
          This callback allows an external package to be notivied when an existing file has been preserved before rollback, in other words, it's about to be modified or deleted.
 
Constructor Summary
Rollback()
          We only support one Rollback at a time (no real plans to support multiple rollbacks either.) Creating a new Rollback wipes out the previous one.
 
Method Summary
 void clearRollback()
          Clears the list of rollback changes, clears the rollback directory.
 java.lang.String getChangeList()
          Get a String description of the file changes.
static Rollback getCurrent()
          Get the current rollback.
 java.util.ArrayList getFileChanges()
          Returns the list of FileChange objects which was added to during the last refactoring.
 void preserve(java.lang.String refname, java.lang.String fullpath)
          Preserve (copy) a file to the "rollback" directory.
 void preserveAndWrite(int handle, java.lang.String refname, java.lang.String fullpath)
          Preserve a file in the "rollback" directory, and then write to it.
 void preserveMove(java.lang.String refname, java.lang.String fullpath)
          Preserve (move) a file to the "rollback" directory.
 void registerNewFile(java.lang.String refname, java.lang.String fullpath)
          Keep track of files which were newly generated by the refactoring.
 java.lang.String rollback()
          Roll back the file changes that were made with the previous refactoring.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

externPreModify

public static ICallback externPreModify
This callback allows an external package to be notivied when an existing file has been preserved before rollback, in other words, it's about to be modified or deleted.

Constructor Detail

Rollback

public Rollback()
We only support one Rollback at a time (no real plans to support multiple rollbacks either.) Creating a new Rollback wipes out the previous one. If you want to find the current Rollback, use getCurrent().

Method Detail

clearRollback

public void clearRollback()
                   throws java.io.IOException
Clears the list of rollback changes, clears the rollback directory. Calling this is not necessary - just crate a new Rollback. That will cause this to be called.

Throws:
java.io.IOException

getChangeList

public java.lang.String getChangeList()
Get a String description of the file changes.


getCurrent

public static Rollback getCurrent()
Get the current rollback.

Returns:
null if no rollback exists for the session.

getFileChanges

public java.util.ArrayList getFileChanges()
Returns the list of FileChange objects which was added to during the last refactoring.


preserve

public void preserve(java.lang.String refname,
                     java.lang.String fullpath)
              throws java.io.IOException
Preserve (copy) a file to the "rollback" directory. Does not re-copy a file that has already been preserved.

Parameters:
refname - The name that the file was referred to with.
fullpath - The full path to the file.
Throws:
java.io.IOException

preserveMove

public void preserveMove(java.lang.String refname,
                         java.lang.String fullpath)
Preserve (move) a file to the "rollback" directory. Does not re-move a file that has already been preserved.

Parameters:
refname - The name that the file was referred to with.
fullpath - The full path to the file.
Throws:
java.io.IOException

preserveAndWrite

public void preserveAndWrite(int handle,
                             java.lang.String refname,
                             java.lang.String fullpath)
                      throws java.io.IOException
Preserve a file in the "rollback" directory, and then write to it. Does not change the original file if there were no differences between old & new. Also use this to write a new file - nothing to rollback, but a record of the newly created file will be kept. If the file has already been preserved, it is not re-copied.

Parameters:
handle - Handle to the top/first node/token.
refname - The name that was used for referring to this file.
fullpath - The full path to the file.
Throws:
java.io.IOException

registerNewFile

public void registerNewFile(java.lang.String refname,
                            java.lang.String fullpath)
Keep track of files which were newly generated by the refactoring.

Parameters:
refname - Relative filename for use with PROPATH. Probably not relevent for this type of a FileChange object.
fullpath - Fully qualified path to the file.

rollback

public java.lang.String rollback()
Roll back the file changes that were made with the previous refactoring. Note that if the user modifies one of the modified files in their workspace, their changes will be lost when they perform the rollback.

Returns:
A String error message, null if no errors.


Copyright © 2008 Joanju Software. All Rights Reserved.