cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2003, 2004 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.wst.common.modulecore.resources; |
| 12 | |
| 13 | import org.eclipse.core.runtime.CoreException; |
| 14 | import org.eclipse.core.runtime.IPath; |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 15 | |
| 16 | public interface IVirtualContainer extends IVirtualResource { |
| 17 | |
| 18 | /*==================================================================== |
| 19 | * Constants defining which members are wanted: |
| 20 | *====================================================================*/ |
cbridgha | 21789da | 2005-03-30 18:50:37 +0000 | [diff] [blame^] | 21 | |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 22 | /** |
| 23 | * Returns whether a resource of some type with the given path |
| 24 | * exists relative to this resource. |
| 25 | * The supplied path may be absolute or relative; in either case, it is |
| 26 | * interpreted as relative to this resource. Trailing separators are ignored. |
| 27 | * If the path is empty this container is checked for existence. |
| 28 | * |
| 29 | * @param path the path of the resource |
| 30 | * @return <code>true</code> if a resource of some type with the given path |
| 31 | * exists relative to this resource, and <code>false</code> otherwise |
| 32 | * @see IVirtualResource#exists() |
| 33 | */ |
| 34 | public boolean exists(IPath path); |
| 35 | |
| 36 | /** |
| 37 | * Finds and returns the member resource (project, folder, or file) |
| 38 | * with the given name in this container, or <code>null</code> if no such |
| 39 | * resource exists. |
| 40 | * |
| 41 | * <p> N.B. Unlike the methods which traffic strictly in resource |
| 42 | * handles, this method infers the resulting resource's type from the |
| 43 | * resource existing at the calculated path in the workspace. |
| 44 | * </p> |
| 45 | * |
| 46 | * @param name the string name of the member resource |
| 47 | * @return the member resource, or <code>null</code> if no such |
| 48 | * resource exists |
| 49 | */ |
| 50 | public IVirtualResource findMember(String name); |
| 51 | |
| 52 | /** |
| 53 | * Finds and returns the member resource (project, folder, or file) |
| 54 | * with the given name in this container, or <code>null</code> if |
| 55 | * there is no such resource. |
| 56 | * <p> |
| 57 | * If the <code>includePhantoms</code> argument is <code>false</code>, |
| 58 | * only a member resource with the given name that exists will be returned. |
| 59 | * If the <code>includePhantoms</code> argument is <code>true</code>, |
| 60 | * the method also returns a resource if the workspace is keeping track of a |
| 61 | * phantom with that name. |
| 62 | * </p><p> |
| 63 | * Note that no attempt is made to exclude team-private member resources |
| 64 | * as with <code>members</code>. |
| 65 | * </p><p> |
| 66 | * N.B. Unlike the methods which traffic strictly in resource |
| 67 | * handles, this method infers the resulting resource's type from the |
| 68 | * existing resource (or phantom) in the workspace. |
| 69 | * </p> |
| 70 | * |
| 71 | * @param name the string name of the member resource |
| 72 | * @param includePhantoms <code>true</code> if phantom resources are |
| 73 | * of interest; <code>false</code> if phantom resources are not of |
| 74 | * interest |
| 75 | * @return the member resource, or <code>null</code> if no such |
| 76 | * resource exists |
| 77 | * @see #members() |
| 78 | * @see IVirtualResource#isPhantom() |
| 79 | */ |
| 80 | public IVirtualResource findMember(String name, boolean includePhantoms); |
| 81 | |
| 82 | /** |
| 83 | * Finds and returns the member resource identified by the given path in |
| 84 | * this container, or <code>null</code> if no such resource exists. |
| 85 | * The supplied path may be absolute or relative; in either case, it is |
| 86 | * interpreted as relative to this resource. Trailing separators and the path's |
| 87 | * device are ignored. If the path is empty this container is returned. |
| 88 | * <p> |
| 89 | * Note that no attempt is made to exclude team-private member resources |
| 90 | * as with <code>members</code>. |
| 91 | * </p><p> |
| 92 | * N.B. Unlike the methods which traffic strictly in resource |
| 93 | * handles, this method infers the resulting resource's type from the |
| 94 | * resource existing at the calculated path in the workspace. |
| 95 | * </p> |
| 96 | * |
| 97 | * @param path the path of the desired resource |
| 98 | * @return the member resource, or <code>null</code> if no such |
| 99 | * resource exists |
| 100 | */ |
| 101 | public IVirtualResource findMember(IPath path); |
| 102 | |
| 103 | /** |
| 104 | * Finds and returns the member resource identified by the given path in |
| 105 | * this container, or <code>null</code> if there is no such resource. |
| 106 | * The supplied path may be absolute or relative; in either case, it is |
| 107 | * interpreted as relative to this resource. Trailing separators and the path's |
| 108 | * device are ignored. |
| 109 | * If the path is empty this container is returned. |
| 110 | * <p> |
| 111 | * If the <code>includePhantoms</code> argument is <code>false</code>, |
| 112 | * only a resource that exists at the given path will be returned. |
| 113 | * If the <code>includePhantoms</code> argument is <code>true</code>, |
| 114 | * the method also returns a resource if the workspace is keeping track of |
| 115 | * a phantom member resource at the given path. |
| 116 | * </p><p> |
| 117 | * Note that no attempt is made to exclude team-private member resources |
| 118 | * as with <code>members</code>. |
| 119 | * </p><p> |
| 120 | * N.B. Unlike the methods which traffic strictly in resource |
| 121 | * handles, this method infers the resulting resource's type from the |
| 122 | * existing resource (or phantom) at the calculated path in the workspace. |
| 123 | * </p> |
| 124 | * |
| 125 | * @param path the path of the desired resource |
| 126 | * @param includePhantoms <code>true</code> if phantom resources are |
| 127 | * of interest; <code>false</code> if phantom resources are not of |
| 128 | * interest |
| 129 | * @return the member resource, or <code>null</code> if no such |
| 130 | * resource exists |
| 131 | * @see #members(boolean) |
| 132 | * @see IVirtualResource#isPhantom() |
| 133 | */ |
| 134 | public IVirtualResource findMember(IPath path, boolean includePhantoms); |
| 135 | |
| 136 | /** |
| 137 | * Returns a handle to the file identified by the given path in this |
| 138 | * container. |
| 139 | * <p> |
| 140 | * This is a resource handle operation; neither the resource nor |
| 141 | * the result need exist in the workspace. |
| 142 | * The validation check on the resource name/path is not done |
| 143 | * when the resource handle is constructed; rather, it is done |
| 144 | * automatically as the resource is created. |
| 145 | * <p> |
| 146 | * The supplied path may be absolute or relative; in either case, it is |
| 147 | * interpreted as relative to this resource and is appended |
| 148 | * to this container's full path to form the full path of the resultant resource. |
| 149 | * A trailing separator is ignored. The path of the resulting resource must |
| 150 | * have at least two segments. |
| 151 | * </p> |
| 152 | * |
| 153 | * @param path the path of the member file |
| 154 | * @return the (handle of the) member file |
| 155 | * @see #getFolder(IPath) |
| 156 | */ |
| 157 | public IVirtualFile getFile(IPath path); |
| 158 | |
| 159 | /** |
| 160 | * Returns a handle to the folder identified by the given path in this |
| 161 | * container. |
| 162 | * <p> |
| 163 | * This is a resource handle operation; neither the resource nor |
| 164 | * the result need exist in the workspace. |
| 165 | * The validation check on the resource name/path is not done |
| 166 | * when the resource handle is constructed; rather, it is done |
| 167 | * automatically as the resource is created. |
| 168 | * <p> |
| 169 | * The supplied path may be absolute or relative; in either case, it is |
| 170 | * interpreted as relative to this resource and is appended |
| 171 | * to this container's full path to form the full path of the resultant resource. |
| 172 | * A trailing separator is ignored. The path of the resulting resource must |
| 173 | * have at least two segments. |
| 174 | * </p> |
| 175 | * |
| 176 | * @param path the path of the member folder |
| 177 | * @return the (handle of the) member folder |
| 178 | * @see #getFile(IPath) |
| 179 | */ |
| 180 | public IVirtualFolder getFolder(IPath path); |
cbridgha | 21789da | 2005-03-30 18:50:37 +0000 | [diff] [blame^] | 181 | |
| 182 | |
| 183 | /** |
| 184 | * Returns a handle to the file with the given name in this folder. |
| 185 | * <p> |
| 186 | * This is a resource handle operation; neither the resource nor |
| 187 | * the result need exist in the workspace. |
| 188 | * The validation check on the resource name/path is not done |
| 189 | * when the resource handle is constructed; rather, it is done |
| 190 | * automatically as the resource is created. |
| 191 | * </p> |
| 192 | * |
| 193 | * @param name the string name of the member file |
| 194 | * @return the (handle of the) member file |
| 195 | * @see #getFolder(String) |
| 196 | */ |
| 197 | public IVirtualFile getFile(String name); |
| 198 | |
| 199 | /** |
| 200 | * Returns a handle to the folder with the given name in this folder. |
| 201 | * <p> |
| 202 | * This is a resource handle operation; neither the container |
| 203 | * nor the result need exist in the workspace. |
| 204 | * The validation check on the resource name/path is not done |
| 205 | * when the resource handle is constructed; rather, it is done |
| 206 | * automatically as the resource is created. |
| 207 | * </p> |
| 208 | * |
| 209 | * @param name the string name of the member folder |
| 210 | * @return the (handle of the) member folder |
| 211 | * @see #getFile(String) |
| 212 | */ |
| 213 | public IVirtualFolder getFolder(String name); |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 214 | |
| 215 | /** |
| 216 | * Returns a list of existing member resources (projects, folders and files) |
| 217 | * in this resource, in no particular order. |
| 218 | * <p> |
| 219 | * This is a convenience method, fully equivalent to <code>members(IVirtualResource.NONE)</code>. |
| 220 | * Team-private member resources are <b>not</b> included in the result. |
| 221 | * </p><p> |
| 222 | * Note that the members of a project or folder are the files and folders |
| 223 | * immediately contained within it. The members of the workspace root |
| 224 | * are the projects in the workspace. |
| 225 | * </p> |
| 226 | * |
| 227 | * @return an array of members of this resource |
| 228 | * @exception CoreException if this request fails. Reasons include: |
| 229 | * <ul> |
| 230 | * <li> This resource does not exist.</li> |
| 231 | * <li> This resource is a project that is not open.</li> |
| 232 | * </ul> |
| 233 | * @see #findMember(IPath) |
| 234 | * @see IVirtualResource#isAccessible() |
| 235 | */ |
| 236 | public IVirtualResource[] members() throws CoreException; |
| 237 | |
| 238 | /** |
| 239 | * Returns a list of all member resources (projects, folders and files) |
| 240 | * in this resource, in no particular order. |
| 241 | * <p> |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 242 | * If the <code>INCLUDE_PHANTOMS</code> flag is not specified in the member |
| 243 | * flags (recommended), only member resources that exist will be returned. |
| 244 | * If the <code>INCLUDE_PHANTOMS</code> flag is specified, |
| 245 | * the result will also include any phantom member resources the |
| 246 | * workspace is keeping track of. |
| 247 | * </p><p> |
| 248 | * If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag is specified |
| 249 | * in the member flags, team private members will be included along with |
| 250 | * the others. If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag |
| 251 | * is not specified (recommended), the result will omit any team private |
| 252 | * member resources. |
| 253 | * </p> |
| 254 | * <p> |
| 255 | * If the <code>EXCLUDE_DERIVED</code> flag is not specified, derived |
| 256 | * resources are included. If the <code>EXCLUDE_DERIVED</code> flag is |
| 257 | * specified in the member flags, derived resources are not included. |
| 258 | * </p> |
| 259 | * |
| 260 | * @param memberFlags bit-wise or of member flag constants |
| 261 | * (<code>INCLUDE_PHANTOMS</code>, <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> |
| 262 | * and <code>EXCLUDE_DERIVED</code>) indicating which members are of interest |
| 263 | * @return an array of members of this resource |
| 264 | * @exception CoreException if this request fails. Reasons include: |
| 265 | * <ul> |
| 266 | * <li> This resource does not exist.</li> |
| 267 | * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and |
| 268 | * this resource does not exist.</li> |
| 269 | * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and |
| 270 | * this resource is a project that is not open.</li> |
| 271 | * </ul> |
| 272 | * @see IVirtualResource#exists() |
| 273 | * @since 2.0 |
| 274 | */ |
| 275 | public IVirtualResource[] members(int memberFlags) throws CoreException; |
cbridgha | a59090c | 2005-03-24 16:36:37 +0000 | [diff] [blame] | 276 | |
| 277 | public void commit() throws CoreException; |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 278 | } |
| 279 | |