blob: c2411ad4a4aefdbd13e1d245030889d86c4d0892 [file] [log] [blame]
cbridgha1c6a6ba2005-03-24 16:24:53 +00001/*******************************************************************************
jlanutifed82ab2005-12-01 22:03:10 +00002 * Copyright (c) 2003, 2005 IBM Corporation and others.
cbridgha1c6a6ba2005-03-24 16:24:53 +00003 * 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
jlanutifed82ab2005-12-01 22:03:10 +00007 *
cbridgha1c6a6ba2005-03-24 16:24:53 +00008 * Contributors:
9 * IBM Corporation - initial API and implementation
jlanutifed82ab2005-12-01 22:03:10 +000010 *******************************************************************************/
cbridgha44a17d72005-04-04 07:05:01 +000011package org.eclipse.wst.common.componentcore.resources;
cbridgha1c6a6ba2005-03-24 16:24:53 +000012
13import org.eclipse.core.runtime.CoreException;
14import org.eclipse.core.runtime.IPath;
cbridgha25501202005-03-30 23:45:41 +000015import org.eclipse.core.runtime.IProgressMonitor;
cbridgha25501202005-03-30 23:45:41 +000016/**
cbridghace903d12005-03-31 22:04:23 +000017 * Represents a component as defined by the WTP Modules file. A
18 * virtual container represents the root of the component.
19 * <p>
20 * Virtual containers can provide handles to virtual files and
21 * virtual folders that it contains.
22 * </p>
23 * <p>
24 * To acquire a handle to a component, use the following snippet:<br>
25 * <code>ModuleCore.createContainer(containingProject, componentName)</code>
26 * which will create a handle to a virtual container contained by
27 * <i>containingProject</i> with the name <i>componentName</i>. If the
28 * a component of the given name exists, then
cbridgha44a17d72005-04-04 07:05:01 +000029 * {@link org.eclipse.wst.common.componentcore.resources.IVirtualResource#exists()}
cbridghace903d12005-03-31 22:04:23 +000030 * will return true. Otherwise, use {@link #create(int, IProgressMonitor)} to
31 * create the relevant model elements. If a client needs to add a
32 * mapping from a folder in the same project to root, use
33 * {@link #createLink(IPath, int, IProgressMonitor)} with a
34 * project-relative path.
cbridgha25501202005-03-30 23:45:41 +000035 * <p>
36 * This interface is not intended to be implemented by clients.
37 * </p>
jeffliu3723bef2005-07-06 13:41:48 +000038 * @plannedfor 1.0
cbridgha25501202005-03-30 23:45:41 +000039 */
cbridghace903d12005-03-31 22:04:23 +000040public interface IVirtualContainer extends IVirtualResource {
41
42
43 /**
44 * Create the underlying model elements if they do not already exist. Resources
45 * may be created as a result of this method if the mapped path does not exist.
46 *
47 * @param updateFlags Any of IVirtualResource or IResource update flags. If a
48 * resource must be created, the updateFlags will be supplied to the
49 * resource creation operation.
50 * @param aMonitor
51 * @throws CoreException
52 */
53 public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException;
54
cbridgha21789da2005-03-30 18:50:37 +000055
cbridgha1c6a6ba2005-03-24 16:24:53 +000056 /**
cbridghace903d12005-03-31 22:04:23 +000057 * Returns whether a virtual resource of some type with the given path
cbridgha1c6a6ba2005-03-24 16:24:53 +000058 * exists relative to this resource.
59 * The supplied path may be absolute or relative; in either case, it is
60 * interpreted as relative to this resource. Trailing separators are ignored.
61 * If the path is empty this container is checked for existence.
62 *
63 * @param path the path of the resource
64 * @return <code>true</code> if a resource of some type with the given path
65 * exists relative to this resource, and <code>false</code> otherwise
66 * @see IVirtualResource#exists()
67 */
68 public boolean exists(IPath path);
69
70 /**
cbridghace903d12005-03-31 22:04:23 +000071 * Finds and returns the member virtual resource (folder or file)
cbridgha1c6a6ba2005-03-24 16:24:53 +000072 * with the given name in this container, or <code>null</code> if no such
73 * resource exists.
74 *
cbridgha1c6a6ba2005-03-24 16:24:53 +000075 *
76 * @param name the string name of the member resource
77 * @return the member resource, or <code>null</code> if no such
78 * resource exists
79 */
80 public IVirtualResource findMember(String name);
81
82 /**
cbridghace903d12005-03-31 22:04:23 +000083 * Finds and returns the member resource (folder, or file)
cbridgha1c6a6ba2005-03-24 16:24:53 +000084 * with the given name in this container, or <code>null</code> if
85 * there is no such resource.
86 * <p>
87 * If the <code>includePhantoms</code> argument is <code>false</code>,
88 * only a member resource with the given name that exists will be returned.
89 * If the <code>includePhantoms</code> argument is <code>true</code>,
90 * the method also returns a resource if the workspace is keeping track of a
91 * phantom with that name.
cbridghace903d12005-03-31 22:04:23 +000092 * </p>
93 * <p>
cbridgha1c6a6ba2005-03-24 16:24:53 +000094 * Note that no attempt is made to exclude team-private member resources
95 * as with <code>members</code>.
cbridgha1c6a6ba2005-03-24 16:24:53 +000096 * </p>
97 *
98 * @param name the string name of the member resource
99 * @param includePhantoms <code>true</code> if phantom resources are
100 * of interest; <code>false</code> if phantom resources are not of
101 * interest
102 * @return the member resource, or <code>null</code> if no such
103 * resource exists
104 * @see #members()
105 * @see IVirtualResource#isPhantom()
106 */
cbridghace903d12005-03-31 22:04:23 +0000107 public IVirtualResource findMember(String name, int searchFlags);
cbridgha1c6a6ba2005-03-24 16:24:53 +0000108
109 /**
110 * Finds and returns the member resource identified by the given path in
111 * this container, or <code>null</code> if no such resource exists.
112 * The supplied path may be absolute or relative; in either case, it is
113 * interpreted as relative to this resource. Trailing separators and the path's
cbridghace903d12005-03-31 22:04:23 +0000114 * device are ignored. If the path is empty this container is returned.
cbridgha1c6a6ba2005-03-24 16:24:53 +0000115 *
116 * @param path the path of the desired resource
117 * @return the member resource, or <code>null</code> if no such
118 * resource exists
119 */
120 public IVirtualResource findMember(IPath path);
121
122 /**
123 * Finds and returns the member resource identified by the given path in
124 * this container, or <code>null</code> if there is no such resource.
125 * The supplied path may be absolute or relative; in either case, it is
126 * interpreted as relative to this resource. Trailing separators and the path's
127 * device are ignored.
cbridghace903d12005-03-31 22:04:23 +0000128 * If the path is empty this container is returned.
cbridgha1c6a6ba2005-03-24 16:24:53 +0000129 *
130 * @param path the path of the desired resource
131 * @param includePhantoms <code>true</code> if phantom resources are
132 * of interest; <code>false</code> if phantom resources are not of
133 * interest
134 * @return the member resource, or <code>null</code> if no such
135 * resource exists
136 * @see #members(boolean)
137 * @see IVirtualResource#isPhantom()
138 */
cbridghace903d12005-03-31 22:04:23 +0000139 public IVirtualResource findMember(IPath path, int searchFlags);
cbridgha1c6a6ba2005-03-24 16:24:53 +0000140
141 /**
142 * Returns a handle to the file identified by the given path in this
143 * container.
144 * <p>
145 * This is a resource handle operation; neither the resource nor
146 * the result need exist in the workspace.
147 * The validation check on the resource name/path is not done
148 * when the resource handle is constructed; rather, it is done
149 * automatically as the resource is created.
150 * <p>
151 * The supplied path may be absolute or relative; in either case, it is
152 * interpreted as relative to this resource and is appended
153 * to this container's full path to form the full path of the resultant resource.
154 * A trailing separator is ignored. The path of the resulting resource must
155 * have at least two segments.
156 * </p>
157 *
158 * @param path the path of the member file
159 * @return the (handle of the) member file
160 * @see #getFolder(IPath)
161 */
162 public IVirtualFile getFile(IPath path);
163
164 /**
165 * Returns a handle to the folder identified by the given path in this
166 * container.
167 * <p>
168 * This is a resource handle operation; neither the resource nor
169 * the result need exist in the workspace.
170 * The validation check on the resource name/path is not done
171 * when the resource handle is constructed; rather, it is done
172 * automatically as the resource is created.
173 * <p>
174 * The supplied path may be absolute or relative; in either case, it is
175 * interpreted as relative to this resource and is appended
176 * to this container's full path to form the full path of the resultant resource.
177 * A trailing separator is ignored. The path of the resulting resource must
178 * have at least two segments.
179 * </p>
180 *
181 * @param path the path of the member folder
182 * @return the (handle of the) member folder
183 * @see #getFile(IPath)
184 */
cbridgha25501202005-03-30 23:45:41 +0000185 public IVirtualFolder getFolder(IPath path);
cbridgha21789da2005-03-30 18:50:37 +0000186
187 /**
188 * Returns a handle to the file with the given name in this folder.
189 * <p>
190 * This is a resource handle operation; neither the resource nor
191 * the result need exist in the workspace.
192 * The validation check on the resource name/path is not done
193 * when the resource handle is constructed; rather, it is done
194 * automatically as the resource is created.
195 * </p>
196 *
197 * @param name the string name of the member file
198 * @return the (handle of the) member file
199 * @see #getFolder(String)
200 */
201 public IVirtualFile getFile(String name);
202
203 /**
204 * Returns a handle to the folder with the given name in this folder.
205 * <p>
206 * This is a resource handle operation; neither the container
207 * nor the result need exist in the workspace.
208 * The validation check on the resource name/path is not done
209 * when the resource handle is constructed; rather, it is done
210 * automatically as the resource is created.
211 * </p>
212 *
213 * @param name the string name of the member folder
214 * @return the (handle of the) member folder
215 * @see #getFile(String)
216 */
217 public IVirtualFolder getFolder(String name);
cbridgha1c6a6ba2005-03-24 16:24:53 +0000218
219 /**
220 * Returns a list of existing member resources (projects, folders and files)
221 * in this resource, in no particular order.
222 * <p>
223 * This is a convenience method, fully equivalent to <code>members(IVirtualResource.NONE)</code>.
224 * Team-private member resources are <b>not</b> included in the result.
225 * </p><p>
226 * Note that the members of a project or folder are the files and folders
227 * immediately contained within it. The members of the workspace root
228 * are the projects in the workspace.
229 * </p>
230 *
231 * @return an array of members of this resource
232 * @exception CoreException if this request fails. Reasons include:
233 * <ul>
234 * <li> This resource does not exist.</li>
235 * <li> This resource is a project that is not open.</li>
236 * </ul>
237 * @see #findMember(IPath)
238 * @see IVirtualResource#isAccessible()
239 */
240 public IVirtualResource[] members() throws CoreException;
241
242 /**
243 * Returns a list of all member resources (projects, folders and files)
244 * in this resource, in no particular order.
245 * <p>
cbridgha1c6a6ba2005-03-24 16:24:53 +0000246 * If the <code>INCLUDE_PHANTOMS</code> flag is not specified in the member
247 * flags (recommended), only member resources that exist will be returned.
248 * If the <code>INCLUDE_PHANTOMS</code> flag is specified,
249 * the result will also include any phantom member resources the
250 * workspace is keeping track of.
251 * </p><p>
252 * If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag is specified
253 * in the member flags, team private members will be included along with
254 * the others. If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag
255 * is not specified (recommended), the result will omit any team private
256 * member resources.
257 * </p>
258 * <p>
259 * If the <code>EXCLUDE_DERIVED</code> flag is not specified, derived
260 * resources are included. If the <code>EXCLUDE_DERIVED</code> flag is
261 * specified in the member flags, derived resources are not included.
262 * </p>
263 *
264 * @param memberFlags bit-wise or of member flag constants
265 * (<code>INCLUDE_PHANTOMS</code>, <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code>
266 * and <code>EXCLUDE_DERIVED</code>) indicating which members are of interest
267 * @return an array of members of this resource
268 * @exception CoreException if this request fails. Reasons include:
269 * <ul>
270 * <li> This resource does not exist.</li>
271 * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and
272 * this resource does not exist.</li>
273 * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and
274 * this resource is a project that is not open.</li>
275 * </ul>
276 * @see IVirtualResource#exists()
jeffliu3723bef2005-07-06 13:41:48 +0000277 * @plannedfor 2.0
cbridgha1c6a6ba2005-03-24 16:24:53 +0000278 */
279 public IVirtualResource[] members(int memberFlags) throws CoreException;
vbhadrire796edc2005-06-17 15:32:30 +0000280
281 public IVirtualResource[] getResources(String aResourceType);
cbridgha1c6a6ba2005-03-24 16:24:53 +0000282}
283