KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > masterfs > providers > ProvidedExtensions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.masterfs.providers;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import org.openide.filesystems.FileObject;
25
26 /**
27  * Encapsulate a group of individual factory methods that are responsible for creating objects
28  * of specific interfaces. If subclassed and provided by
29  * {@link AnnotationProvider#getInterceptionListener} then
30  * individual instances will be called by <code>MasterFileSystem</code>
31  * There may exist more than one instance of <code>ProvidedExtensions</code>
32  * at a given moment and therefore there is defined for
33  * every method wheter will be called by <code>MasterFileSystem</code>
34  * for every present instance or just for the first one.
35  *
36  * @see ProvidedExtensions.IOHandler
37  * @see InterceptionListener
38  *
39  * @author Radek Matous
40  */

41 public class ProvidedExtensions implements InterceptionListener {
42     /**
43      * Return instance of {@link ProvidedExtensions.IOHandler}
44      * that is responsible for moving the file or null.
45      *
46      * Just the first non null instance of <code>IOHandler</code> is used by
47      * <code>MasterFileSystem</code>
48      *
49      * @param from file to be moved
50      * @param to target to move this file to
51      * @return instance of {@link ProvidedExtensions.IOHandler}
52      * that is responsible for moving the file or null
53      */

54     public ProvidedExtensions.IOHandler getMoveHandler(
55             File JavaDoc from, File JavaDoc to) {
56         return null;
57     }
58     
59     /*
60      * Return instance of {@link ProvidedExtensions.IOHandler}
61      * that is responsible for renaming the file or null.
62      *
63      * Just the first non null instance of <code>IOHandler</code> is used by
64      * <code>MasterFileSystem</code>
65      *
66      * @param from file to be renamed
67      * @param newName new name of file
68      * @return instance of {@link ProvidedExtensions.IOHandler}
69      * that is responsible for renaming the file or null
70      */

71     public ProvidedExtensions.IOHandler getRenameHandler(
72             File JavaDoc from, String JavaDoc newName) {
73         return null;
74     }
75
76     /*
77      * Return instance of {@link ProvidedExtensions.DeleteHandler}
78      * that is responsible for deleting the file or null.
79      *
80      * Just the first non null instance of <code>DeleteHandler</code> is used by
81      * <code>MasterFileSystem</code>
82      *
83      * @param f file or folder to be deleted
84      * @return instance of {@link ProvidedExtensions.DeleteHandler}
85      * that is responsible for deleting the file or null
86      */

87     public ProvidedExtensions.DeleteHandler getDeleteHandler(File JavaDoc f) {
88         return null;
89     }
90     
91     
92     public interface IOHandler {
93         /**
94          * @throws java.io.IOException if handled operation isn't successful
95          */

96         void handle() throws IOException JavaDoc;
97     }
98     
99     public interface DeleteHandler {
100         /**
101          * Deletes the file or directory denoted by this abstract pathname. If
102          * this pathname denotes a directory, then the directory must be empty in
103          * order to be deleted.
104          *
105          * @return <code>true</code> if and only if the file or directory is
106          * successfully deleted; <code>false</code> otherwise
107          */

108         boolean delete(File JavaDoc file);
109     }
110     
111         
112     public void createSuccess(FileObject fo) {}
113     public void createFailure(FileObject parent, String JavaDoc name, boolean isFolder) {}
114     public void beforeCreate(FileObject parent, String JavaDoc name, boolean isFolder) {}
115     public void deleteSuccess(FileObject fo) {}
116     public void deleteFailure(FileObject fo) {}
117     public void beforeDelete(FileObject fo) {}
118
119
120     /*
121      * Called by <code>MasterFileSystem</code> when <code>FileObject</code>
122      * is going to be modified by asking for <code>OutputStream<code>
123      * @see org.openide.filesystems.FileObject#getOutputStream
124      * @param fo file which is going to be notified
125      * @since 1.10
126      */

127     public void beforeChange(FileObject fo) {}
128 }
129
Popular Tags