Eclipse Platform
2.0

org.eclipse.core.resources
Interface IResource

All Superinterfaces:
IAdaptable
All Known Subinterfaces:
IContainer, IFile, IFolder, IProject, IWorkspaceRoot

public interface IResource
extends IAdaptable

The workspace analog of file system files and directories. There are exactly four types of resource: files, folders, projects and the workspace root.

File resources are similar to files in that they hold data directly. Folder resources are analogous to directories in that they hold other resources but cannot directly hold data. Project resources group files and folders into reusable clusters. The workspace root is the top level resource under which all others reside.

Features of resources:

This interface is not intended to be implemented by clients.

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

See Also:
IWorkspace, Platform.getAdapterManager()

Field Summary
static int ALWAYS_DELETE_PROJECT_CONTENT
          Update flag constant (bit mask value 4) indicating that the operation should delete the files and folders of a project.
static int DEPTH_INFINITE
          Depth constant (value 2) indicating this resource and its direct and indirect members at any depth.
static int DEPTH_ONE
          Depth constant (value 1) indicating this resource and its direct members.
static int DEPTH_ZERO
          Depth constant (value 0) indicating this resource, but not any of its members.
static int FILE
          Type constant (bit mask value 1) which identifies file resources.
static int FOLDER
          Type constant (bit mask value 2) which identifies folder resources.
static int FORCE
          Update flag constant (bit mask value 1) indicating that the operation if to proceed even if the resource is out of sync with the local file system.
static int KEEP_HISTORY
          Update flag constant (bit mask value 2) indicating that the operation should maintain local history by taking snapshots of the contents of files just before being overwritten or deleted.
static int NEVER_DELETE_PROJECT_CONTENT
          Update flag constant (bit mask value 4) indicating that the operation should preserve the files and folders of a project.
static int NONE
          General purpose zero-valued bit mask constant.
static int NULL_STAMP
          Modification stamp constant (value -1) indicating no modification stamp is available.
static int PROJECT
          Type constant (bit mask value 4) which identifies project resources.
static int ROOT
          Type constant (bit mask value 8) which identifies the root resource.
 
Method Summary
 void accept(IResourceVisitor visitor)
          Accepts the given visitor.
 void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
          Accepts the given visitor.
 void accept(IResourceVisitor visitor, int depth, int memberFlags)
          Accepts the given visitor.
 void clearHistory(IProgressMonitor monitor)
          Removes the local history of this resource and its descendants.
 void copy(IPath destination, boolean force, IProgressMonitor monitor)
          Makes a copy of this resource at the given path.
 void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
          Makes a copy of this resource at the given path.
 void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
          Makes a copy of this project using the given project description.
 void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
          Makes a copy of this project using the given project description.
 IMarker createMarker(String type)
          Creates and returns the marker with the specified type on this resource.
 void delete(boolean force, IProgressMonitor monitor)
          Deletes this resource from the workspace.
 void delete(int updateFlags, IProgressMonitor monitor)
          Deletes this resource from the workspace.
 void deleteMarkers(String type, boolean includeSubtypes, int depth)
          Deletes all markers on this resource of the given type, and, optionally, deletes such markers from its children.
 boolean equals(Object other)
          Compares two objects for equality; for resources, equality is defined in terms of their handles: same resource type, equal full paths, and identical workspaces.
 boolean exists()
          Returns whether this resource exists in the workspace.
 IMarker findMarker(long id)
          Returns the marker with the specified id on this resource, Returns null if there is no matching marker.
 IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
          Returns all markers of the specified type on this resource, and, optionally, on its children.
 String getFileExtension()
          Returns the file extension portion of this resource's name, or null if it does not have one.
 IPath getFullPath()
          Returns the full, absolute path of this resource relative to the workspace.
 IPath getLocation()
          Returns the absolute path in the local file system to this resource, or null if no path can be determined.
 IMarker getMarker(long id)
          Returns a marker handle with the given id on this resource.
 long getModificationStamp()
          Returns a non-negative modification stamp, or NULL_STAMP if the resource does not exist or is not local or is not accessible.
 String getName()
          Returns the name of this resource.
 IContainer getParent()
          Returns the resource which is the parent of this resource, or null if it has no parent (that is, this resource is the workspace root).
 String getPersistentProperty(QualifiedName key)
          Returns the value of the persistent property of this resource identified by the given key, or null if this resource has no such property.
 IProject getProject()
          Returns the project which contains this resource.
 IPath getProjectRelativePath()
          Returns a relative path of this resource with respect to its project.
 Object getSessionProperty(QualifiedName key)
          Returns the value of the session property of this resource identified by the given key, or null if this resource has no such property.
 int getType()
          Returns the type of this resource.
 IWorkspace getWorkspace()
          Returns the workspace which manages this resource.
 boolean isAccessible()
          Returns whether this resource is accessible.
 boolean isDerived()
          Returns whether this resource subtree is marked as derived.
 boolean isLocal(int depth)
          Returns whether this resource and its members (to the specified depth) are expected to have their contents (and properties) available locally.
 boolean isPhantom()
          Returns whether this resource is a phantom resource.
 boolean isReadOnly()
          Returns whether this resource is marked as read-only in the file system.
 boolean isSynchronized(int depth)
          Returns whether this resource and its descendants to the given depth are considered to be in sync with the local file system.
 boolean isTeamPrivateMember()
          Returns whether this resource is a team private member of its parent container.
 void move(IPath destination, boolean force, IProgressMonitor monitor)
          Moves this resource so that it is located at the given path.
 void move(IPath destination, int updateFlags, IProgressMonitor monitor)
          Moves this resource so that it is located at the given path.
 void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor)
          Renames or relocates this project so that it is the project specified by the given project description.
 void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
          Renames or relocates this project so that it is the project specified by the given project description.
 void refreshLocal(int depth, IProgressMonitor monitor)
          Refreshes the resource hierarchy from this resource and its children (to the specified depth) relative to the local file system.
 void setDerived(boolean isDerived)
          Sets whether this resource subtree is marked as derived.
 void setLocal(boolean flag, int depth, IProgressMonitor monitor)
          Set whether or not this resource and its members (to the specified depth) are expected to have their contents (and properties) available locally.
 void setPersistentProperty(QualifiedName key, String value)
          Sets the value of the persistent property of this resource identified by the given key.
 void setReadOnly(boolean readOnly)
          Sets or unsets this resource as read-only in the file system.
 void setSessionProperty(QualifiedName key, Object value)
          Sets the value of the session property of this resource identified by the given key.
 void setTeamPrivateMember(boolean isTeamPrivate)
          Sets whether this resource subtree is a team private member of its parent container.
 void touch(IProgressMonitor monitor)
          Marks this resource as having changed even though its content may not have changed.
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

