KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > spi > VCSInterceptor


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.versioning.spi;
20
21 import java.io.File JavaDoc;
22 import java.io.IOException JavaDoc;
23
24 /**
25  * Versioning systems that need to intercept or listen to file system operations implement this class.
26  *
27  * @author Maros Sandor
28  */

29 public abstract class VCSInterceptor {
30
31     // ==================================================================================================
32
// DELETE
33
// ==================================================================================================
34

35     /**
36      * Notifies the interceptor that the file or folder is about to be deleted. The interceptor MUST NOT delete
37      * the file here.
38      *
39      * @param file file to be deleted
40      * @return true if this interceptor wants to handle this operation (doDelete will be called), false otherwise
41      */

42     public boolean beforeDelete(File JavaDoc file) {
43         return false;
44     }
45
46     /**
47      * Called if beforeDelete() returns true and delegates the delete operation to this interceptor. The interceptor
48      * may decide to either delete the file or leave it intact. In case it does not want to delete the file, it should
49      * just return without doing anything.
50      *
51      * @param file a file or an empty folder to delete
52      * @throws IOException if the delete operation failed
53      */

54     public void doDelete(File JavaDoc file) throws IOException JavaDoc {
55     }
56
57     /**
58      * Called after a file or folder is deleted. In case the file was deleted outside IDE, this is the only method called.
59      *
60      * @param file deleted file
61      */

62     public void afterDelete(File JavaDoc file) {
63     }
64     
65     // ==================================================================================================
66
// MOVE
67
// ==================================================================================================
68

69     /**
70      * Notifies the interceptor that the file or folder is about to be moved. The interceptor MUST NOT move
71      * the file here.
72      *
73      * @param from the file to be moved
74      * @param to destination of the file being moved
75      * @return true if this interceptor wants to handle this operation (doMove will be called), false otherwise
76      */

77     public boolean beforeMove(File JavaDoc from, File JavaDoc to) {
78         return false;
79     }
80
81     /**
82      * Called if beforeMove() returns true and delegates the move operation to this interceptor.
83      *
84      * @param from the file to be moved
85      * @param to destination of the file being moved
86      * @throws IOException if the move operation failed
87      */

88     public void doMove(File JavaDoc from, File JavaDoc to) throws IOException JavaDoc {
89     }
90
91     /**
92      * Called after a file or folder has beed moved. In case the file was moved outside IDE, this method is not called but
93      * a pair or afterDelete() / afterCreate() is called instead.
94      *
95      * @param from original location of the file
96      * @param to current location of the file
97      */

98     public void afterMove(File JavaDoc from, File JavaDoc to) {
99     }
100     
101     // ==================================================================================================
102
// CREATE
103
// ==================================================================================================
104

105     /**
106      * Notifies the interceptor that the file or folder is about to be created. The interceptor MUST NOT create
107      * the file here.
108      *
109      * Beware: It may happen on some filesystems that the file will be ALREADY created. If so, returning true from this method has no effect and
110      * doCreate will NOT be called.
111      *
112      * @param file file or folder to be created
113      * @return true if this interceptor wants to handle this operation (doCreate will be called), false otherwise
114      */

115     public boolean beforeCreate(File JavaDoc file, boolean isDirectory) {
116         return false;
117     }
118
119     /**
120      * Called if beforeCreate() returns true and delegates the create operation to this interceptor.
121      *
122      * @param file the file to create
123      * @param isDirectory true if the new file should be a directory, false otherwise
124      * @throws IOException if the create operation failed
125      */

126     public void doCreate(File JavaDoc file, boolean isDirectory) throws IOException JavaDoc {
127     }
128
129     /**
130      * Called after a new file or folder has beed created. In case the file was created outside IDE, this is the only
131      * method called.
132      *
133      * @param file the new file
134      */

135     public void afterCreate(File JavaDoc file) {
136     }
137     
138     // ==================================================================================================
139
// CHANGE
140
// ==================================================================================================
141

142     /**
143      * Called after a file changed.
144      *
145      * @param file changed file
146      */

147     public void afterChange(File JavaDoc file) {
148     }
149     
150     /**
151      * Called before a file is changed.
152      *
153      * @param file to be changed file
154      */

155     public void beforeChange(File JavaDoc file) {
156     }
157     
158 }
159
Popular Tags