Eclipse Platform
Release 3.1

org.eclipse.core.resources
Interface IWorkspaceRoot

All Superinterfaces:
IAdaptable, IContainer, IResource, ISchedulingRule

public interface IWorkspaceRoot
extends IContainer, IAdaptable

A root resource represents the top of the resource hierarchy in a workspace. There is exactly one root in a workspace. The root resource has the following behavior:

This interface is not intended to be implemented by clients.

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

See Also:
Platform.getAdapterManager()

Field Summary
 
Fields inherited from interface org.eclipse.core.resources.IContainer
EXCLUDE_DERIVED, INCLUDE_PHANTOMS, INCLUDE_TEAM_PRIVATE_MEMBERS
 
Fields inherited from interface org.eclipse.core.resources.IResource
ALLOW_MISSING_LOCAL, ALWAYS_DELETE_PROJECT_CONTENT, AVOID_NATURE_CONFIG, BACKGROUND_REFRESH, DEPTH_INFINITE, DEPTH_ONE, DEPTH_ZERO, FILE, FOLDER, FORCE, KEEP_HISTORY, NEVER_DELETE_PROJECT_CONTENT, NONE, NULL_STAMP, PROJECT, ROOT, SHALLOW
 
Method Summary
 void delete(boolean deleteContent, boolean force, IProgressMonitor monitor)
          Deletes everything in the workspace except the workspace root resource itself.
 IContainer[] findContainersForLocation(IPath location)
          Returns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given path in the local file system.
 IFile[] findFilesForLocation(IPath location)
          Returns the handles of all files that are mapped to the given path in the local file system.
 IContainer getContainerForLocation(IPath location)
          Returns a handle to the workspace root, project or folder which is mapped to the given path in the local file system, or null if none.
 IFile getFileForLocation(IPath location)
          Returns a handle to the file which is mapped to the given path in the local file system, or null if none.
 IProject getProject(String name)
          Returns a handle to the project resource with the given name which is a child of this root.
 IProject[] getProjects()
          Returns the collection of projects which exist under this root.
 
Methods inherited from interface org.eclipse.core.resources.IContainer
exists, findDeletedMembersWithHistory, findMember, findMember, findMember, findMember, getDefaultCharset, getDefaultCharset, getFile, getFolder, members, members, members, setDefaultCharset, setDefaultCharset
 
Methods inherited from interface org.eclipse.core.resources.IResource
accept, accept, accept, accept, clearHistory, copy, copy, copy, copy, createMarker, delete, delete, deleteMarkers, equals, exists, findMarker, findMarkers, getFileExtension, getFullPath, getLocalTimeStamp, getLocation, getMarker, getModificationStamp, getName, getParent, getPersistentProperty, getProject, getProjectRelativePath, getRawLocation, getResourceAttributes, getSessionProperty, getType, getWorkspace, isAccessible, isDerived, isLinked, isLocal, isPhantom, isReadOnly, isSynchronized, isTeamPrivateMember, move, move, move, move, refreshLocal, revertModificationStamp, setDerived, setLocal, setLocalTimeStamp, setPersistentProperty, setReadOnly, setResourceAttributes, setSessionProperty, setTeamPrivateMember, touch
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 
Methods inherited from interface org.eclipse.core.runtime.jobs.ISchedulingRule
contains, isConflicting
 

Method Detail

delete

public void delete(boolean deleteContent,
                   boolean force,
                   IProgressMonitor monitor)
            throws CoreException
Deletes everything in the workspace except the workspace root resource itself.

This is a convenience method, fully equivalent to:

   delete(
     (deleteContent ? IResource.ALWAYS_DELETE_PROJECT_CONTENT : IResource.NEVER_DELETE_PROJECT_CONTENT )
        | (force ? FORCE : IResource.NONE),
     monitor);
 

This method changes resources; these changes will be reported in a subsequent resource change event.

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

Parameters:
deleteContent - a flag controlling how whether content is aggressively deleted
force - a flag controlling whether resources that are not in sync with the local file system will be tolerated
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
CoreException - if this method fails. Reasons include:
  • A project could not be deleted.
  • A project's contents could not be deleted.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
OperationCanceledException - if the operation is canceled. Cancelation can occur even if no progress monitor is provided.
See Also:
IResource.delete(int,IProgressMonitor)

findContainersForLocation

public IContainer[] findContainersForLocation(IPath location)
Returns the handles to all the resources (workspace root, project, folder) in the workspace which are mapped to the given path in the local file system. Returns an empty array if there are none.

If the path maps to the platform working location, the returned object will be a single element array consisting of an object of type ROOT.

If the path maps to a project, the resulting object will be a single element array consisting of an object of type PROJECT; otherwise the resulting array will contain folders (type FOLDER).

The path must be absolute; its segments need not be valid names; a trailing separator is ignored. The resulting resource(s) need not exist in the workspace.

Parameters:
location - a path in the local file system
Returns:
the corresponding containers in the workspace, or an empty array if none
Since:
2.1

findFilesForLocation

public IFile[] findFilesForLocation(IPath location)
Returns the handles of all files that are mapped to the given path in the local file system. Returns an empty array if there are none. The path must be absolute; its segments need not be valid names. The resulting file(s) need not exist in the workspace.

Parameters:
location - a path in the local file system
Returns:
the corresponding files in the workspace, or an empty array if none
Since:
2.1

getContainerForLocation

public IContainer getContainerForLocation(IPath location)
Returns a handle to the workspace root, project or folder which is mapped to the given path in the local file system, or null if none. If the path maps to the platform working location, the returned object will be of type ROOT. If the path maps to a project, the resulting object will be of type PROJECT; otherwise the resulting object will be a folder (type FOLDER). The path must be absolute; its segments need not be valid names; a trailing separator is ignored. The resulting resource need not exist in the workspace.

This method returns null when the given file system location is not equal to or under the location of any existing project in the workspace, or equal to the location of the platform working location.

Warning: This method ignores linked resources and their children. Since linked resources may overlap other resources, a unique mapping from a file system location to a single resource is not guaranteed. To find all resources for a given location, including linked resources, use the method findContainersForLocation.

Parameters:
location - a path in the local file system
Returns:
the corresponding project or folder in the workspace, or null if none

getFileForLocation

public IFile getFileForLocation(IPath location)
Returns a handle to the file which is mapped to the given path in the local file system, or null if none. The path must be absolute; its segments need not be valid names. The resulting file need not exist in the workspace.

This method returns null when the given file system location is not under the location of any existing project in the workspace.

Warning: This method ignores linked resources and their children. Since linked resources may overlap other resources, a unique mapping from a file system location to a single resource is not guaranteed. To find all resources for a given location, including linked resources, use the method findFilesForLocation.

Parameters:
location - a path in the local file system
Returns:
the corresponding file in the workspace, or null if none

getProject

public IProject getProject(String name)
Returns a handle to the project resource with the given name which is a child of this root.

Note: This method deals exclusively with resource handles, independent of whether the resources exist in the workspace. The validation check on the project name is not done when the project handle is constructed; rather, it is done automatically as the project is created.

Parameters:
name - the name of the project
Returns:
a project resource handle
See Also:
getProjects()

getProjects

public IProject[] getProjects()
Returns the collection of projects which exist under this root. The projects can be open or closed.

Returns:
an array of projects
See Also:
getProject(String)

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.