/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.masterfs.providers;
import java.io.IOException;
import org.openide.filesystems.FileObject;
/**
* Encapsulate a group of individual factory methods that are responsible for creating objects
* of specific interfaces. If subclassed and provided by
* {@link AnnotationProvider#getInterceptionListener} then
* individual instances will be called by MasterFileSystem
* There may exist more than one instance of ProvidedExtensions
* at a given moment and therefore there is defined for
* every method wheter will be called by MasterFileSystem
* for every present instance or just for the first one.
*
* @see ProvidedExtensions.IOHandler
* @see InterceptionListener
*
* @author Radek Matous
*/
public class ProvidedExtensions implements InterceptionListener {
/**
* Return instance of {@link ProvidedExtensions.IOHandler}
* that is responsible for moving the file or null.
*
* Just the first non null instance of IOHandler
is used by
* MasterFileSystem
*
* @param src file to be moved
* @param destFolder target folder to move this file to
* @param name new basename of file
* @param ext new extension of file (ignored for folders)
* @return instance of {@link ProvidedExtensions.IOHandler}
* that is responsible for moving the file or null
*/
public ProvidedExtensions.IOHandler getMoveHandler(
FileObject src, FileObject destFolder, String name, String ext) {
return null;
}
/*
* Return instance of {@link ProvidedExtensions.IOHandler}
* that is responsible for renaming the file or null.
*
* Just the first non null instance of IOHandler
is used by
* MasterFileSystem
*
* @param src file to be renamed
* @param name new basename of file
* @param ext new extension of file (ignored for folders)
* @return instance of {@link ProvidedExtensions.IOHandler}
* that is responsible for renaming the file or null
*/
public ProvidedExtensions.IOHandler getRenameHandler(
FileObject src, String name, String ext) {
return null;
}
/**
* All non null instances of InterceptionListener
are used by
* MasterFileSystem
*
* @return instance of {@link InterceptionListener} or null
*/
public InterceptionListener getInterceptionListener() {
return null;
}
public interface IOHandler {
/**
* @throws java.io.IOException if handled operation isn't successful
*/
void handle() throws IOException;
}
public final void createSuccess(FileObject fo) {}
public final void createFailure(FileObject parent, String name, boolean isFolder) {}
public final void beforeCreate(FileObject parent, String name, boolean isFolder) {}
public final void deleteSuccess(FileObject fo) {}
public final void deleteFailure(FileObject fo) {}
public final void beforeDelete(FileObject fo) {}
}