FILE

public static final int FILE
Type constant (bit mask value 1) which identifies file resources.

See Also:
getType(), IFile, Constant Field Values

FOLDER

public static final int FOLDER
Type constant (bit mask value 2) which identifies folder resources.

See Also:
getType(), IFolder, Constant Field Values

PROJECT

public static final int PROJECT
Type constant (bit mask value 4) which identifies project resources.

See Also:
getType(), IProject, Constant Field Values

ROOT

public static final int ROOT
Type constant (bit mask value 8) which identifies the root resource.

See Also:
getType(), IWorkspaceRoot, Constant Field Values

DEPTH_ZERO

public static final int DEPTH_ZERO
Depth constant (value 0) indicating this resource, but not any of its members.

See Also:
Constant Field Values

DEPTH_ONE

public static final int DEPTH_ONE
Depth constant (value 1) indicating this resource and its direct members.

See Also:
Constant Field Values

DEPTH_INFINITE

public static final int DEPTH_INFINITE
Depth constant (value 2) indicating this resource and its direct and indirect members at any depth.

See Also:
Constant Field Values

FORCE

public static final int FORCE
Update flag constant (bit mask value 1) indicating that the operation if to proceed even if the resource is out of sync with the local file system.

Since:
2.0
See Also:
Constant Field Values

KEEP_HISTORY

public static final int KEEP_HISTORY
Update flag constant (bit mask value 2) indicating that the operation should maintain local history by taking snapshots of the contents of files just before being overwritten or deleted.

Since:
2.0
See Also:
IFile.getHistory(org.eclipse.core.runtime.IProgressMonitor), Constant Field Values

ALWAYS_DELETE_PROJECT_CONTENT

public static final int ALWAYS_DELETE_PROJECT_CONTENT
Update flag constant (bit mask value 4) indicating that the operation should delete the files and folders of a project.

Deleting a project that is open ordinarily deletes all its files and folders, whereas deleting a project that is closed retains its files and folders. Specifying ALWAYS_DELETE_PROJECT_CONTENT indicates that the contents of a project are to be deleted regardless of whether the project is open or closed at the time; specifying NEVER_DELETE_PROJECT_CONTENT indicates that the contents of a project are to be retained regardless of whether the project is open or closed at the time.

Since:
2.0
See Also:
NEVER_DELETE_PROJECT_CONTENT, Constant Field Values

NEVER_DELETE_PROJECT_CONTENT

public static final int NEVER_DELETE_PROJECT_CONTENT
Update flag constant (bit mask value 4) indicating that the operation should preserve the files and folders of a project.

Deleting a project that is open ordinarily deletes all its files and folders, whereas deleting a project that is closed retains its files and folders. Specifying ALWAYS_DELETE_PROJECT_CONTENT indicates that the contents of a project are to be deleted regardless of whether the project is open or closed at the time; specifying NEVER_DELETE_PROJECT_CONTENT indicates that the contents of a project are to be retained regardless of whether the project is open or closed at the time.

Since:
2.0
See Also:
ALWAYS_DELETE_PROJECT_CONTENT, Constant Field Values

NULL_STAMP

public static final int NULL_STAMP
Modification stamp constant (value -1) indicating no modification stamp is available.

See Also:
getModificationStamp(), Constant Field Values

NONE

public static final int NONE
General purpose zero-valued bit mask constant. Useful whenever you need to supply a bit mask with no bits set.

Example usage:

    delete(IResource.NONE, null)
 

Since:
2.0
See Also:
Constant Field Values
Method Detail

accept

public void accept(IResourceVisitor visitor)
            throws CoreException
Accepts the given visitor. The visitor's visit method is called with this resource. If the visitor returns true, this method visits this resource's members.

This is a convenience method, fully equivalent to accept(visitor,IResource.NONE,DEPTH_INFINITE).

Parameters:
visitor - the visitor
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • The visitor failed with this exception.
See Also:
IResourceVisitor.visit(org.eclipse.core.resources.IResource), accept(IResourceVisitor,int,int)

accept

public void accept(IResourceVisitor visitor,
                   int depth,
                   boolean includePhantoms)
            throws CoreException
Accepts the given visitor. The visitor's visit method is called with this resource. If the visitor returns false, this resource's members are not visited.

The subtree under the given resource is traversed to the supplied depth.

This is a convenience method, fully equivalent to:

   accept(visitor, depth, includePhantoms ? INCLUDE_PHANTOMS : IResource.NONE);
 

