Eclipse Platform
2.0

org.eclipse.core.resources
Interface IContainer

All Superinterfaces:
IAdaptable, IResource
All Known Subinterfaces:
IFolder, IProject, IWorkspaceRoot

public interface IContainer
extends IResource, IAdaptable

Interface for resources which may contain other resources (termed its members). While the workspace itself is not considered a container in this sense, the workspace root resource is a container.

This interface is not intended to be implemented by clients.

Containers implement the IAdaptable interface; extensions are managed by the platform's adapter manager.

See Also:
Platform.getAdapterManager(), IProject, IFolder, IWorkspaceRoot

Field Summary
static int INCLUDE_PHANTOMS
          Member constant (bit mask value 1) indicating that phantom member resources are to be included.
static int INCLUDE_TEAM_PRIVATE_MEMBERS
          Member constant (bit mask value 2) indicating that team private members are to be included.
 
Fields inherited from interface org.eclipse.core.resources.IResource
ALWAYS_DELETE_PROJECT_CONTENT, DEPTH_INFINITE, DEPTH_ONE, DEPTH_ZERO, FILE, FOLDER, FORCE, KEEP_HISTORY, NEVER_DELETE_PROJECT_CONTENT, NONE, NULL_STAMP, PROJECT, ROOT
 
Method Summary
 boolean exists(IPath path)
          Returns whether a resource of some type with the given path exists relative to this resource.
 IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor)
          Returns a list of recently deleted files inside this container that are have one or more saved states in the local history.
 IResource findMember(IPath path)
          Finds and returns the member resource identified by the given path in this container, or null if no such resource exists.
 IResource findMember(IPath path, boolean includePhantoms)
          Finds and returns the member resource identified by the given path in this container, or null if there is no such resource.
 IResource findMember(String name)
          Finds and returns the member resource (project, folder, or file) with the given name in this container, or null if no such resource exists.
 IResource findMember(String name, boolean includePhantoms)
          Finds and returns the member resource (project, folder, or file) with the given name in this container, or null if there is no such resource.
 IFile getFile(IPath path)
          Returns a handle to the file identified by the given path in this container.
 IFolder getFolder(IPath path)
          Returns a handle to the folder identified by the given path in this container.
 IResource[] members()
          Returns a list of existing member resources (projects, folders and files) in this resource, in no particular order.
 IResource[] members(boolean includePhantoms)
          Returns a list of all member resources (projects, folders and files) in this resource, in no particular order.
 IResource[] 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.core.resources.IResource
accept, accept, accept, clearHistory, copy, copy, copy, copy, createMarker, delete, delete, deleteMarkers, equals, exists, findMarker, findMarkers, getFileExtension, getFullPath, getLocation, getMarker, getModificationStamp, getName, getParent, getPersistentProperty, getProject, getProjectRelativePath, getSessionProperty, getType, getWorkspace, isAccessible, isDerived, isLocal, isPhantom, isReadOnly, isSynchronized, isTeamPrivateMember, move, move, move, move, refreshLocal, setDerived, setLocal, setPersistentProperty, setReadOnly, setSessionProperty, setTeamPrivateMember, touch
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

INCLUDE_PHANTOMS

public static final int INCLUDE_PHANTOMS
Member constant (bit mask value 1) indicating that phantom member resources are to be included.

Since:
2.0
See Also:
IResource.isPhantom(), Constant Field Values

INCLUDE_TEAM_PRIVATE_MEMBERS

public static final int INCLUDE_TEAM_PRIVATE_MEMBERS
Member constant (bit mask value 2) indicating that team private members are to be included.

Since:
2.0
See Also:
IResource.isTeamPrivateMember(), Constant Field Values
Method Detail

exists

public boolean exists(IPath path)
Returns whether a 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:
IResource.exists()

findMember

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

N.B. Unlike the methods which traffic strictly in resource handles, this method infers the resulting resource's type from the resource existing at the calculated path in the workspace.

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

findMember

public IResource findMember(String name,
                            boolean includePhantoms)
