站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

BackupFacility (Refactoring API) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.refactoring.api 1.0

org.netbeans.modules.refactoring.spi
Class BackupFacility

java.lang.Object
  extended by org.netbeans.modules.refactoring.spi.BackupFacility

public abstract class BackupFacility
extends Object

Simple backup facility can be used to backup files and implement undo For instance Java Refactoring module implements undo this way: public Problem prepare(RefactoringElementsBag elements) { . . elements.registerTransaction(new RetoucheCommit(results)); } where RetoucheCommit is Transaction:

 BackupFacility.Handle handle;
 public void commit() {
   FileObject[] files;
   .
   .
   handle = BackupFacility.getDefault().backup(files);
   doCommit();
 }
 public void rollback() {
   //rollback all files
   handle.restore();
 }
 
You can register your own implementation via META-INF services.

See Also:
Transaction, RefactoringElementImplementation.performChange(), RefactoringElementImplementation.undoChange(), RefactoringElementsBag.registerTransaction(org.netbeans.modules.refactoring.spi.Transaction), RefactoringElementsBag#registerFileChange, BackupFacility.Handle

Nested Class Summary
static interface BackupFacility.Handle
          Handle class representing handle to file{s), which were backuped by org.netbeans.modules.refactoring.spi.BackupFacility.backup()
 
Method Summary
 BackupFacility.Handle backup(Collection<? extends FileObject> fileObjects)
          does backup
abstract  BackupFacility.Handle backup(FileObject... file)
          does beckup
abstract  void clear()
          do cleanup all backup files are deleted all internal structures cleared default implementa
static BackupFacility getDefault()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

backup

public abstract BackupFacility.Handle backup(FileObject... file)
                                      throws IOException
does beckup

Parameters:
file - file(s) to backup
Returns:
handle which can be used to restore files
Throws:
IOException - if backup failed

backup

public final BackupFacility.Handle backup(Collection<? extends FileObject> fileObjects)
                                   throws IOException
does backup

Parameters:
fileObjects - FileObjects to backup
Returns:
handle which can be used to restore files
Throws:
IOException

clear

public abstract void clear()
do cleanup all backup files are deleted all internal structures cleared default implementa


getDefault

public static BackupFacility getDefault()
Returns:
default instance of this class. If there is instance of this class in META-INF services -> this class is returned. Otherwise default implementation is used.

org.netbeans.modules.refactoring.api 1.0

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.