Parameters:
visitor - the visitor
depth - the depth to which members of this resource should be visited. One of DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE.
includePhantoms - true if phantom resources are of interest; false if phantom resources are not of interest.
Throws:
CoreException - if this request fails. Reasons include:
  • includePhantoms is false and this resource does not exist.
  • includePhantoms is true and this resource does not exist and is not a phantom.
  • The visitor failed with this exception.
See Also:
isPhantom(), IResourceVisitor.visit(org.eclipse.core.resources.IResource), DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE, accept(IResourceVisitor,int,int)

accept

public void accept(IResourceVisitor visitor,
                   int depth,
                   int memberFlags)
            throws CoreException
Accepts the given visitor. The visitor's visit method is called with this resource. If the visitor returns false, this resource's members are not visited.

The subtree under the given resource is traversed to the supplied depth.

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

If the INCLUDE_TEAM_PRIVATE_MEMBERS flag is not specified (recommended), team private members will not be visited. If the INCLUDE_TEAM_PRIVATE_MEMBERS flag is specified in the member flags, team private member resources are visited as well.

Parameters:
visitor - the visitor
depth - the depth to which members of this resource should be visited. One of DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE.
memberFlags - bit-wise or of member flag constants (IContainer.INCLUDE_PHANTOMS and INCLUDE_TEAM_PRIVATE_MEMBERS) indicating which members are of interest
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.
  • The visitor failed with this exception.
Since:
2.0
See Also:
IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS, isPhantom(), isTeamPrivateMember(), DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE, IResourceVisitor.visit(org.eclipse.core.resources.IResource)

clearHistory

public void clearHistory(IProgressMonitor monitor)
                  throws CoreException
Removes the local history of this resource and its descendants.

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

Parameters:
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
CoreException

copy

public void copy(IProjectDescription description,
                 boolean force,
                 IProgressMonitor monitor)
          throws CoreException
Makes a copy of this project using the given project description.

This is a convenience method, fully equivalent to:

   copy(description, (force ? FORCE : IResource.NONE), monitor);
 

This operation changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource copy has been added to its new parent.

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

Parameters:
description - the destination project description
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 and cancellation are not desired
Throws:
CoreException - if this resource could not be copied. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • This resource is not a project.
  • The project described by the given description already exists.
  • This resource or one of its descendents is out of sync with the local file system and force is false.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.

copy

public void copy(IPath destination,
                 boolean force,
                 IProgressMonitor monitor)
          throws CoreException
Makes a copy of this resource at the given path.

This is a convenience method, fully equivalent to:

   copy(destination, (force ? FORCE : IResource.NONE), monitor);
 

This operation changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource copy has been added to its new parent.

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

Parameters:
destination - the destination path
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 and cancellation are not desired
Throws:
CoreException - if this resource could not be copied. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • The source or destination is the workspace root.
  • The source is a project but the destination is not.
  • The destination is a project but the source is not.
  • The resource corresponding to the parent destination path does not exist.
  • The resource corresponding to the parent destination path is a closed project.
  • A resource at destination path does exist.
  • This resource or one of its descendents is out of sync with the local file system and force is false.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • The source resource is a file and the destination path specifies a project.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.

copy

public void copy(IProjectDescription description,
                 int updateFlags,
                 IProgressMonitor monitor)
          throws CoreException
Makes a copy of this project using the given project description. The project's descendents are copied as well. The description specifies the name, location and attributes of the new project. After successful completion, corresponding new resources will exist at the given path; their contents and properties will be copies of the originals. The original resources are not affected.

When a resource is copied, its persistent properties are copied with it. Session properties and markers are not copied.

The FORCE update flag controls how this method deals with cases where the workspace is not completely in sync with the local file system. If FORCE is not specified, the method will only attempt to copy resources that are in sync with the corresponding files and directories in the local file system; it will fail if it encounters a resource that is out of sync with the file system. However, if FORCE is specified, the method copies all corresponding files and directories from the local file system, including ones that have been recently updated or created. Note that in both settings of the FORCE flag, the operation fails if the newly created resources in the workspace would be out of sync with the local file system; this ensures files in the file system cannot be accidentally overwritten.

Update flags other than FORCE are ignored.

This operation changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource copy has been added to its new parent.

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

Parameters:
description - the destination project description
updateFlags - bit-wise or of update flag constants (only FORCE is relevant here)
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this resource could not be copied. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • This resource is not a project.
  • The project described by the given description already exists.
  • This resource or one of its descendents is out of sync with the local file system and FORCE is not specified.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
Since:
2.0

copy

public void copy(IPath destination,
                 int updateFlags,
                 IProgressMonitor monitor)
          throws CoreException
Makes a copy of this resource at the given path. The resource's descendents are copied as well. The path of this resource must not be a prefix of the destination path. The workspace root may not be the source or destination location of a copy operation, and a project can only be copied to another project. After successful completion, corresponding new resources will exist at the given path; their contents and properties will be copies of the originals. The original resources are not affected.

The supplied path may be absolute or relative. Absolute paths fully specify the new location for the resource, including its project. Relative paths are considered to be relative to the container of the resource being copied. A trailing separator is ignored.

Calling this method with a one segment absolute destination path is equivalent to calling:

   copy(workspace.newProjectDescription(folder.getName()),updateFlags,monitor);
 

When a resource is copied, its persistent properties are copied with it. Session properties and markers are not copied.

The FORCE update flag controls how this method deals with cases where the workspace is not completely in sync with the local file system. If FORCE is not specified, the method will only attempt to copy resources that are in sync with the corresponding files and directories in the local file system; it will fail if it encounters a resource that is out of sync with the file system. However, if FORCE is specified, the method copies all corresponding files and directories from the local file system, including ones that have been recently updated or created. Note that in both settings of the FORCE flag, the operation fails if the newly created resources in the workspace would be out of sync with the local file system; this ensures files in the file system cannot be accidentally overwritten.

