org.eclipse.wst.common.componentcore.resources
Interface IVirtualContainer

All Superinterfaces:
IVirtualResource
All Known Subinterfaces:
IVirtualComponent, IVirtualFolder

public interface IVirtualContainer
extends IVirtualResource

Represents a component as defined by the WTP Modules file. A virtual container represents the root of the component.

Virtual containers can provide handles to virtual files and virtual folders that it contains.

To acquire a handle to a component, use the following snippet:
ModuleCore.createContainer(containingProject, componentName) which will create a handle to a virtual container contained by containingProject with the name componentName. If the a component of the given name exists, then IVirtualResource.exists() will return true. Otherwise, use create(int, IProgressMonitor) to create the relevant model elements. If a client needs to add a mapping from a folder in the same project to root, use IVirtualResource.createLink(IPath, int, IProgressMonitor) with a project-relative path.

This interface is not intended to be implemented by clients.

Since:
1.0

Field Summary
 
Fields inherited from interface org.eclipse.wst.common.componentcore.resources.IVirtualResource
COMPONENT, FILE, FOLDER, FORCE, IGNORE_EXCLUSIONS, IGNORE_UNDERLYING_RESOURCE, NONE
 
Method Summary
 void create(int updateFlags, IProgressMonitor aMonitor)
          Create the underlying model elements if they do not already exist.
 boolean exists(IPath path)
          Returns whether a virtual resource of some type with the given path exists relative to this resource.
 IVirtualResource findMember(java.lang.String name)
          Finds and returns the member virtual resource (folder or file) with the given name in this container, or null if no such resource exists.
 IVirtualResource findMember(java.lang.String name, int searchFlags)
          Finds and returns the member resource (folder, or file) with the given name in this container, or null if there is no such resource.
 IVirtualFile getFile(IPath path)
          Returns a handle to the file identified by the given path in this container.
 IVirtualFolder getFolder(IPath path)
          Returns a handle to the folder identified by the given path in this container.
 IVirtualResource[] members()
          Returns a list of existing member resources (projects, folders and files) in this resource, in no particular order.
 IVirtualResource[] members(int memberFlags)
          Returns a list of all member resources (projects, folders and files) in this resource, in no particular order.
 
Methods inherited from interface org.eclipse.wst.common.componentcore.resources.IVirtualResource
createLink, delete, equals, exists, getComponent, getFileExtension, getName, getParent, getProject, getProjectRelativePath, getResourceType, getRuntimePath, getType, getUnderlyingResource, getUnderlyingResources, getWorkspaceRelativePath, isAccessible, setResourceType
 

Method Detail

create

public void create(int updateFlags,
                   IProgressMonitor aMonitor)
            throws CoreException
Create the underlying model elements if they do not already exist. Resources may be created as a result of this method if the mapped path does not exist.

Parameters:
updateFlags - Any of IVirtualResource or IResource update flags. If a resource must be created, the updateFlags will be supplied to the resource creation operation.
aMonitor -
Throws:
CoreException

exists

public boolean exists(IPath path)
Returns whether a virtual resource of some type with the given path exists relative to this resource. The supplied path may be absolute or relative; in either case, it is interpreted as relative to this resource. Trailing separators are ignored. If the path is empty this container is checked for existence.

Parameters:
path - the path of the resource
Returns:
true if a resource of some type with the given path exists relative to this resource, and false otherwise
See Also:
IVirtualResource.exists()

findMember

public IVirtualResource findMember(java.lang.String name)
Finds and returns the member virtual resource (folder or file) with the given name in this container, or null if no such resource exists.

Parameters:
name - the string name of the member resource
Returns:
the member resource, or null if no such resource exists

findMember

public IVirtualResource findMember(java.lang.String name,
                                   int searchFlags)
Finds and returns the member resource (folder, or file) with the given name in this container, or null if there is no such resource.

If the includePhantoms argument is false, only a member resource with the given name that exists will be returned. If the includePhantoms argument is true, the method also returns a resource if the workspace is keeping track of a phantom with that name.

Note that no attempt is made to exclude team-private member resources as with members.

Parameters:
name - the string name of the member resource
Returns:
the member resource, or null if no such resource exists
See Also:
members(), IVirtualResource#isPhantom()

getFile

public IVirtualFile getFile(IPath path)
Returns a handle to the file identified by the given path in this container.

This is a resource handle operation; neither the resource nor the result need exist in the workspace. The validation check on the resource name/path is not done when the resource handle is constructed; rather, it is done automatically as the resource is created.

The supplied path may be absolute or relative; in either case, it is interpreted as relative to this resource and is appended to this container's full path to form the full path of the resultant resource. A trailing separator is ignored. The path of the resulting resource must have at least two segments.

Parameters:
path - the path of the member file
Returns:
the (handle of the) member file
See Also:
getFolder(IPath)

getFolder

public IVirtualFolder getFolder(IPath path)
Returns a handle to the folder identified by the given path in this container.

This is a resource handle operation; neither the resource nor the result need exist in the workspace. The validation check on the resource name/path is not done when the resource handle is constructed; rather, it is done automatically as the resource is created.

The supplied path may be absolute or relative; in either case, it is interpreted as relative to this resource and is appended to this container's full path to form the full path of the resultant resource. A trailing separator is ignored. The path of the resulting resource must have at least two segments.

Parameters:
path - the path of the member folder
Returns:
the (handle of the) member folder
See Also:
getFile(IPath)

members

public IVirtualResource[] members()
                           throws CoreException
Returns a list of existing member resources (projects, folders and files) in this resource, in no particular order.

This is a convenience method, fully equivalent to members(IVirtualResource.NONE). Team-private member resources are not included in the result.

Note that the members of a project or folder are the files and folders immediately contained within it. The members of the workspace root are the projects in the workspace.

Returns:
an array of members of this resource
Throws:
CoreException - if this request fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.
See Also:
#findMember(IPath), IVirtualResource.isAccessible()

members

public IVirtualResource[] members(int memberFlags)
                           throws CoreException
Returns a list of all member resources (projects, folders and files) in this resource, in no particular order.

If the INCLUDE_PHANTOMS flag is not specified in the member flags (recommended), only member resources that exist will be returned. If the INCLUDE_PHANTOMS flag is specified, the result will also include any phantom member resources the workspace is keeping track of.

If the INCLUDE_TEAM_PRIVATE_MEMBERS flag is specified in the member flags, team private members will be included along with the others. If the INCLUDE_TEAM_PRIVATE_MEMBERS flag is not specified (recommended), the result will omit any team private member resources.

If the EXCLUDE_DERIVED flag is not specified, derived resources are included. If the EXCLUDE_DERIVED flag is specified in the member flags, derived resources are not included.

Parameters:
memberFlags - bit-wise or of member flag constants (INCLUDE_PHANTOMS, INCLUDE_TEAM_PRIVATE_MEMBERS and EXCLUDE_DERIVED) indicating which members are of interest
Returns:
an array of members of this resource
Throws:
CoreException - if this request fails. Reasons include:
  • This resource does not exist.
  • the INCLUDE_PHANTOMS flag is not specified and this resource does not exist.
  • the INCLUDE_PHANTOMS flag is not specified and this resource is a project that is not open.
Since:
2.0
See Also:
IVirtualResource.exists()