KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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 - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.resources;
12
13 import org.eclipse.core.runtime.jobs.ISchedulingRule;
14
15 /**
16  * A resource rule factory returns scheduling rules for API methods
17  * that modify the workspace. These rules can be used when creating jobs
18  * or other operations that perform a series of modifications on the workspace.
19  * This allows clients to implement two phase commit semantics, where all
20  * necessary rules are obtained prior to executing a long running operation.
21  * <p>
22  * Note that simple use of the workspace APIs does not require use of scheduling
23  * rules. All workspace API methods that modify the workspace will automatically
24  * obtain any scheduling rules needed to perform the modification. However, if you
25  * are aggregating a set of changes to the workspace using <code>WorkspaceJob</code>
26  * or <code>IWorkspaceRunnable</code> you can use scheduling rules to lock a
27  * portion of the workspace for the duration of the job or runnable. If you
28  * provide a non-null scheduling rule, a runtime exception will occur if you try to
29  * modify a portion of the workspace that is not covered by the rule for the runnable or job.
30  * <p>
31  * If more than one rule is needed, they can be aggregated using the
32  * <code>MultiRule.combine</code> method. Simplifying a group of rules does not change
33  * the set of resources that are covered, but can improve job scheduling performance.
34  * <p>
35  * Note that <code>null</code> is a valid scheduling rule (indicating that no
36  * resources need to be locked), and thus all methods in this class may
37  * return <code>null</code>.
38  * <p>
39  * This interface is not intended to be implemented by clients.
40  * </p>
41  *
42  * @see WorkspaceJob
43  * @see IWorkspace#run(IWorkspaceRunnable, ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor)
44  * @see org.eclipse.core.runtime.jobs.MultiRule#combine(ISchedulingRule, ISchedulingRule)
45  * @since 3.0
46  */

47 public interface IResourceRuleFactory {
48     /**
49      * Returns the scheduling rule that is required for creating a project, folder,
50      * or file.
51      *
52      * @param resource the resource being created
53      * @return a scheduling rule, or <code>null</code>
54      */

55     public ISchedulingRule createRule(IResource resource);
56
57     /**
58      * Returns the scheduling rule that is required for building a project or the
59      * entire workspace.
60      *
61      * @return a scheduling rule, or <code>null</code>
62      */

63     public ISchedulingRule buildRule();
64     
65     /**
66      * Returns the scheduling rule that is required for changing the charset
67      * setting for a file or the default charset setting for a container.
68      *
69      * @param resource the resource the charset will be changed
70      * @return a scheduling rule, or <code>null</code>
71      * @since 3.1
72      */

73     public ISchedulingRule charsetRule(IResource resource);
74
75     /**
76      * Returns the scheduling rule that is required for copying a resource.
77      *
78      * @param source the source of the copy
79      * @param destination the destination of the copy
80      * @return a scheduling rule, or <code>null</code>
81      */

82     public ISchedulingRule copyRule(IResource source, IResource destination);
83
84     /**
85      * Returns the scheduling rule that is required for deleting a resource.
86      *
87      * @param resource the resource to be deleted
88      * @return a scheduling rule, or <code>null</code>
89      */

90     public ISchedulingRule deleteRule(IResource resource);
91
92     /**
93      * Returns the scheduling rule that is required for creating, modifying, or
94      * deleting markers on a resource.
95      *
96      * @param resource the resource owning the marker to be modified
97      * @return a scheduling rule, or <code>null</code>
98      */

99     public ISchedulingRule markerRule(IResource resource);
100
101     /**
102      * Returns the scheduling rule that is required for modifying a resource.
103      * For files, modification includes setting and appending contents. For
104      * projects, modification includes opening or closing the project, or
105      * setting the project description. For all resources
106      * <code>touch</code> is considered to be a modification.
107      *
108      * @param resource the resource being modified
109      * @return a scheduling rule, or <code>null</code>
110      */

111     public ISchedulingRule modifyRule(IResource resource);
112
113     /**
114      * Returns the scheduling rule that is required for moving a resource.
115      *
116      * @param source the source of the move
117      * @param destination the destination of the move
118      * @return a scheduling rule, or <code>null</code>
119      */

120     public ISchedulingRule moveRule(IResource source, IResource destination);
121
122     /**
123      * Returns the scheduling rule that is required for performing
124      * <code>refreshLocal</code> on a resource.
125      *
126      * @param resource the resource to refresh
127      * @return a scheduling rule, or <code>null</code>
128      */

129     public ISchedulingRule refreshRule(IResource resource);
130
131     /**
132      * Returns the scheduling rule that is required for a <code>validateEdit</code>
133      *
134      * @param resources the resources to be validated
135      * @return a scheduling rule, or <code>null</code>
136      */

137     public ISchedulingRule validateEditRule(IResource[] resources);
138 }
139
Popular Tags