Finds and returns the member resource (project, 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 phantom member resource with the given name that the workspace is keeping track of.

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

N.B. Unlike the methods which traffic strictly in resource handles, this method infers the resulting resource's type from the existing resource (or phantom) in the workspace.

Parameters:
name - the string name of the member resource
includePhantoms - true if phantom resources are of interest; false if phantom resources are not of interest
Returns:
the member resource, or null if no such resource exists
See Also:
members(), IResource.isPhantom()

findMember

public IResource findMember(IPath path)
Finds and returns the member resource identified by the given path in this container, or null if no such resource exists. 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 returned.

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

N.B. Unlike the methods which traffic strictly in resource handles, this method infers the resulting resource's type from the resource existing at the calculated path in the workspace.

Parameters:
path - the path of the desired resource
Returns:
the member resource, or null if no such resource exists

findMember

public IResource findMember(IPath path,
                            boolean includePhantoms)
Finds and returns the member resource identified by the given path in this container, or null if there is no such 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 returned.

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

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

N.B. Unlike the methods which traffic strictly in resource handles, this method infers the resulting resource's type from the existing resource (or phantom) at the calculated path in the workspace.

Parameters:
path - the path of the desired resource
includePhantoms - true if phantom resources are of interest; false if phantom resources are not of interest
Returns:
the member resource, or null if no such resource exists
See Also:
members(boolean), IResource.isPhantom()

getFile

public IFile 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 resulting resource will have at least 3 segments.

Parameters:
path - the path of the member file
Returns:
the (handle of the) member file
See Also:
getFolder(org.eclipse.core.runtime.IPath)

getFolder

public IFolder 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 will have at least 2 segments.

Parameters:
path - the path of the member folder
Returns:
the (handle of the) member folder
See Also:
getFile(org.eclipse.core.runtime.IPath)

members

public IResource[] 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(IResource.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(java.lang.String), IResource.isAccessible()

members

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

This is a convenience method, fully equivalent to:

   members(includePhantoms ? INCLUDE_PHANTOMS : IResource.NONE);
 
Team-private member resources are not included in the result.

Parameters:
includePhantoms - true if phantom resources are of interest; false if phantom resources are not of interest.
Returns:
an array of members of this resource
Throws:
CoreException - if this request fails. Reasons include:
  • includePhantoms is false and this resource does not exist.
  • includePhantoms is false and this resource is a project that is not open.
See Also:
members(int), IResource.exists(), IResource.isPhantom()

members

public IResource[] 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.

Parameters:
memberFlags - bit-wise or of member flag constants (INCLUDE_PHANTOMS and INCLUDE_TEAM_PRIVATE_MEMBERS) indicating which members are of interest
Returns:
an array of members of this resource
Throws:
CoreException - if this request fails. Reasons include:
  • 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:
IResource.exists()

findDeletedMembersWithHistory

public IFile[] findDeletedMembersWithHistory(int depth,
                                             IProgressMonitor monitor)
                                      throws CoreException
Returns a list of recently deleted files inside this container that are have one or more saved states in the local history. The depth parameter determines how deep inside the container to look. This resource may or may not exist in the workspace.

When applied to an existing project resource, this method returns recently deleted files with saved states in that project. Note that local history is maintained with each individual project, and gets discarded when a project is deleted from the workspace. If applied to a deleted project, this method returns the empty list.

When applied to the workspace root resource (depth infinity), this method returns all recently deleted files with saved states in all existing projects.

When applied to a folder (or project) resource (depth one), this method returns all recently deleted member files with saved states.

When applied to a folder resource (depth zero), this method returns an empty list unless there was a recently deleted file with saved states with at same path as the folder.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Parameters:
depth - depth limit: one of DEPTH_ZERO, DEPTH_ONE or DEPTH_INFINITE
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Returns:
an array of recently deleted files
Throws:
CoreException - if this method fails
Since:
2.0
See Also:
IFile.getHistory(org.eclipse.core.runtime.IProgressMonitor)

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.