Update flags other than FORCE are ignored.

This operation changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource copy has been added to its new parent.

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

Parameters:
destination - the destination path
updateFlags - bit-wise or of update flag constants (only FORCE is relevant here)
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this resource could not be copied. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • The source or destination is the workspace root.
  • The source is a project but the destination is not.
  • The destination is a project but the source is not.
  • The resource corresponding to the parent destination path does not exist.
  • The resource corresponding to the parent destination path is a closed project.
  • A resource at destination path does exist.
  • This resource or one of its descendents is out of sync with the local file system and FORCE is not specified.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • The source resource is a file and the destination path specifies a project.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
Since:
2.0
See Also:
FORCE

createMarker

public IMarker createMarker(String type)
                     throws CoreException
Creates and returns the marker with the specified type on this resource. Marker type ids are the id of an extension installed in the org.eclipse.core.resources.markers extension point.

Parameters:
type - the type of the marker to create
Returns:
the handle of the new marker
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.

delete

public void delete(boolean force,
                   IProgressMonitor monitor)
            throws CoreException
Deletes this resource from the workspace.

This is a convenience method, fully equivalent to:

   delete(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:
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 and cancellation are not desired
Throws:
CoreException - if this method fails. Reasons include:
  • This resource could not be deleted for some reason.
  • This resource or one of its descendents is out of sync with the local file system and force is false.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
delete(int,IProgressMonitor)

delete

public void delete(int updateFlags,
                   IProgressMonitor monitor)
            throws CoreException
Deletes this resource from the workspace. Deletion applies recursively to all members of this resource in a "best-effort" fashion. That is, all resources which can be deleted are deleted. Resources which could not be deleted are noted in a thrown exception. The method does not fail if resources do not exist; it fails only if resources could not be deleted.

Deleting a resource also deletes its contents from the local file system. In the case of a file or folder resource, the corresponding file or directory in the local file system is deleted. Deleting an open project recursively deletes its members; deleting a closed project just gets rid of the project itself (closed projects have no members); files in the project's local content area are retained; referenced projects are unaffected. Deleting the workspace root deletes all projects from the workspace and all properties, markers, etc. from the root. The root itself is not deleted though its properties and markers are deleted.

Deleting a resource also deletes its session and persistent properties and markers.

Deleting a non-project resource which has sync information converts the resource to a phantom and retains the sync information for future use.

Deleting the workspace root resource recursively deletes all projects, and removes all markers, properties, sync info and other data related to the workspace root; the root resource itself is not deleted, however.

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.

The FORCE update flag controls how this method deals with cases where the workspace is not completely in sync with the local file system. If FORCE is not specified, the method will only attempt to delete files and directories in the local file system that correspond to, and are in sync with, resources in the workspace; it will fail if it encounters a file or directory in the file system that is out of sync with the workspace. This option ensures there is no unintended data loss; it is the recommended setting. However, if FORCE is specified, the method will ruthlessly attempt to delete corresponding files and directories in the local file system, including ones that have been recently updated or created.

The KEEP_HISTORY update flag controls whether or not file that are about to be deleted from the local file system have their current contents saved in the workspace's local history. The local history mechanism serves as a safety net to help the user recover from mistakes that might otherwise result in data loss. Specifying KEEP_HISTORY is recommended except in circumstances where past states of the files are of no conceivable interested to the user. Note that local history is maintained with each individual project, and gets discarded when a project is deleted from the workspace. Hence KEEP_HISTORY is only really applicable when deleting files and folders, but not projects.

The ALWAYS_DELETE_PROJECT_CONTENTS update flag controls how project deletions are handled. If ALWAYS_DELETE_PROJECT_CONTENTS is specified, then the files and folders in a project's local content area are deleted, regardless of whether the project is open or closed; FORCE is assumed regardless of whether it is specified. If NEVER_DELETE_PROJECT_CONTENTS is specified, then the files and folders in a project's local content area are retained, regardless of whether the project is open or closed; the FORCE flag is ignored. If neither of these flags is specified, files and folders in a project's local content area from open projects (subject to the FORCE flag), but never from closed projects.

Parameters:
updateFlags - bit-wise or of update flag constants ( FORCE, KEEP_HISTORY, ALWAYS_DELETE_PROJECT_CONTENTS, and NEVER_DELETE_PROJECT_CONTENTS)
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this method fails. Reasons include:
  • This resource could not be deleted for some reason.
  • This resource or one of its descendents is out of sync with the local file system and FORCE is not specified.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
Since:
2.0
See Also:
IFile.delete(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor), IFolder.delete(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor), FORCE, KEEP_HISTORY, #ALWAYS_DELETE_PROJECT_CONTENTS, #NEVER_DELETE_PROJECT_CONTENTS

deleteMarkers

public void deleteMarkers(String type,
                          boolean includeSubtypes,
                          int depth)
                   throws CoreException
Deletes all markers on this resource of the given type, and, optionally, deletes such markers from its children. If includeSubtypes is false, only markers whose type exactly matches the given type are deleted.

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

Parameters:
type - the type of marker to consider, or null to indicate all types
includeSubtypes - whether or not to consider subtypes of the given type
depth - how far to recurse (see IResource.DEPTH_* )
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE

equals

public boolean equals(Object other)
Compares two objects for equality; for resources, equality is defined in terms of their handles: same resource type, equal full paths, and identical workspaces. Resources are not equal to objects other than resources.

Overrides:
equals in class Object
Parameters:
other - the other object
Returns:
an indication of whether the objects are equals
See Also:
getType(), getFullPath(), getWorkspace()

exists

public boolean exists()
Returns whether this resource exists in the workspace.

IResource objects are lightweight handle objects used to access resources in the workspace. However, having a handle object does not necessarily mean the workspace really has such a resource. When the workspace does have a genuine resource of a matching type, the resource is said to exist, and this method returns true; in all other cases, this method returns false. In particular, it returns false if the workspace has no resource at that path, or if it has a resource at that path with a type different from the type of this resource handle.

Note that no resources ever exist under a project that is closed; opening a project may bring some resources into existence.

The name and path of a resource handle may be invalid. However, validation checks are done automatically as a resource is created; this means that any resource that exists can be safely assumed to have a valid name and path.

Returns:
true if the resource exists, otherwise false

findMarker

public IMarker findMarker(long id)
                   throws CoreException
Returns the marker with the specified id on this resource, Returns null if there is no matching marker.

Parameters:
id - the id of the marker to find
Returns:
a marker or null
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.

findMarkers

public IMarker[] findMarkers(String type,
                             boolean includeSubtypes,
                             int depth)
                      throws CoreException
Returns all markers of the specified type on this resource, and, optionally, on its children. If includeSubtypes is false, only markers whose type exactly matches the given type are returned. Returns an empty array if there are no matching markers.

Parameters:
type - the type of marker to consider, or null to indicate all types
includeSubtypes - whether or not to consider subtypes of the given type
depth - how far to recurse (see IResource.DEPTH_* )
Returns:
an array of markers
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.
See Also:
DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE

getFileExtension

public String getFileExtension()
Returns the file extension portion of this resource's name, or null if it does not have one.

The file extension portion is defined as the string following the last period (".") character in the name. If there is no period in the name, the path has no file extension portion. If the name ends in a period, the file extension portion is the empty string.

This is a resource handle operation; the resource need not exist.

Returns:
a string file extension
See Also:
getName()

getFullPath

public IPath getFullPath()
Returns the full, absolute path of this resource relative to the workspace.

This is a resource handle operation; the resource need not exist. If this resource does exist, its path can be safely assumed to be valid.

A resource's full path indicates the route from the root of the workspace to the resource. Within a workspace, there is exactly one such path for any given resource. The first segment of these paths name a project; remaining segments, folders and/or files within that project. The returned path never has a trailing separator. The path of the workspace root is Path.ROOT.

Since absolute paths contain the name of the project, they are vulnerable when the project is renamed. For most situations, project-relative paths are recommended over absolute paths.

Returns:
the absolute path of this resource
See Also:
getProjectRelativePath(), Path.ROOT

getLocation

public IPath getLocation()
Returns the absolute path in the local file system to this resource, or null if no path can be determined.

If this resource is the workspace root, this method returns the absolute local file system path of the platform working area.

If this resource is a project that exists in the workspace, this method returns the path to the project's local content area. This is true regardless of whether the project is open or closed.

If this resource is a file or folder under a project that exists, this method returns a (non-null) path computed from the location of the project's local content area and the project-relative path of the file or folder. This is true regardless of whether the file or folders exists, or whether the project is open or closed.

If this resource is a project that does not exist in the workspace, or a file or folder below such a project, this method returns null.

Returns:
the absolute path of this resource in the local file system, or null if no path can be determined
See Also:
IProjectDescription.setLocation(org.eclipse.core.runtime.IPath), Platform.getLocation()

getMarker

public IMarker getMarker(long id)
Returns a marker handle with the given id on this resource. This resource is not checked to see if it has such a marker. The returned marker need not exist. This resource need not exist.

Parameters:
id - the id of the marker
Returns:
the specified marker handle
See Also:
IMarker.getId()

getModificationStamp

public long getModificationStamp()
Returns a non-negative modification stamp, or NULL_STAMP if the resource does not exist or is not local or is not accessible.

A resource's modification stamp gets updated each time a resource is modified. If a resource's modification stamp is the same, the resource has not changed. Conversely, if a resource's modification stamp is different, some aspect of it (other than properties) has been modified at least once (possibly several times). Resource modification stamps are preserved across project close/re-open, and across workspace shutdown/restart. The magnitude or sign of the numerical difference between two modification stamps is not significant.

The following things affect a resource's modification stamp:

The following things do not affect a resource's modification stamp:

Returns:
the modification stamp, or NULL_STAMP if this resource either does not exist or exists as a closed project
See Also:
NULL_STAMP

getName

public String getName()
Returns the name of this resource. The name of a resource is synonymous with the last segment of its full (or project-relative) path for all resources other than the workspace root. The workspace root's name is the empty string.

This is a resource handle operation; the resource need not exist.

If this resource exists, its name can be safely assumed to be valid.

Returns:
the name of the resource
See Also:
getFullPath(), getProjectRelativePath()

getParent

public IContainer getParent()
Returns the resource which is the parent of this resource, or null if it has no parent (that is, this resource is the workspace root).

The full path of the parent resource is the same as this resource's full path with the last segment removed.

This is a resource handle operation; neither the resource nor the resulting resource need exist.

Returns:
the parent resource of this resource, or null if it has no parent

getPersistentProperty

public String getPersistentProperty(QualifiedName key)
                             throws CoreException
Returns the value of the persistent property of this resource identified by the given key, or null if this resource has no such property.

Parameters:
key - the qualified name of the property
Returns:
the string value of the property, or null if this resource has no such property
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • This resource is a project that is not open.
See Also:
setPersistentProperty(org.eclipse.core.runtime.QualifiedName, java.lang.String)

getProject

public IProject getProject()
Returns the project which contains this resource. Returns itself for projects and null for the workspace root.

A resource's project is the one named by the first segment of its full path.

This is a resource handle operation; neither the resource nor the resulting project need exist.

Returns:
the project handle

getProjectRelativePath

public IPath getProjectRelativePath()
Returns a relative path of this resource with respect to its project. Returns the empty path for projects and the workspace root.

This is a resource handle operation; the resource need not exist. If this resource does exist, its path can be safely assumed to be valid.

A resource's project-relative path indicates the route from the project to the resource. Within a workspace, there is exactly one such path for any given resource. The returned path never has a trailing slash.

Project-relative paths are recommended over absolute paths, since the former are no affected if the project is renamed.

Returns:
the relative path of this resource with respect to its project
See Also:
getFullPath(), getProject(), Path.EMPTY

getSessionProperty

public Object getSessionProperty(QualifiedName key)
                          throws CoreException
Returns the value of the session property of this resource identified by the given key, or null if this resource has no such property.

Parameters:
key - the qualified name of the property
Returns:
the string value of the session property, or null if this resource has no such property
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • This resource is a project that is not open.
See Also:
setSessionProperty(org.eclipse.core.runtime.QualifiedName, java.lang.Object)

getType

public int getType()
Returns the type of this resource. The returned value will be one of FILE, FOLDER, PROJECT, ROOT.

This is a resource handle operation; the resource need not exist in the workspace.

Returns:
the type of this resource
See Also:
FILE, FOLDER, PROJECT, ROOT

getWorkspace

public IWorkspace getWorkspace()
Returns the workspace which manages this resource.

This is a resource handle operation; the resource need not exist in the workspace.

Returns:
the workspace

isAccessible

public boolean isAccessible()
Returns whether this resource is accessible. For files and folder, this is equivalent to existing; for projects, this is equivalent to existing and being open. The workspace root is always accessible.

Returns:
true if this resource is accessible, and false otherwise
See Also:
exists(), IProject.isOpen()

isLocal

public boolean isLocal(int depth)
Returns whether this resource and its members (to the specified depth) are expected to have their contents (and properties) available locally. Returns false in all other cases, including the case where this resource does not exist. The workspace root and projects are always local.

When a resource is not local, its content and properties are unavailable for both reading and writing.

Parameters:
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
Returns:
true if this resource is local, and false otherwise
See Also:
setLocal(boolean, int, org.eclipse.core.runtime.IProgressMonitor)

isPhantom

public boolean isPhantom()
Returns whether this resource is a phantom resource.

The workspace uses phantom resources to remember outgoing deletions and incoming additions relative to an external synchronization partner. Phantoms appear and disappear automatically as a byproduct of synchronization. Since the workspace root cannot be synchronized in this way, it is never a phantom. Projects are also never phantoms.

The key point is that phantom resources do not exist (in the technical sense of exists, which returns false for phantoms) are therefore invisible except through a handful of phantom-enabled API methods (notably IContainer.members(boolean)).

Returns:
true if this resource is a phantom resource, and false otherwise
See Also:
exists(), IContainer.members(boolean), IContainer.findMember(String, boolean), IContainer.findMember(IPath, boolean), ISynchronizer

isReadOnly

public boolean isReadOnly()
Returns whether this resource is marked as read-only in the file system.

Returns:
true if this resource is read-only, false otherwise

isSynchronized

public boolean isSynchronized(int depth)
Returns whether this resource and its descendants to the given depth are considered to be in sync with the local file system.

A resource is considered to be in sync if all of the following conditions are true:

A resource is also considered to be in sync if it is missing from both the workspace and the filesystem. In all other cases the resource is considered to be out of sync.

This operation interrogates files and folders in the local file system; depending on the speed of the local file system and the requested depth, this operation may be time-consuming.

Parameters:
depth - the depth (one of IResource.DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE)
Returns:
true if this resource and its descendants to the specified depth are synchronized, and false in all other cases
Since:
2.0
See Also:
DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE, refreshLocal(int, org.eclipse.core.runtime.IProgressMonitor)

move

public void move(IProjectDescription description,
                 boolean force,
                 boolean keepHistory,
                 IProgressMonitor monitor)
          throws CoreException
Renames or relocates this project so that it is the project specified by the given project description.

This is a convenience method, fully equivalent to:

   move(description, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);
 

This operation changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource has been removed from its parent and that a corresponding resource has been added to its new parent. Additional information provided with resource delta shows that these additions and removals are related.

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

Parameters:
description - the destination project description
force - a flag controlling whether resources that are not in sync with the local file system will be tolerated
keepHistory - a flag indicating whether or not to keep local history for files
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this resource could not be moved. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • This resource is not a project.
  • The project at the destination already exists.
  • This resource or one of its descendents is out of sync with the local file system and force is false.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
IResourceDelta.getFlags()

move

public void move(IPath destination,
                 boolean force,
                 IProgressMonitor monitor)
          throws CoreException
Moves this resource so that it is located at the given path.

This is a convenience method, fully equivalent to:

   move(destination, force ? FORCE : IResource.NONE, monitor);
 

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource has been removed from its parent and that a corresponding resource has been added to its new parent. Additional information provided with resource delta shows that these additions and removals are related.

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

Parameters:
destination - the destination path
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 and cancellation are not desired
Throws:
CoreException - if this resource could not be moved. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • The source or destination is the workspace root.
  • The source is a project but the destination is not.
  • The destination is a project but the source is not.
  • The resource corresponding to the parent destination path does not exist.
  • The resource corresponding to the parent destination path is a closed project.
  • A resource at destination path does exist.
  • A resource of a different type exists at the destination path.
  • This resource or one of its descendents is out of sync with the local file system and force is false.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
  • The source resource is a file and the destination path specifies a project.
See Also:
IResourceDelta.getFlags()

move

public void move(IProjectDescription description,
                 int updateFlags,
                 IProgressMonitor monitor)
          throws CoreException
Renames or relocates this project so that it is the project specified by the given project description. The description specifies the name, location and attributes of the new project. After successful completion, the old project and any direct or indirect members will no longer exist; but corresponding new resources will now exist at the project.

When a resource moves, its session and persistent properties move with it. Likewise for all the other attributes of the resource including markers.

When this project's location is the default location, then the directories and files on disk are moved to be in the location specified by the given description. If the given description specifies the default location for the project, the directories and files are moved to the default location. In all other cases the directories and files on disk are left untouched. If the name in the given description is the same as this project's name and the location is different, then the project contents will be moved to the new location. All other parts of the given description are ignored.

The FORCE update flag controls how this method deals with cases where the workspace is not completely in sync with the local file system. If FORCE is not specified, the method will only attempt to move resources that are in sync with the corresponding files and directories in the local file system; it will fail if it encounters a resource that is out of sync with the file system. However, if FORCE is specified, the method moves all corresponding files and directories from the local file system, including ones that have been recently updated or created. Note that in both settings of the FORCE flag, the operation fails if the newly created resources in the workspace would be out of sync with the local file system; this ensures files in the file system cannot be accidentally overwritten.

The KEEP_HISTORY update flag controls whether or not file that are about to be deleted from the local file system have their current contents saved in the workspace's local history. The local history mechanism serves as a safety net to help the user recover from mistakes that might otherwise result in data loss. Specifying KEEP_HISTORY is recommended except in circumstances where past states of the files are of no conceivable interested to the user. Note that local history is maintained with each individual project, and gets discarded when a project is deleted from the workspace. Hence KEEP_HISTORY is only really applicable when moving files and folders, but not whole projects.

Update flags other than FORCE and KEEP_HISTORY are ignored.

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource has been removed from its parent and that a corresponding resource has been added to its new parent. Additional information provided with resource delta shows that these additions and removals are related.

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

Parameters:
description - the destination project description
updateFlags - bit-wise or of update flag constants (FORCE and KEEP_HISTORY)
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this resource could not be moved. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • This resource is not a project.
  • The project at the destination already exists.
  • This resource or one of its descendents is out of sync with the local file system and FORCE is not specified.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
Since:
2.0
See Also:
IResourceDelta.getFlags(), FORCE, KEEP_HISTORY

move

public void move(IPath destination,
                 int updateFlags,
                 IProgressMonitor monitor)
          throws CoreException
Moves this resource so that it is located at the given path. The path of the resource must not be a prefix of the destination path. The workspace root may not be the source or destination location of a move operation, and a project can only be moved to another project. After successful completion, the resource and any direct or indirect members will no longer exist; but corresponding new resources will now exist at the given path.

The supplied path may be absolute or relative. Absolute paths fully specify the new location for the resource, including its project. Relative paths are considered to be relative to the container of the resource being moved. A trailing slash is ignored.

Calling this method with a one segment absolute destination path is equivalent to calling:

                 IProjectDescription description = getDescription();
                 description.setName(path.lastSegment());
                 move(description, updateFlags, monitor);
 

When a resource moves, its session and persistent properties move with it. Likewise for all the other attributes of the resource including markers.

The FORCE update flag controls how this method deals with cases where the workspace is not completely in sync with the local file system. If FORCE is not specified, the method will only attempt to move resources that are in sync with the corresponding files and directories in the local file system; it will fail if it encounters a resource that is out of sync with the file system. However, if FORCE is specified, the method moves all corresponding files and directories from the local file system, including ones that have been recently updated or created. Note that in both settings of the FORCE flag, the operation fails if the newly created resources in the workspace would be out of sync with the local file system; this ensures files in the file system cannot be accidentally overwritten.

The KEEP_HISTORY update flag controls whether or not file that are about to be deleted from the local file system have their current contents saved in the workspace's local history. The local history mechanism serves as a safety net to help the user recover from mistakes that might otherwise result in data loss. Specifying KEEP_HISTORY is recommended except in circumstances where past states of the files are of no conceivable interested to the user. Note that local history is maintained with each individual project, and gets discarded when a project is deleted from the workspace. Hence KEEP_HISTORY is only really applicable when moving files and folders, but not whole projects.

Update flags other than FORCE and KEEP_HISTORY are ignored.

This method changes resources; these changes will be reported in a subsequent resource change event that will include an indication that the resource has been removed from its parent and that a corresponding resource has been added to its new parent. Additional information provided with resource delta shows that these additions and removals are related.

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

Parameters:
destination - the destination path
updateFlags - bit-wise or of update flag constants (FORCE and KEEP_HISTORY)
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this resource could not be moved. Reasons include:
  • This resource does not exist.
  • This resource or one of its descendents is not local.
  • The source or destination is the workspace root.
  • The source is a project but the destination is not.
  • The destination is a project but the source is not.
  • The resource corresponding to the parent destination path does not exist.
  • The resource corresponding to the parent destination path is a closed project.
  • A resource at destination path does exist.
  • A resource of a different type exists at the destination path.
  • This resource or one of its descendents is out of sync with the local file system and force is false.
  • The workspace and the local file system are out of sync at the destination resource or one of its descendents.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
  • The source resource is a file and the destination path specifies a project.
Since:
2.0
See Also:
IResourceDelta.getFlags(), FORCE, KEEP_HISTORY

refreshLocal

public void refreshLocal(int depth,
                         IProgressMonitor monitor)
                  throws CoreException
Refreshes the resource hierarchy from this resource and its children (to the specified depth) relative to the local file system. Creations, deletions, and changes detected in the local file system will be reflected in the workspace's resource tree. This resource need not exist or be local.

This method may discover changes to resources; any such changes will be reported in a subsequent resource change event.

If a new file or directory is discovered in the local file system at or below the location of this resource, any parent folders required to contain the new resource in the workspace will also be created automatically as required.

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

Parameters:
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this method fails. Reasons include:
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE

setLocal

public void setLocal(boolean flag,
                     int depth,
                     IProgressMonitor monitor)
              throws CoreException
Set whether or not this resource and its members (to the specified depth) are expected to have their contents (and properties) available locally. The workspace root and projects are always local and attempting to set either to non-local (i.e., passing false) has no affect on the resource.

When a resource is not local, its content and properties are unavailable for both reading and writing.

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

Parameters:
flag - whether this resource should be considered local
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this method fails. Reasons include:
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
isLocal(int)

setPersistentProperty

public void setPersistentProperty(QualifiedName key,
                                  String value)
                           throws CoreException
Sets the value of the persistent property of this resource identified by the given key. If the supplied value is null, the persistent property is removed from this resource. The change is made immediately on disk.

Persistent properties are intended to be used by plug-ins to store resource-specific information that should be persisted across platform sessions. The value of a persistent property is a string which should be short (i.e., under 2KB). Unlike session properties, persistent properties are stored on disk and maintained across workspace shutdown and restart.

The qualifier part of the property name must be the unique identifier of the declaring plug-in (e.g. "com.example.plugin").

Parameters:
key - the qualified name of the property
value - the string value of the property, or null if the property is to be removed
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • This resource is a project that is not open.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
getPersistentProperty(org.eclipse.core.runtime.QualifiedName), isLocal(int)

setReadOnly

public void setReadOnly(boolean readOnly)
Sets or unsets this resource as read-only in the file system.


setSessionProperty

public void setSessionProperty(QualifiedName key,
                               Object value)
                        throws CoreException
Sets the value of the session property of this resource identified by the given key. If the supplied value is null, the session property is removed from this resource.

Sessions properties are intended to be used as a caching mechanism by ISV plug-ins. They allow key-object associations to be stored with existing resources in the workspace. These key-value associations are maintained in memory (at all times), and the information is lost when a resource is deleted from the workspace, when the parent project is closed, or when the workspace is closed.

The qualifier part of the property name must be the unique identifier of the declaring plug-in (e.g. "com.example.plugin").

Parameters:
key - the qualified name of the property
value - the value of the session property, or null if the property is to be removed
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • This resource is project that is not open.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
getSessionProperty(org.eclipse.core.runtime.QualifiedName)

touch

public void touch(IProgressMonitor monitor)
           throws CoreException
Marks this resource as having changed even though its content may not have changed. This method can be used to trigger the rebuilding of resources/structures derived from this resource. Touching the workspace root has no effect.

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:
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.

isDerived

public boolean isDerived()
Returns whether this resource subtree is marked as derived. Returns false if this resource does not exist.

Returns:
true if this resource is marked as derived, and false otherwise
Since:
2.0
See Also:
setDerived(boolean)

setDerived

public void setDerived(boolean isDerived)
                throws CoreException
Sets whether this resource subtree is marked as derived.

A derived resource is a regular file or folder that is created in the course of translating, compiling, copying, or otherwise processing other files. Derived resources are not original data, and can be recreated from other resources. It is commonplace to exclude derived resources from version and configuration management because they would otherwise clutter the team repository with version of these ever-changing files as each user regenerates them.

If a resource or any of its ancestors is marked as derived, a team provider should assume that the resource is not under version and configuration management by default. That is, the resource should only be stored in a team repository if the user explicitly indicates that this resource is worth saving.

Newly-created resources are not marked as derived; rather, the mark must be set explicitly using setDerived(true). Derived marks are maintained in the in-memory resource tree, and are discarded when the resources is deleted. Derived marks are saved to disk when a project is closed, or when the workspace is saved.

Projects and the workspace root are never considered derived; attempts to mark them as derived are ignored.

This operation does not result in a resource change event, and does not trigger auto-builds.

Parameters:
isDerived - true if this resource is to be marked as derived, and false otherwise
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
Since:
2.0
See Also:
isDerived()

isTeamPrivateMember

public boolean isTeamPrivateMember()
Returns whether this resource is a team private member of its parent container. Returns false if this resource does not exist.

Returns:
true if this resource is a team private member, and false otherwise
Since:
2.0
See Also:
setTeamPrivateMember(boolean)

setTeamPrivateMember

public void setTeamPrivateMember(boolean isTeamPrivate)
                          throws CoreException
Sets whether this resource subtree is a team private member of its parent container.

A team private member resource is a special file or folder created by a team provider to hold team-provider-specific information. Resources marked as team private members are invisible to most clients.

Newly-created resources are not team private members by default; rather, the team provider must mark a resource explicitly using setTeamPrivateMember(true). Team private member marks are maintained in the in-memory resource tree, and are discarded when the resources is deleted. Team private member marks are saved to disk when a project is closed, or when the workspace is saved.

Projects and the workspace root are never considered team private members; attempts to mark them as derived are ignored.

This operation does not result in a resource change event, and does not trigger auto-builds.

Parameters:
isTeamPrivate - true if this resource is to be marked as team private, and false otherwise
Throws:
CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
Since:
2.0
See Also:
isTeamPrivateMember()

Eclipse Platform
2.0

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