KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > resources > IFolder


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.resources;
12
13 import java.net.URI JavaDoc;
14 import org.eclipse.core.runtime.*;
15
16 /**
17  * Folders may be leaf or non-leaf resources and may contain files and/or other folders.
18  * A folder resource is stored as a directory in the local file system.
19  * <p>
20  * Folders, like other resource types, may exist in the workspace but
21  * not be local; non-local folder resources serve as place-holders for
22  * folders whose properties have not yet been fetched from a repository.
23  * </p>
24  * <p>
25  * This interface is not intended to be implemented by clients.
26  * </p>
27  * <p>
28  * Folders implement the <code>IAdaptable</code> interface;
29  * extensions are managed by the platform's adapter manager.
30  * </p>
31  *
32  * @see Platform#getAdapterManager()
33  */

34 public interface IFolder extends IContainer, IAdaptable {
35
36     /**
37      * Creates a new folder resource as a member of this handle's parent resource.
38      * <p>
39      * This is a convenience method, fully equivalent to:
40      * <pre>
41      * create((force ? FORCE : IResource.NONE), local, monitor);
42      * </pre>
43      * </p>
44      * <p>
45      * This method changes resources; these changes will be reported
46      * in a subsequent resource change event, including an indication
47      * that the folder has been added to its parent.
48      * </p>
49      * <p>
50      * This method is long-running; progress and cancellation are provided
51      * by the given progress monitor.
52      * </p>
53      *
54      * @param force a flag controlling how to deal with resources that
55      * are not in sync with the local file system
56      * @param local a flag controlling whether or not the folder will be local
57      * after the creation
58      * @param monitor a progress monitor, or <code>null</code> if progress
59      * reporting is not desired
60      * @exception CoreException if this method fails. Reasons include:
61      * <ul>
62      * <li> This resource already exists in the workspace.</li>
63      * <li> The workspace contains a resource of a different type
64      * at the same path as this resource.</li>
65      * <li> The parent of this resource does not exist.</li>
66      * <li> The parent of this resource is a project that is not open.</li>
67      * <li> The parent contains a resource of a different type
68      * at the same path as this resource.</li>
69      * <li> The name of this resource is not valid (according to
70      * <code>IWorkspace.validateName</code>).</li>
71      * <li> The corresponding location in the local file system is occupied
72      * by a file (as opposed to a directory).</li>
73      * <li> The corresponding location in the local file system is occupied
74      * by a folder and <code>force </code> is <code>false</code>.</li>
75      * <li> Resource changes are disallowed during certain types of resource change
76      * event notification. See <code>IResourceChangeEvent</code> for more details.</li>
77      * </ul>
78      * @exception OperationCanceledException if the operation is canceled.
79      * Cancelation can occur even if no progress monitor is provided.
80      * @see IFolder#create(int,boolean,IProgressMonitor)
81      */

82     public void create(boolean force, boolean local, IProgressMonitor monitor) throws CoreException;
83
84     /**
85      * Creates a new folder resource as a member of this handle's parent resource.
86      * <p>
87      * The <code>FORCE</code> update flag controls how this method deals with
88      * cases where the workspace is not completely in sync with the local file
89      * system. If <code>FORCE</code> is not specified, the method will only attempt
90      * to create a directory in the local file system if there isn't one already.
91      * This option ensures there is no unintended data loss; it is the recommended
92      * setting. However, if <code>FORCE</code> is specified, this method will
93      * be deemed a success even if there already is a corresponding directory.
94      * </p>
95      * <p>
96      * The {@link IResource#DERIVED} update flag indicates that this resource
97      * should immediately be set as a derived resource. Specifying this flag
98      * is equivalent to atomically calling {@link IResource#setDerived(boolean)}
99      * with a value of <code>true</code> immediately after creating the resource.
100      * </p>
101      * <p>
102      * The {@link IResource#TEAM_PRIVATE} update flag indicates that this resource
103      * should immediately be set as a team private resource. Specifying this flag
104      * is equivalent to atomically calling {@link IResource#setTeamPrivateMember(boolean)}
105      * with a value of <code>true</code> immediately after creating the resource.
106      * </p>
107      * <p>
108      * Update flags other than those listed above are ignored.
109      * </p>
110      * <p>
111      * This method synchronizes this resource with the local file system.
112      * </p>
113      * <p>
114      * This method changes resources; these changes will be reported
115      * in a subsequent resource change event, including an indication
116      * that the folder has been added to its parent.
117      * </p>
118      * <p>
119      * This method is long-running; progress and cancellation are provided
120      * by the given progress monitor.
121      * </p>
122      *
123      * @param updateFlags bit-wise or of update flag constants
124      * ({@link IResource#FORCE}, {@link IResource#DERIVED}, and {@link IResource#TEAM_PRIVATE})
125      * @param local a flag controlling whether or not the folder will be local
126      * after the creation
127      * @param monitor a progress monitor, or <code>null</code> if progress
128      * reporting is not desired
129      * @exception CoreException if this method fails. Reasons include:
130      * <ul>
131      * <li> This resource already exists in the workspace.</li>
132      * <li> The workspace contains a resource of a different type
133      * at the same path as this resource.</li>
134      * <li> The parent of this resource does not exist.</li>
135      * <li> The parent of this resource is a project that is not open.</li>
136      * <li> The parent contains a resource of a different type
137      * at the same path as this resource.</li>
138      * <li> The name of this resource is not valid (according to
139      * <code>IWorkspace.validateName</code>).</li>
140      * <li> The corresponding location in the local file system is occupied
141      * by a file (as opposed to a directory).</li>
142      * <li> The corresponding location in the local file system is occupied
143      * by a folder and <code>FORCE</code> is not specified.</li>
144      * <li> Resource changes are disallowed during certain types of resource change
145      * event notification. See <code>IResourceChangeEvent</code> for more details.</li>
146      * </ul>
147      * @exception OperationCanceledException if the operation is canceled.
148      * Cancelation can occur even if no progress monitor is provided.
149      * @see IResourceRuleFactory#createRule(IResource)
150      * @since 2.0
151      */

152     public void create(int updateFlags, boolean local, IProgressMonitor monitor) throws CoreException;
153
154     /**
155      * Creates a new folder resource as a member of this handle's parent resource.
156      * The folder's contents will be located in the directory specified by the given
157      * file system path. The given path must be either an absolute file system
158      * path, or a relative path whose first segment is the name of a workspace path
159      * variable.
160      * <p>
161      * The <code>ALLOW_MISSING_LOCAL</code> update flag controls how this
162      * method deals with cases where the local file system directory to be linked does
163      * not exist, or is relative to a workspace path variable that is not defined.
164      * If <code>ALLOW_MISSING_LOCAL</code> is specified, the operation will succeed
165      * even if the local directory is missing, or the path is relative to an
166      * undefined variable. If <code>ALLOW_MISSING_LOCAL</code> is not specified, the
167      * operation will fail in the case where the local file system directory does
168      * not exist or the path is relative to an undefined variable.
169      * </p>
170      * <p>
171      * The {@link IResource#REPLACE} update flag controls how this
172      * method deals with cases where a resource of the same name as the
173      * prospective link already exists. If {@link IResource#REPLACE}
174      * is specified, then any existing resource with the same name is removed
175      * from the workspace to make way for creation of the link. This does <b>not</b>
176      * cause the underlying file system contents of that resource to be deleted.
177      * If {@link IResource#REPLACE} is not specified, this method will
178      * fail if an existing resource exists of the same name.
179      * </p>
180      * <p>
181      * The {@link IResource#BACKGROUND_REFRESH} update flag controls how
182      * this method synchronizes the new resource with the filesystem. If this flag is
183      * specified, resources on disk will be synchronized in the background after the
184      * method returns. Child resources of the link may not be available until
185      * this background refresh completes. If this flag is not specified, resources are
186      * synchronized in the foreground before this method returns.
187      * </p>
188      * <p>
189      * Update flags other than {@link IResource#ALLOW_MISSING_LOCAL} or
190      * {@link IResource#REPLACE} or {@link IResource#BACKGROUND_REFRESH} are ignored.
191      * </p>
192      * <p>
193      * This method changes resources; these changes will be reported
194      * in a subsequent resource change event, including an indication
195      * that the folder has been added to its parent.
196      * </p>
197      * <p>
198      * This method is long-running; progress and cancellation are provided
199      * by the given progress monitor.
200      * </p>
201      *
202      * @param localLocation a file system path where the folder should be linked
203      * @param updateFlags bit-wise or of update flag constants
204      * (only ALLOW_MISSING_LOCAL is relevant here)
205      * @param monitor a progress monitor, or <code>null</code> if progress
206      * reporting is not desired
207      * @exception CoreException if this method fails. Reasons include:
208      * <ul>
209      * <li> This resource already exists in the workspace.</li>
210      * <li> The workspace contains a resource of a different type
211      * at the same path as this resource.</li>
212      * <li> The parent of this resource does not exist.</li>
213      * <li> The parent of this resource is not an open project</li>
214      * <li> The name of this resource is not valid (according to
215      * <code>IWorkspace.validateName</code>).</li>
216      * <li> The corresponding location in the local file system does not exist, or
217      * is relative to an undefined variable, and <code>ALLOW_MISSING_LOCAL</code> is
218      * not specified.</li>
219      * <li> The corresponding location in the local file system is occupied
220      * by a file (as opposed to a directory).</li>
221      * <li> Resource changes are disallowed during certain types of resource change
222      * event notification. See <code>IResourceChangeEvent</code> for more details.</li>
223      * <li>The team provider for the project which contains this folder does not permit
224      * linked resources.</li>
225      * <li>This folder's project contains a nature which does not permit linked resources.</li>
226      * </ul>
227      * @exception OperationCanceledException if the operation is canceled.
228      * Cancelation can occur even if no progress monitor is provided.
229      * @see IResource#isLinked()
230      * @see IResource#ALLOW_MISSING_LOCAL
231      * @since 2.1
232      */

233     public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException;
234
235     /**
236      * Creates a new folder resource as a member of this handle's parent resource.
237      * The folder's contents will be located in the directory specified by the given
238      * file system URI. The given URI must be either absolute, or a relative URI
239      * whose first path segment is the name of a workspace path variable.
240      * <p>
241      * The <code>ALLOW_MISSING_LOCAL</code> update flag controls how this
242      * method deals with cases where the local file system directory to be linked does
243      * not exist, or is relative to a workspace path variable that is not defined.
244      * If <code>ALLOW_MISSING_LOCAL</code> is specified, the operation will succeed
245      * even if the local directory is missing, or the path is relative to an
246      * undefined variable. If <code>ALLOW_MISSING_LOCAL</code> is not specified, the
247      * operation will fail in the case where the local file system directory does
248      * not exist or the path is relative to an undefined variable.
249      * </p>
250      * <p>
251      * The {@link IResource#REPLACE} update flag controls how this
252      * method deals with cases where a resource of the same name as the
253      * prospective link already exists. If {@link IResource#REPLACE}
254      * is specified, then any existing resource with the same name is removed
255      * from the workspace to make way for creation of the link. This does <b>not</b>
256      * cause the underlying file system contents of that resource to be deleted.
257      * If {@link IResource#REPLACE} is not specified, this method will
258      * fail if an existing resource exists of the same name.
259      * </p>
260      * <p>
261      * The {@link IResource#BACKGROUND_REFRESH} update flag controls how
262      * this method synchronizes the new resource with the filesystem. If this flag is
263      * specified, resources on disk will be synchronized in the background after the
264      * method returns. Child resources of the link may not be available until
265      * this background refresh completes. If this flag is not specified, resources are
266      * synchronized in the foreground before this method returns.
267      * </p>
268      * <p>
269      * Update flags other than {@link IResource#ALLOW_MISSING_LOCAL} or
270      * {@link IResource#REPLACE} or {@link IResource#BACKGROUND_REFRESH} are ignored.
271      * </p>
272      * <p>
273      * This method changes resources; these changes will be reported
274      * in a subsequent resource change event, including an indication
275      * that the folder has been added to its parent.
276      * </p>
277      * <p>
278      * This method is long-running; progress and cancellation are provided
279      * by the given progress monitor.
280      * </p>
281      *
282      * @param location a file system path where the folder should be linked
283      * @param updateFlags bit-wise or of update flag constants
284      * (only ALLOW_MISSING_LOCAL is relevant here)
285      * @param monitor a progress monitor, or <code>null</code> if progress
286      * reporting is not desired
287      * @exception CoreException if this method fails. Reasons include:
288      * <ul>
289      * <li> This resource already exists in the workspace.</li>
290      * <li> The workspace contains a resource of a different type
291      * at the same path as this resource.</li>
292      * <li> The parent of this resource does not exist.</li>
293      * <li> The parent of this resource is not an open project</li>
294      * <li> The name of this resource is not valid (according to
295      * <code>IWorkspace.validateName</code>).</li>
296      * <li> The corresponding location in the local file system does not exist, or
297      * is relative to an undefined variable, and <code>ALLOW_MISSING_LOCAL</code> is
298      * not specified.</li>
299      * <li> The corresponding location in the local file system is occupied
300      * by a file (as opposed to a directory).</li>
301      * <li> Resource changes are disallowed during certain types of resource change
302      * event notification. See <code>IResourceChangeEvent</code> for more details.</li>
303      * <li>The team provider for the project which contains this folder does not permit
304      * linked resources.</li>
305      * <li>This folder's project contains a nature which does not permit linked resources.</li>
306      * </ul>
307      * @exception OperationCanceledException if the operation is canceled.
308      * Cancelation can occur even if no progress monitor is provided.
309      * @see IResource#isLinked()
310      * @see IResource#ALLOW_MISSING_LOCAL
311      * @since 3.2
312      */

313     public void createLink(URI JavaDoc location, int updateFlags, IProgressMonitor monitor) throws CoreException;
314
315     /**
316      * Deletes this resource from the workspace.
317      * <p>
318      * This is a convenience method, fully equivalent to:
319      * <pre>
320      * delete((keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
321      * </pre>
322      * </p>
323      * <p>
324      * This method changes resources; these changes will be reported
325      * in a subsequent resource change event, including an indication
326      * that this folder has been removed from its parent.
327      * </p>
328      * <p>
329      * This method is long-running; progress and cancellation are provided
330      * by the given progress monitor.
331      * </p>
332      *
333      * @param force a flag controlling whether resources that are not
334      * in sync with the local file system will be tolerated
335      * @param keepHistory a flag controlling whether files under this folder
336      * should be stored in the workspace's local history
337      * @param monitor a progress monitor, or <code>null</code> if progress
338      * reporting is not desired
339      * @exception CoreException if this method fails. Reasons include:
340      * <ul>
341      * <li> This resource could not be deleted for some reason.</li>
342      * <li> This resource is out of sync with the local file system
343      * and <code>force</code> is <code>false</code>.</li>
344      * <li> Resource changes are disallowed during certain types of resource change
345      * event notification. See <code>IResourceChangeEvent</code> for more details.</li>
346      * </ul>
347      * @exception OperationCanceledException if the operation is canceled.
348      * Cancelation can occur even if no progress monitor is provided.
349      *
350      * @see IResourceRuleFactory#deleteRule(IResource)
351      * @see IResource#delete(int,IProgressMonitor)
352      */

353     public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException;
354
355     /**
356      * Returns a handle to the file with the given name in this folder.
357      * <p>
358      * This is a resource handle operation; neither the resource nor
359      * the result need exist in the workspace.
360      * The validation check on the resource name/path is not done
361      * when the resource handle is constructed; rather, it is done
362      * automatically as the resource is created.
363      * </p>
364      *
365      * @param name the string name of the member file
366      * @return the (handle of the) member file
367      * @see #getFolder(String)
368      */

369     public IFile getFile(String JavaDoc name);
370
371     /**
372      * Returns a handle to the folder with the given name in this folder.
373      * <p>
374      * This is a resource handle operation; neither the container
375      * nor the result need exist in the workspace.
376      * The validation check on the resource name/path is not done
377      * when the resource handle is constructed; rather, it is done
378      * automatically as the resource is created.
379      * </p>
380      *
381      * @param name the string name of the member folder
382      * @return the (handle of the) member folder
383      * @see #getFile(String)
384      */

385     public IFolder getFolder(String JavaDoc name);
386
387     /**
388      * Moves this resource so that it is located at the given path.
389      * <p>
390      * This is a convenience method, fully equivalent to:
391      * <pre>
392      * move(destination, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
393      * </pre>
394      * </p>
395      * <p>
396      * This method changes resources; these changes will be reported
397      * in a subsequent resource change event, including an indication
398      * that this folder has been removed from its parent and a new folder
399      * has been added to the parent of the destination.
400      * </p>
401      * <p>
402      * This method is long-running; progress and cancellation are provided
403      * by the given progress monitor.
404      * </p>
405      *
406      * @param destination the destination path
407      * @param force a flag controlling whether resources that are not
408      * in sync with the local file system will be tolerated
409      * @param keepHistory a flag controlling whether files under this folder
410      * should be stored in the workspace's local history
411      * @param monitor a progress monitor, or <code>null</code> if progress
412      * reporting is not desired
413      * @exception CoreException if this resource could not be moved. Reasons include:
414      * <ul>
415      * <li> This resource does not exist.</li>
416      * <li> This resource or one of its descendents is not local.</li>
417      * <li> The resource corresponding to the parent destination path does not exist.</li>
418      * <li> The resource corresponding to the parent destination path is a closed
419      * project.</li>
420      * <li> A resource at destination path does exist.</li>
421      * <li> A resource of a different type exists at the destination path.</li>
422      * <li> This resource or one of its descendents is out of sync with the local file system
423      * and <code>force</code> is <code>false</code>.</li>
424      * <li> The workspace and the local file system are out of sync
425      * at the destination resource or one of its descendents.</li>
426      * <li> Resource changes are disallowed during certain types of resource change
427      * event notification. See <code>IResourceChangeEvent</code> for more details.</li>
428      * </ul>
429      * @exception OperationCanceledException if the operation is canceled.
430      * Cancelation can occur even if no progress monitor is provided.
431      *
432      * @see IResourceRuleFactory#moveRule(IResource, IResource)
433      * @see IResource#move(IPath,int,IProgressMonitor)
434      */

435     public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException;
436 }
437
Popular Tags