/* * 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; /** * Provides bunch of interfaces. If subclassed and provided by * {@link AnnotationProvider#getInterceptionListener} * individual interfaces will be called by MasterFileSystem. * * @see ProvidedExtensions.MoveHandler * @see ProvidedExtensions.RenameHandler * @see InterceptionListener * * @author Radek Matous */ public class ProvidedExtensions implements InterceptionListener { private boolean isInterceptionImplemented; /** * @param isInterceptionImplemented if false then no methods of {@link InterceptionListener} * will be called by MasterFileSystem. */ protected ProvidedExtensions(boolean isInterceptionImplemented) { this.isInterceptionImplemented = isInterceptionImplemented; } /** * @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.MoveHandler} or null */ public MoveHandler getMoveHandler(FileObject src, FileObject destFolder, String name, String ext) { return null; } /** * @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.RenameHandler} or null */ public RenameHandler getRenameHandler(FileObject src, String name, String ext) { return null; } /** * @return instance of {@link InterceptionListener} or null */ public final InterceptionListener getInterceptionListener() { return (isInterceptionImplemented) ? this : null; } public interface MoveHandler { /** * Moves the file. This method is called from inside of {@link FileObject#move}. * It is guaranteed that file is already locked {@link FileObject#lock}. * @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) * @throws java.io.IOException if file isn't successfully moved */ void handleMove(FileObject src, FileObject destFolder, String name, String ext) throws IOException; } public interface RenameHandler { /** * Renames the file. This method is called from inside of {@link FileObject#rename}. * It is guaranteed that file is already locked {@link FileObject#lock}. * @param src file to be renamed * @param name new basename of file * @param ext new extension of file (ignored for folders) * @throws java.io.IOException if file isn't successfully renamed */ void handleRename(FileObject src, String name, String ext) throws IOException; } public void createSuccess(FileObject fo) {} public void createFailure(FileObject parent, String name, boolean isFolder) {} public void beforeCreate(FileObject parent, String name, boolean isFolder) {} public void deleteSuccess(FileObject fo) {} public void deleteFailure(FileObject fo) {} public void beforeDelete(FileObject fo) {} }