org.eclipse.core.internal.resources
Class Resource

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.core.internal.resources.Resource
All Implemented Interfaces:
java.lang.Cloneable, ICoreConstants, IPathRequestor, IResource, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.jobs.ISchedulingRule
Direct Known Subclasses:
Container, File

public abstract class Resource
extends org.eclipse.core.runtime.PlatformObject
implements IResource, ICoreConstants, java.lang.Cloneable, IPathRequestor


Field Summary
 
Fields inherited from interface org.eclipse.core.resources.IResource
ALLOW_MISSING_LOCAL, ALWAYS_DELETE_PROJECT_CONTENT, AVOID_NATURE_CONFIG, BACKGROUND_REFRESH, CHECK_ANCESTORS, DEPTH_INFINITE, DEPTH_ONE, DEPTH_ZERO, DERIVED, FILE, FOLDER, FORCE, HIDDEN, KEEP_HISTORY, NEVER_DELETE_PROJECT_CONTENT, NONE, NULL_STAMP, PROJECT, REPLACE, ROOT, SHALLOW, TEAM_PRIVATE
 
Fields inherited from interface org.eclipse.core.internal.resources.ICoreConstants
CRASH_DETECTED, EMPTY_FILE_STATES, EMPTY_PROJECT_ARRAY, EMPTY_RESOURCE_ARRAY, I_NULL_SYNC_INFO, K_BUILD_LIST, M_CHILDREN_UNKNOWN, M_CONTENT_CACHE, M_DEFAULT_CONTENT_DESCRIPTION, M_DERIVED, M_HIDDEN, M_LINK, M_LOCAL_EXISTS, M_MARKERS_SNAP_DIRTY, M_NO_CONTENT_DESCRIPTION, M_OPEN, M_PHANTOM, M_SYNCINFO_SNAP_DIRTY, M_TEAM_PRIVATE_MEMBER, M_TYPE, M_TYPE_START, M_USED, MINIMUM_FILE_SEGMENT_LENGTH, MINIMUM_FOLDER_SEGMENT_LENGTH, NULL_FLAG, PREF_VERSION, PREF_VERSION_KEY, PROJECT_SEGMENT_LENGTH, REFRESH_ON_STARTUP, WORKSPACE_TREE_VERSION_1, WORKSPACE_TREE_VERSION_2
 
Method Summary
 void accept(IResourceProxyVisitor visitor, int memberFlags)
          Accepts the given visitor for an optimized traversal.
 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 checkAccessible(int flags)
           
 org.eclipse.core.runtime.IStatus checkCopyRequirements(org.eclipse.core.runtime.IPath destination, int destinationType, int updateFlags)
          This method reports errors in two different ways.
 void checkDoesNotExist(int flags, boolean checkType)
          Checks that this resource does not exist.
 void checkExists(int flags, boolean checkType)
          Checks that this resource exists.
 void checkLocal(int flags, int depth)
          Checks that this resource is local to the given depth.
 void checkValidPath(org.eclipse.core.runtime.IPath toValidate, int type, boolean lastSegmentOnly)
          Checks that the supplied path is valid according to Workspace.validatePath().
 void clearHistory(org.eclipse.core.runtime.IProgressMonitor monitor)
          Removes the local history of this resource and its descendents.
 boolean contains(org.eclipse.core.runtime.jobs.ISchedulingRule rule)
           
 void convertToPhantom()
           
 void copy(org.eclipse.core.runtime.IPath destination, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Makes a copy of this resource at the given path.
 void copy(org.eclipse.core.runtime.IPath destination, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Makes a copy of this resource at the given path.
 void copy(IProjectDescription destDesc, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Makes a copy of this project using the given project description.
 void copy(IProjectDescription destDesc, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Makes a copy of this project using the given project description.
 int countResources(int depth, boolean phantom)
          Count the number of resources in the tree from this container to the specified depth.
 void createLink(org.eclipse.core.runtime.IPath localLocation, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void createLink(java.net.URI localLocation, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 IMarker createMarker(java.lang.String type)
          Creates and returns the marker with the specified type on this resource.
 IResourceProxy createProxy()
          Creates a resource proxy representing the current state of this resource.
 void delete(boolean force, boolean keepHistory, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void delete(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Deletes this resource from the workspace.
 void delete(int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Deletes this resource from the workspace.
 void deleteMarkers(java.lang.String type, boolean includeSubtypes, int depth)
          Deletes all markers on this resource of the given type, and, optionally, deletes such markers from its children.
 void deleteResource(boolean convertToPhantom, org.eclipse.core.runtime.MultiStatus status)
          This method should be called to delete a resource from the tree because it will also delete its properties and markers.
 boolean equals(java.lang.Object target)
          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.
 boolean exists(int flags, boolean checkType)
           
 IResource findExistingResourceVariant(org.eclipse.core.runtime.IPath target)
          Helper method for case insensitive file systems.
 IMarker findMarker(long id)
          Returns the marker with the specified id on this resource, Returns null if there is no matching marker.
 IMarker[] findMarkers(java.lang.String type, boolean includeSubtypes, int depth)
          Returns all markers of the specified type on this resource, and, optionally, on its children.
 int findMaxProblemSeverity(java.lang.String type, boolean includeSubtypes, int depth)
          Returns the maximum value of the IMarker.SEVERITY attribute across markers of the specified type on this resource, and, optionally, on its children.
 java.lang.String getFileExtension()
          Returns the file extension portion of this resource's name, or null if it does not have one.
 int getFlags(ResourceInfo info)
           
 org.eclipse.core.runtime.IPath getFullPath()
          Returns the full, absolute path of this resource relative to the workspace.
 FileSystemResourceManager getLocalManager()
           
 long getLocalTimeStamp()
          Returns a cached value of the local time stamp on disk for this resource, or NULL_STAMP if the resource does not exist or is not local or is not accessible.
 org.eclipse.core.runtime.IPath getLocation()
          Returns the absolute path in the local file system to this resource, or null if no path can be determined.
 java.net.URI getLocationURI()
          Returns the absolute URI of this resource, or null if no URI 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.
 java.lang.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).
 java.util.Map getPersistentProperties()
          Returns a copy of the map of this resource's persistent properties.
 java.lang.String getPersistentProperty(org.eclipse.core.runtime.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.
 org.eclipse.core.runtime.IPath getProjectRelativePath()
          Returns a relative path of this resource with respect to its project.
 IPropertyManager getPropertyManager()
           
 org.eclipse.core.runtime.IPath getRawLocation()
          Returns the file system location of this resource, or null if no path can be determined.
 java.net.URI getRawLocationURI()
          Returns the file system location of this resource, or null if no path can be determined.
 ResourceAttributes getResourceAttributes()
          Gets this resource's extended attributes from the file system, or null if the attributes could not be obtained.
 ResourceInfo getResourceInfo(boolean phantom, boolean mutable)
          Returns the resource info.
 java.util.Map getSessionProperties()
          Returns a copy of the map of this resource's session properties.
 java.lang.Object getSessionProperty(org.eclipse.core.runtime.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.
 org.eclipse.core.filesystem.IFileStore getStore()
           
abstract  int getType()
          Returns the type of this resource.
 java.lang.String getTypeString()
           
 IWorkspace getWorkspace()
          Returns the workspace which manages this resource.
 int hashCode()
           
 boolean isAccessible()
          Returns whether this resource is accessible.
 boolean isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule rule)
           
 boolean isDerived()
          Returns whether this resource subtree is marked as derived.
 boolean isDerived(int options)
          Returns whether this resource subtree is marked as derived.
 boolean isHidden()
          Returns whether this resource is hidden in the resource tree.
 boolean isHidden(int options)
          Returns whether this resource is hidden in the resource tree.
 boolean isLinked()
          Returns whether this resource has been linked to a location other than the default location calculated by the platform.
 boolean isLinked(int options)
          Returns true if this resource has been linked to a location other than the default location calculated by the platform.
 boolean isLocal(int depth)
          Deprecated.  
 boolean isLocal(int flags, int depth)
          Deprecated.  
 boolean isPhantom()
          Returns whether this resource is a phantom resource.
 boolean isPhantom(int flags)
           
 boolean isReadOnly()
          Deprecated.  
 boolean isSynchronized(int depth)
          Returns whether this resource and its descendents 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.
 boolean isTeamPrivateMember(int options)
          Returns whether this resource is a team private member of its parent container.
 boolean isUnderLink()
          Returns true if this resource is a linked resource, or a child of a linked resource, and false otherwise.
 void move(org.eclipse.core.runtime.IPath destination, boolean force, boolean keepHistory, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void move(org.eclipse.core.runtime.IPath destination, boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
          Moves this resource so that it is located at the given path.
 void move(org.eclipse.core.runtime.IPath destination, int updateFlags, org.eclipse.core.runtime.IProgressMonitor monitor)
          Moves this resource so that it is located at the given path.
 void move(IProjectDescription description, boolean force, boolean keepHistory, org.eclipse.core.runtime.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, org.eclipse.core.runtime.IProgressMonitor monitor)
          Renames or relocates this project so that it is the project specified by the given project description.
 void refreshLocal(int depth, org.eclipse.core.runtime.IProgressMonitor monitor)
          Refreshes the resource hierarchy from this resource and its children (to the specified depth) relative to the local file system.
 java.lang.String requestName()
           
 org.eclipse.core.runtime.IPath requestPath()
           
 void revertModificationStamp(long value)
          Reverts this resource's modification stamp.
 void setDerived(boolean isDerived)
          Sets whether this resource subtree is marked as derived.
 void setHidden(boolean isHidden)
          Sets whether this resource and its members are hidden in the resource tree.
 void setLocal(boolean flag, int depth, org.eclipse.core.runtime.IProgressMonitor monitor)
          Deprecated.  
 long setLocalTimeStamp(long value)
          Sets the local time stamp on disk for this resource.
 void setPersistentProperty(org.eclipse.core.runtime.QualifiedName key, java.lang.String value)
          Sets the value of the persistent property of this resource identified by the given key.
 void setReadOnly(boolean readonly)
          Deprecated.  
 void setResourceAttributes(ResourceAttributes attributes)
          Sets this resource with the given extended attributes.
 void setSessionProperty(org.eclipse.core.runtime.QualifiedName key, java.lang.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.
 boolean synchronizing(ResourceInfo info)
          Returns true if this resource has the potential to be (or have been) synchronized.
 java.lang.String toString()
           
 void touch(org.eclipse.core.runtime.IProgressMonitor monitor)
          Marks this resource as having changed even though its content may not have changed.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Method Detail

accept

public void accept(IResourceProxyVisitor visitor,
                   int memberFlags)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Accepts the given visitor for an optimized traversal. The visitor's visit method is called, and is provided with a proxy to this resource. The proxy is a transient object that can be queried very quickly for information about the resource. If the actual resource handle is needed, it can be obtained from the proxy. Requesting the resource handle, or the full path of the resource, will degrade performance of the visit.

The entire subtree under the given resource is traversed to infinite depth, unless the visitor ignores a subtree by returning false from its visit method.

No guarantees are made about the behavior of this method if resources are deleted or added during the traversal of this resource hierarchy. If resources are deleted during the traversal, they may still be passed to the visitor; if resources are created, they may not be passed to the visitor. If resources other than the one being visited are modified during the traversal, the resource proxy may contain stale information when that resource is visited.

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

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

If the IContainer.INCLUDE_HIDDEN flag is not specified (recommended), hidden resources will not be visited. If the IContainer.INCLUDE_HIDDEN flag is specified in the member flags, hidden resources are visited as well.

Specified by:
accept in interface IResource
Parameters:
visitor - the visitor
memberFlags - bit-wise or of member flag constants (IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS and IContainer.INCLUDE_HIDDEN) indicating which members are of interest
Throws:
org.eclipse.core.runtime.CoreException - if this request fails. Reasons include:
See Also:
IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS, IContainer.INCLUDE_HIDDEN, IResource.isPhantom(), IResource.isTeamPrivateMember(), IResourceProxyVisitor.visit(IResourceProxy)

accept

public void accept(IResourceVisitor visitor)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.DEPTH_INFINITE, IResource.NONE).

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

accept

public void accept(IResourceVisitor visitor,
                   int depth,
                   boolean includePhantoms)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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 ? IContainer.INCLUDE_PHANTOMS : IResource.NONE);
 

Specified by:
accept in interface IResource
Parameters:
visitor - the visitor
depth - the depth to which members of this resource should be visited. One of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE.
includePhantoms - true if phantom resources are of interest; false if phantom resources are not of interest.
Throws:
org.eclipse.core.runtime.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:
IResource.isPhantom(), IResourceVisitor.visit(IResource), IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE, IResource.accept(IResourceVisitor,int,int)

accept

public void accept(IResourceVisitor visitor,
                   int depth,
                   int memberFlags)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

No guarantees are made about the behavior of this method if resources are deleted or added during the traversal of this resource hierarchy. If resources are deleted during the traversal, they may still be passed to the visitor; if resources are created, they may not be passed to the visitor.

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

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

If the IContainer.EXCLUDE_DERIVED flag is not specified (recommended), derived resources are visited. If the IContainer.EXCLUDE_DERIVED flag is specified in the member flags, derived resources are not visited.

If the IContainer.INCLUDE_HIDDEN flag is not specified (recommended), hidden resources will not be visited. If the IContainer.INCLUDE_HIDDEN flag is specified in the member flags, hidden resources are visited as well.

Specified by:
accept in interface IResource
Parameters:
visitor - the visitor
depth - the depth to which members of this resource should be visited. One of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE.
memberFlags - bit-wise or of member flag constants (IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS, IContainer.INCLUDE_HIDDEN and IContainer.EXCLUDE_DERIVED) indicating which members are of interest
Throws:
org.eclipse.core.runtime.CoreException - if this request fails. Reasons include:
See Also:
IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS, IContainer.INCLUDE_HIDDEN, IContainer.EXCLUDE_DERIVED, IResource.isDerived(), IResource.isPhantom(), IResource.isTeamPrivateMember(), IResource.isHidden(), IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE, IResourceVisitor.visit(IResource)

checkAccessible

public void checkAccessible(int flags)
                     throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

checkCopyRequirements

public org.eclipse.core.runtime.IStatus checkCopyRequirements(org.eclipse.core.runtime.IPath destination,
                                                              int destinationType,
                                                              int updateFlags)
                                                       throws org.eclipse.core.runtime.CoreException
This method reports errors in two different ways. It can throw a CoreException or return a status. CoreExceptions are used according to the specification of the copy method. Programming errors, that would usually be prevented by using an "Assert" code, are reported as an IStatus. We're doing this way because we have two different methods to copy resources: IResource#copy and IWorkspace#copy. The first one gets the error and throws its message in an AssertionFailureException. The second one just throws a CoreException using the status returned by this method.

Throws:
org.eclipse.core.runtime.CoreException
See Also:
IResource.copy(IPath, int, IProgressMonitor)

checkDoesNotExist

public void checkDoesNotExist(int flags,
                              boolean checkType)
                       throws org.eclipse.core.runtime.CoreException
Checks that this resource does not exist. If the file system is not case sensitive, this method also checks for a case variant.

Throws:
org.eclipse.core.runtime.CoreException - if this resource exists

checkExists

public void checkExists(int flags,
                        boolean checkType)
                 throws org.eclipse.core.runtime.CoreException
Checks that this resource exists. If checkType is true, the type of this resource and the one in the tree must match.

Throws:
org.eclipse.core.runtime.CoreException - if this resource does not exist

checkLocal

public void checkLocal(int flags,
                       int depth)
                throws org.eclipse.core.runtime.CoreException
Checks that this resource is local to the given depth.

Throws:
org.eclipse.core.runtime.CoreException - if this resource is not local

checkValidPath

public void checkValidPath(org.eclipse.core.runtime.IPath toValidate,
                           int type,
                           boolean lastSegmentOnly)
                    throws org.eclipse.core.runtime.CoreException
Checks that the supplied path is valid according to Workspace.validatePath().

Throws:
org.eclipse.core.runtime.CoreException - if the path is not valid

clearHistory

public void clearHistory(org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from interface: IResource
Removes the local history of this resource and its descendents.

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

Specified by:
clearHistory in interface IResource
Parameters:
monitor - a progress monitor, or null if progress reporting and cancellation are not desired

contains

public boolean contains(org.eclipse.core.runtime.jobs.ISchedulingRule rule)
Specified by:
contains in interface org.eclipse.core.runtime.jobs.ISchedulingRule

convertToPhantom

public void convertToPhantom()
                      throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

copy

public void copy(org.eclipse.core.runtime.IPath destination,
                 boolean force,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
copy in interface IResource
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 is not desired
Throws:
org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath destination,
                 int updateFlags,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

The SHALLOW update flag controls how this method deals with linked resources. If SHALLOW is not specified, then the underlying contents of the linked resource will always be copied in the file system. In this case, the destination of the copy will never be a linked resource or contain any linked resources. If SHALLOW is specified when a linked resource is copied into another project, a new linked resource is created in the destination project that points to the same file system location. When a project containing linked resources is copied, the new project will contain the same linked resources pointing to the same file system locations. For both of these shallow cases, no files on disk under the linked resource are actually copied. With the SHALLOW flag, copying of linked resources into anything other than a project is not permitted. The SHALLOW update flag is ignored when copying non- linked resources.

The IResource.DERIVED update flag indicates that the new resource should immediately be set as a derived resource. Specifying this flag is equivalent to atomically calling IResource.setDerived(boolean) with a value of true immediately after creating the resource.

The IResource.TEAM_PRIVATE update flag indicates that the new resource should immediately be set as a team private resource. Specifying this flag is equivalent to atomically calling IResource.setTeamPrivateMember(boolean) with a value of true immediately after creating the resource.

The IResource.HIDDEN update flag indicates that the new resource should immediately be set as a hidden resource. Specifying this flag is equivalent to atomically calling IResource.setHidden(boolean) with a value of true immediately after creating the resource.

Update flags other than those listed above 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.

An attempt will be made to copy the local history for this resource and its children, to the destination. Since local history existence is a safety-net mechanism, failure of this action will not result in automatic failure of the copy operation.

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

Specified by:
copy in interface IResource
Parameters:
destination - the destination path
updateFlags - bit-wise or of update flag constants (IResource.FORCE, IResource.SHALLOW, IResource.DERIVED, IResource.TEAM_PRIVATE, IResource.HIDDEN)
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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.
  • The source is a linked resource, but the destination is not a project, and SHALLOW is specified.
  • A resource at destination path does exist.
  • This resource or one of its descendants 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 descendants.
  • The source resource is a file and the destination path specifies a project.
  • The source is a linked resource, and the destination path does not specify a project.
  • The location of the source resource on disk is the same or a prefix of the location of the destination resource on disk.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
IResource.FORCE, IResource.SHALLOW, IResource.DERIVED, IResource.TEAM_PRIVATE, IResourceRuleFactory.copyRule(IResource, IResource)

copy

public void copy(IProjectDescription destDesc,
                 boolean force,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
copy in interface IResource
Parameters:
destDesc - 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 is not desired
Throws:
org.eclipse.core.runtime.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(IProjectDescription destDesc,
                 int updateFlags,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

The SHALLOW update flag controls how this method deals with linked resources. If SHALLOW is not specified, then the underlying contents of any linked resources in the project will always be copied in the file system. In this case, the destination of the copy will never contain any linked resources. If SHALLOW is specified when a project containing linked resources is copied, new linked resources are created in the destination project that point to the same file system locations. In this case, no files on disk under linked resources are actually copied. The SHALLOW update flag is ignored when copying non- linked resources.

Update flags other than FORCE or SHALLOW are ignored.

An attempt will be made to copy the local history for this resource and its children, to the destination. Since local history existence is a safety-net mechanism, failure of this action will not result in automatic failure of the copy operation.

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.

Specified by:
copy in interface IResource
Parameters:
destDesc - the destination project description
updateFlags - bit-wise or of update flag constants (FORCE and SHALLOW)
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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.
See Also:
IResource.FORCE, IResource.SHALLOW, IResourceRuleFactory.copyRule(IResource, IResource)

countResources

public int countResources(int depth,
                          boolean phantom)
Count the number of resources in the tree from this container to the specified depth. Include this resource. Include phantoms if the phantom boolean is true.


createLink

public void createLink(org.eclipse.core.runtime.IPath localLocation,
                       int updateFlags,
                       org.eclipse.core.runtime.IProgressMonitor monitor)
                throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

createLink

public void createLink(java.net.URI localLocation,
                       int updateFlags,
                       org.eclipse.core.runtime.IProgressMonitor monitor)
                throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

createMarker

public IMarker createMarker(java.lang.String type)
                     throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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. The specified type string must not be null.

Specified by:
createMarker in interface IResource
Parameters:
type - the type of the marker to create
Returns:
the handle of the new marker
Throws:
org.eclipse.core.runtime.CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.
See Also:
IResourceRuleFactory.markerRule(IResource)

createProxy

public IResourceProxy createProxy()
Description copied from interface: IResource
Creates a resource proxy representing the current state of this resource.

Note that once a proxy has been created, it does not stay in sync with the corresponding resource. Changes to the resource after the proxy is created will not be reflected in the state of the proxy.

Specified by:
createProxy in interface IResource
Returns:
A proxy representing this resource

delete

public void delete(boolean force,
                   boolean keepHistory,
                   org.eclipse.core.runtime.IProgressMonitor monitor)
            throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

delete

public void delete(boolean force,
                   org.eclipse.core.runtime.IProgressMonitor monitor)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
delete in interface IResource
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 is not desired
Throws:
org.eclipse.core.runtime.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:
IResource.delete(int,IProgressMonitor)

delete

public void delete(int updateFlags,
                   org.eclipse.core.runtime.IProgressMonitor monitor)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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 non-linked 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 a linked resource does not delete its contents from the file system, it just removes that resource and its children from the workspace. Deleting children of linked resources does remove the contents from the file system.

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 IResource.FORCE update flag controls how this method deals with cases where the workspace is not completely in sync with the local file system. If IResource.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 IResource.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 IResource.KEEP_HISTORY update flag controls whether or not files 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 IResource.KEEP_HISTORY is recommended except in circumstances where past states of the files are of no conceivable interest 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 IResource.KEEP_HISTORY is only really applicable when deleting files and folders, but not projects.

The IResource.ALWAYS_DELETE_PROJECT_CONTENT update flag controls how project deletions are handled. If IResource.ALWAYS_DELETE_PROJECT_CONTENT 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; IResource.FORCE is assumed regardless of whether it is specified. If IResource.NEVER_DELETE_PROJECT_CONTENT 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 IResource.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 IResource.FORCE flag), but never from closed projects.

Specified by:
delete in interface IResource
Parameters:
updateFlags - bit-wise or of update flag constants ( IResource.FORCE, IResource.KEEP_HISTORY, IResource.ALWAYS_DELETE_PROJECT_CONTENT, and IResource.NEVER_DELETE_PROJECT_CONTENT)
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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 IResource.FORCE is not specified.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
IFile.delete(boolean, boolean, IProgressMonitor), IFolder.delete(boolean, boolean, IProgressMonitor), IResource.FORCE, IResource.KEEP_HISTORY, IResource.ALWAYS_DELETE_PROJECT_CONTENT, IResource.NEVER_DELETE_PROJECT_CONTENT, IResourceRuleFactory.deleteRule(IResource)

deleteMarkers

public void deleteMarkers(java.lang.String type,
                          boolean includeSubtypes,
                          int depth)
                   throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
deleteMarkers in interface IResource
Parameters:
type - the type of marker to consider, or null to indicate all types
includeSubtypes - whether or not to consider sub-types of the given type
depth - how far to recurse (see IResource.DEPTH_* )
Throws:
org.eclipse.core.runtime.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:
IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE, IResourceRuleFactory.markerRule(IResource)

deleteResource

public void deleteResource(boolean convertToPhantom,
                           org.eclipse.core.runtime.MultiStatus status)
                    throws org.eclipse.core.runtime.CoreException
This method should be called to delete a resource from the tree because it will also delete its properties and markers. If a status object is provided, minor exceptions are added, otherwise they are thrown. If major exceptions occur, they are always thrown.

Throws:
org.eclipse.core.runtime.CoreException

equals

public boolean equals(java.lang.Object target)
Description copied from interface: IResource
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.

Specified by:
equals in interface IResource
Overrides:
equals in class java.lang.Object
Parameters:
target - the other object
Returns:
an indication of whether the objects are equals
See Also:
IResource.getType(), IResource.getFullPath(), IResource.getWorkspace()

exists

public boolean exists()
Description copied from interface: IResource
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.

Specified by:
exists in interface IResource
Returns:
true if the resource exists, otherwise false

exists

public boolean exists(int flags,
                      boolean checkType)

findExistingResourceVariant

public IResource findExistingResourceVariant(org.eclipse.core.runtime.IPath target)
Helper method for case insensitive file systems. Returns an existing resource whose path differs only in case from the given path, or null if no such resource exists.


findMarker

public IMarker findMarker(long id)
Description copied from interface: IResource
Returns the marker with the specified id on this resource, Returns null if there is no matching marker.

Specified by:
findMarker in interface IResource
Parameters:
id - the id of the marker to find
Returns:
a marker or null

findMarkers

public IMarker[] findMarkers(java.lang.String type,
                             boolean includeSubtypes,
                             int depth)
                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

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

findMaxProblemSeverity

public int findMaxProblemSeverity(java.lang.String type,
                                  boolean includeSubtypes,
                                  int depth)
                           throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Returns the maximum value of the IMarker.SEVERITY attribute across markers of the specified type on this resource, and, optionally, on its children. If includeSubtypesis false, only markers whose type exactly matches the given type are considered. Returns -1 if there are no matching markers. Returns IMarker.SEVERITY_ERROR if any of the markers has a severity greater than or equal to IMarker.SEVERITY_ERROR.

Specified by:
findMaxProblemSeverity in interface IResource
Parameters:
type - the type of marker to consider (normally IMarker.PROBLEM or one of its subtypes), or null to indicate all types
includeSubtypes - whether or not to consider sub-types of the given type
depth - how far to recurse (see IResource.DEPTH_* )
Returns:
IMarker.SEVERITY_INFO, IMarker.SEVERITY_WARNING, IMarker.SEVERITY_ERROR, or -1
Throws:
org.eclipse.core.runtime.CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is a project that is not open.
See Also:
IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE

getFileExtension

public java.lang.String getFileExtension()
Description copied from interface: IResource
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.

Specified by:
getFileExtension in interface IResource
Returns:
a string file extension
See Also:
IResource.getName()

getFlags

public int getFlags(ResourceInfo info)

getFullPath

public org.eclipse.core.runtime.IPath getFullPath()
Description copied from interface: IResource
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.

Specified by:
getFullPath in interface IResource
Returns:
the absolute path of this resource
See Also:
IResource.getProjectRelativePath(), Path.ROOT

getLocalManager

public FileSystemResourceManager getLocalManager()

getLocalTimeStamp

public long getLocalTimeStamp()
Description copied from interface: IResource
Returns a cached value of the local time stamp on disk for this resource, or NULL_STAMP if the resource does not exist or is not local or is not accessible. The return value is represented as the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970). The returned value may not be the same as the actual time stamp on disk if the file has been modified externally since the last local refresh.

Note that due to varying file system timing granularities, this value is not guaranteed to change every time the file is modified. For a more reliable indication of whether the file has changed, use getModificationStamp.

Specified by:
getLocalTimeStamp in interface IResource
Returns:
a local file system time stamp, or NULL_STAMP.

getLocation

public org.eclipse.core.runtime.IPath getLocation()
Description copied from interface: IResource
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. This value will be null in the case where the location is relative to an undefined workspace path variable.

If this resource is a linked resource under a project that is open, this method returns the resolved path to the linked resource's local contents. This value will be null in the case where the location is relative to an undefined workspace path variable.

If this resource is a file or folder under a project that exists, or a linked resource under a closed project, 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. In the case of linked resources, the location of a linked resource within a closed project is too computed from the location of the project's local content area and the project-relative path of the resource. If the linked resource resides in an open project then its location is computed according to the link.

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. This method also returns null if called on a resource that is not stored in the local file system. For such resources IResource.getLocationURI() should be used instead.

Specified by:
getLocation in interface IResource
Returns:
the absolute path of this resource in the local file system, or null if no path can be determined
See Also:
IResource.getRawLocation(), IResource.getLocationURI(), IProjectDescription.setLocation(IPath), Platform.getLocation()

getLocationURI

public java.net.URI getLocationURI()
Description copied from interface: IResource
Returns the absolute URI of this resource, or null if no URI can be determined.

If this resource is the workspace root, this method returns the absolute location of the platform working area.

If this resource is a project that exists in the workspace, this method returns the URI to the project's local content area. This is true regardless of whether the project is open or closed. This value will be null in the case where the location is relative to an undefined workspace path variable.

If this resource is a linked resource under a project that is open, this method returns the resolved URI to the linked resource's local contents. This value will be null in the case where the location is relative to an undefined workspace path variable.

If this resource is a file or folder under a project that exists, or a linked resource under a closed project, this method returns a (non- null) URI 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. In the case of linked resources, the location of a linked resource within a closed project is computed from the location of the project's local content area and the project-relative path of the resource. If the linked resource resides in an open project then its location is computed according to the link.

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.

Specified by:
getLocationURI in interface IResource
Returns:
the absolute URI of this resource, or null if no URI can be determined
See Also:
IResource.getRawLocation(), IProjectDescription.setLocation(IPath), Platform.getLocation(), URI

getMarker

public IMarker getMarker(long id)
Description copied from interface: IResource
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.

Specified by:
getMarker in interface IResource
Parameters:
id - the id of the marker
Returns:
the specified marker handle
See Also:
IMarker.getId()

getModificationStamp

public long getModificationStamp()
Description copied from interface: IResource
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:

Specified by:
getModificationStamp in interface IResource
Returns:
the modification stamp, or NULL_STAMP if this resource either does not exist or exists as a closed project
See Also:
IResource.NULL_STAMP, IResource.revertModificationStamp(long)

getName

public java.lang.String getName()
Description copied from interface: IResource
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.

Specified by:
getName in interface IResource
Returns:
the name of the resource
See Also:
IResource.getFullPath(), IResource.getProjectRelativePath()

getParent

public IContainer getParent()
Description copied from interface: IResource
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.

Specified by:
getParent in interface IResource
Returns:
the parent resource of this resource, or null if it has no parent

getPersistentProperty

public java.lang.String getPersistentProperty(org.eclipse.core.runtime.QualifiedName key)
                                       throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Returns the value of the persistent property of this resource identified by the given key, or null if this resource has no such property.

Specified by:
getPersistentProperty in interface IResource
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:
org.eclipse.core.runtime.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:
IResource.setPersistentProperty(QualifiedName, String)

getPersistentProperties

public java.util.Map getPersistentProperties()
                                      throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Returns a copy of the map of this resource's persistent properties. Returns an empty map if this resource has no persistent properties.

Specified by:
getPersistentProperties in interface IResource
Returns:
the map containing the persistent properties where the key is the QualifiedName of the property and the value is the String value of the property.
Throws:
org.eclipse.core.runtime.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:
IResource.setPersistentProperty(QualifiedName, String)

getProject

public IProject getProject()
Description copied from interface: IResource
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.

Specified by:
getProject in interface IResource
Returns:
the project handle

getProjectRelativePath

public org.eclipse.core.runtime.IPath getProjectRelativePath()
Description copied from interface: IResource
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 project, 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 not affected if the project is renamed.

Specified by:
getProjectRelativePath in interface IResource
Returns:
the relative path of this resource with respect to its project
See Also:
IResource.getFullPath(), IResource.getProject(), Path.EMPTY

getPropertyManager

public IPropertyManager getPropertyManager()

getRawLocation

public org.eclipse.core.runtime.IPath getRawLocation()
Description copied from interface: IResource
Returns the file system location of this resource, or null if no path can be determined. The returned path will either be an absolute file system path, or a relative path whose first segment is the name of a workspace path variable.

If this resource is an existing project, the returned path will be equal to the location path in the project description. If this resource is a linked resource in an open project, the returned path will be equal to the location path supplied when the linked resource was created. In all other cases, this method returns the same value as IResource.getLocation().

Specified by:
getRawLocation in interface IResource
Returns:
the raw path of this resource in the local file system, or null if no path can be determined
See Also:
IResource.getLocation(), IFile.createLink(IPath, int, IProgressMonitor), IFolder.createLink(IPath, int, IProgressMonitor), IPathVariableManager, IProjectDescription.getLocation()

getRawLocationURI

public java.net.URI getRawLocationURI()
Description copied from interface: IResource
Returns the file system location of this resource, or null if no path can be determined. The returned path will either be an absolute URI, or a relative URI whose first path segment is the name of a workspace path variable.

If this resource is an existing project, the returned path will be equal to the location path in the project description. If this resource is a linked resource in an open project, the returned path will be equal to the location path supplied when the linked resource was created. In all other cases, this method returns the same value as IResource.getLocationURI().

Specified by:
getRawLocationURI in interface IResource
Returns:
the raw path of this resource in the file system, or null if no path can be determined
See Also:
IResource.getLocationURI(), IFile.createLink(URI, int, IProgressMonitor), IFolder.createLink(URI, int, IProgressMonitor), IPathVariableManager, IProjectDescription.getLocationURI()

getResourceAttributes

public ResourceAttributes getResourceAttributes()
Description copied from interface: IResource
Gets this resource's extended attributes from the file system, or null if the attributes could not be obtained.

Reasons for a null return value include:

Attributes that are not supported by the underlying file system will have a value of false.

Sample usage:

IResource resource;
...
ResourceAttributes attributes = resource.getResourceAttributes();
if (attributes != null) { attributes.setExecutable(true);
resource.setResourceAttributes(attributes);
}

Specified by:
getResourceAttributes in interface IResource
Returns:
the extended attributes from the file system, or null if they could not be obtained
See Also:
IResource.setResourceAttributes(ResourceAttributes), ResourceAttributes

getResourceInfo

public ResourceInfo getResourceInfo(boolean phantom,
                                    boolean mutable)
Returns the resource info. Returns null if the resource doesn't exist. If the phantom flag is true, phantom resources are considered. If the mutable flag is true, a mutable info is returned.


getSessionProperty

public java.lang.Object getSessionProperty(org.eclipse.core.runtime.QualifiedName key)
                                    throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Returns the value of the session property of this resource identified by the given key, or null if this resource has no such property.

Specified by:
getSessionProperty in interface IResource
Parameters:
key - the qualified name of the property
Returns:
the value of the session property, or null if this resource has no such property
Throws:
org.eclipse.core.runtime.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:
IResource.setSessionProperty(QualifiedName, Object)

getSessionProperties

public java.util.Map getSessionProperties()
                                   throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Returns a copy of the map of this resource's session properties. Returns an empty map if this resource has no session properties.

Specified by:
getSessionProperties in interface IResource
Returns:
the map containing the session properties where the key is the QualifiedName of the property and the value is the property value (an Object.
Throws:
org.eclipse.core.runtime.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:
IResource.setSessionProperty(QualifiedName, Object)

getStore

public org.eclipse.core.filesystem.IFileStore getStore()

getType

public abstract int getType()
Description copied from interface: IResource
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.

Specified by:
getType in interface IResource
Returns:
the type of this resource
See Also:
IResource.FILE, IResource.FOLDER, IResource.PROJECT, IResource.ROOT

getTypeString

public java.lang.String getTypeString()

getWorkspace

public IWorkspace getWorkspace()
Description copied from interface: IResource
Returns the workspace which manages this resource.

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

Specified by:
getWorkspace in interface IResource
Returns:
the workspace

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isAccessible

public boolean isAccessible()
Description copied from interface: IResource
Returns whether this resource is accessible. For files and folders, this is equivalent to existing; for projects, this is equivalent to existing and being open. The workspace root is always accessible.

Specified by:
isAccessible in interface IResource
Returns:
true if this resource is accessible, and false otherwise
See Also:
IResource.exists(), IProject.isOpen()

isConflicting

public boolean isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule rule)
Specified by:
isConflicting in interface org.eclipse.core.runtime.jobs.ISchedulingRule

isDerived

public boolean isDerived()
Description copied from interface: IResource
Returns whether this resource subtree is marked as derived. Returns false if this resource does not exist.

This is a convenience method, fully equivalent to isDerived(IResource.NONE).

Specified by:
isDerived in interface IResource
Returns:
true if this resource is marked as derived, and false otherwise
See Also:
IResource.setDerived(boolean)

isDerived

public boolean isDerived(int options)
Description copied from interface: IResource
Returns whether this resource subtree is marked as derived. Returns false if this resource does not exist.

The IResource.CHECK_ANCESTORS option flag indicates whether this method should consider ancestor resources in its calculation. If the IResource.CHECK_ANCESTORS flag is present, this method will return true, if this resource, or any parent resource, is marked as derived. If the IResource.CHECK_ANCESTORS option flag is not specified, this method returns false for children of derived resources.

Specified by:
isDerived in interface IResource
Parameters:
options - bit-wise or of option flag constants (only IResource.CHECK_ANCESTORS is applicable)
Returns:
true if this resource subtree is derived, and false otherwise
See Also:
IResource.setDerived(boolean)

isHidden

public boolean isHidden()
Description copied from interface: IResource
Returns whether this resource is hidden in the resource tree. Returns false if this resource does not exist.

This operation is not related to the file system hidden attribute accessible using ResourceAttributes.isHidden().

Specified by:
isHidden in interface IResource
Returns:
true if this resource is hidden , and false otherwise
See Also:
IResource.setHidden(boolean)

isHidden

public boolean isHidden(int options)
Description copied from interface: IResource
Returns whether this resource is hidden in the resource tree. Returns false if this resource does not exist.

This operation is not related to the file system hidden attribute accessible using ResourceAttributes.isHidden().

The IResource.CHECK_ANCESTORS option flag indicates whether this method should consider ancestor resources in its calculation. If the IResource.CHECK_ANCESTORS flag is present, this method will return true if this resource, or any parent resource, is a hidden resource. If the IResource.CHECK_ANCESTORS option flag is not specified, this method returns false for children of hidden resources.

Specified by:
isHidden in interface IResource
Parameters:
options - bit-wise or of option flag constants (only IResource.CHECK_ANCESTORS is applicable)
Returns:
true if this resource is hidden , and false otherwise
See Also:
IResource.setHidden(boolean)

isLinked

public boolean isLinked()
Description copied from interface: IResource
Returns whether this resource has been linked to a location other than the default location calculated by the platform.

This is a convenience method, fully equivalent to isLinked(IResource.NONE).

Specified by:
isLinked in interface IResource
Returns:
true if this resource is linked, and false otherwise
See Also:
IFile.createLink(IPath, int, IProgressMonitor), IFolder.createLink(IPath, int, IProgressMonitor)

isLinked

public boolean isLinked(int options)
Description copied from interface: IResource
Returns true if this resource has been linked to a location other than the default location calculated by the platform. This location can be outside the project's content area or another location within the project. Returns false in all other cases, including the case where this resource does not exist. The workspace root and projects are never linked.

This method returns true only for a resource that has been linked using the createLink method.

The IResource.CHECK_ANCESTORS option flag indicates whether this method should consider ancestor resources in its calculation. If the IResource.CHECK_ANCESTORS flag is present, this method will return true if this resource, or any parent resource, is a linked resource. If the IResource.CHECK_ANCESTORS option flag is not specified, this method returns false for children of linked resources.

Specified by:
isLinked in interface IResource
Parameters:
options - bit-wise or of option flag constants (only IResource.CHECK_ANCESTORS is applicable)
Returns:
true if this resource is linked, and false otherwise
See Also:
IFile.createLink(IPath, int, IProgressMonitor), IFolder.createLink(IPath, int, IProgressMonitor)

isLocal

public boolean isLocal(int depth)
Deprecated. 

Description copied from interface: IResource
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.

Specified by:
isLocal in interface IResource
Parameters:
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
Returns:
true if this resource is local, and false otherwise
See Also:
IResource.isLocal(int)

isLocal

public boolean isLocal(int flags,
                       int depth)
Deprecated. 

Note the depth parameter is intentionally ignored because this method is over-ridden by Container.isLocal().


isPhantom

public boolean isPhantom()
Description copied from interface: IResource
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)).

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

isPhantom

public boolean isPhantom(int flags)

isReadOnly

public boolean isReadOnly()
Deprecated. 

(non-Javadoc)

Specified by:
isReadOnly in interface IResource
Returns:
true if this resource is read-only, false otherwise
See Also:
IResource.isReadOnly()

isSynchronized

public boolean isSynchronized(int depth)
Description copied from interface: IResource
Returns whether this resource and its descendents 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 file system. 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.

Specified by:
isSynchronized in interface IResource
Parameters:
depth - the depth (one of IResource.DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE)
Returns:
true if this resource and its descendents to the specified depth are synchronized, and false in all other cases
See Also:
IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE, IResource.refreshLocal(int, IProgressMonitor)

isTeamPrivateMember

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

Specified by:
isTeamPrivateMember in interface IResource
Returns:
true if this resource is a team private member, and false otherwise
See Also:
IResource.setTeamPrivateMember(boolean)

isTeamPrivateMember

public boolean isTeamPrivateMember(int options)
Description copied from interface: IResource
Returns whether this resource is a team private member of its parent container. Returns false if this resource does not exist.

The IResource.CHECK_ANCESTORS option flag indicates whether this method should consider ancestor resources in its calculation. If the IResource.CHECK_ANCESTORS flag is present, this method will return true if this resource, or any parent resource, is a team private member. If the IResource.CHECK_ANCESTORS option flag is not specified, this method returns false for children of team private members.

Specified by:
isTeamPrivateMember in interface IResource
Parameters:
options - bit-wise or of option flag constants (only IResource.CHECK_ANCESTORS is applicable)
Returns:
true if this resource is a team private member, and false otherwise
See Also:
IResource.setTeamPrivateMember(boolean)

isUnderLink

public boolean isUnderLink()
Returns true if this resource is a linked resource, or a child of a linked resource, and false otherwise.


move

public void move(org.eclipse.core.runtime.IPath destination,
                 boolean force,
                 boolean keepHistory,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

move

public void move(org.eclipse.core.runtime.IPath destination,
                 boolean force,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
move in interface IResource
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 is not desired
Throws:
org.eclipse.core.runtime.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(org.eclipse.core.runtime.IPath destination,
                 int updateFlags,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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 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 interest 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.

If this resource is not a project, an attempt will be made to copy the local history for this resource and its children, to the destination. Since local history existence is a safety-net mechanism, failure of this action will not result in automatic failure of the move operation.

The SHALLOW update flag controls how this method deals with linked resources. If SHALLOW is not specified, then the underlying contents of the linked resource will always be moved in the file system. In this case, the destination of the move will never be a linked resource or contain any linked resources. If SHALLOW is specified when a linked resource is moved into another project, a new linked resource is created in the destination project that points to the same file system location. When a project containing linked resources is moved, the new project will contain the same linked resources pointing to the same file system locations. For either of these cases, no files on disk under the linked resource are actually moved. With the SHALLOW flag, moving of linked resources into anything other than a project is not permitted. The SHALLOW update flag is ignored when moving non- linked resources.

Update flags other than FORCE, KEEP_HISTORYand SHALLOW 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.

Specified by:
move in interface IResource
Parameters:
destination - the destination path
updateFlags - bit-wise or of update flag constants (FORCE, KEEP_HISTORY and SHALLOW)
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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.
  • The source is a linked resource, but the destination is not a project and SHALLOW is specified.
  • 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.
  • The source resource is a file and the destination path specifies a project.
  • The location of the source resource on disk is the same or a prefix of the location of the destination resource on disk.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
IResourceDelta.getFlags(), IResource.FORCE, IResource.KEEP_HISTORY, IResource.SHALLOW, IResourceRuleFactory.moveRule(IResource, IResource)

move

public void move(IProjectDescription description,
                 boolean force,
                 boolean keepHistory,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
move in interface IResource
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 is not desired
Throws:
org.eclipse.core.runtime.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(IProjectDescription description,
                 int updateFlags,
                 org.eclipse.core.runtime.IProgressMonitor monitor)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Renames or relocates this project so that it is the project specified by the given project description. The description specifies the name and location 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 in the new 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. 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. In all other cases the directories and files on disk are left untouched. Parts of the supplied description other than the name and location 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 interest 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.

Local history information for this project and its children will not be moved to the destination.

The SHALLOW update flag controls how this method deals with linked resources. If SHALLOW is not specified, then the underlying contents of any linked resource will always be moved in the file system. In this case, the destination of the move will not contain any linked resources. If SHALLOW is specified when a project containing linked resources is moved, new linked resources are created in the destination project pointing to the same file system locations. In this case, no files on disk under any linked resource are actually moved. The SHALLOW update flag is ignored when moving non- linked resources.

The IResource.REPLACE update flag controls how this method deals with a change of location. If the location changes and the IResource.REPLACE flag is not specified, then the projects contents on disk are moved to the new location. If the location changes and the IResource.REPLACE flag is specified, then the project is reoriented to correspond to the new location, but no contents are moved on disk. The contents already on disk at the new location become the project contents. If the new project location does not exist, it will be created.

Update flags other than those listed above 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.

Specified by:
move in interface IResource
Parameters:
description - the destination project description
updateFlags - bit-wise or of update flag constants (IResource.FORCE, IResource.KEEP_HISTORY, IResource.SHALLOW and IResource.REPLACE).
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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.
  • The destination file system location is occupied. When moving a project in the file system, the destination directory must either not exist or be empty.
See Also:
IResourceDelta.getFlags(), IResource.FORCE, IResource.KEEP_HISTORY, IResource.SHALLOW, IResource.REPLACE, IResourceRuleFactory.moveRule(IResource, IResource)

refreshLocal

public void refreshLocal(int depth,
                         org.eclipse.core.runtime.IProgressMonitor monitor)
                  throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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.

Specified by:
refreshLocal in interface IResource
Parameters:
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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:
IResource.DEPTH_ZERO, IResource.DEPTH_ONE, IResource.DEPTH_INFINITE, IResourceRuleFactory.refreshRule(IResource)

requestName

public java.lang.String requestName()
Specified by:
requestName in interface IPathRequestor

requestPath

public org.eclipse.core.runtime.IPath requestPath()
Specified by:
requestPath in interface IPathRequestor

revertModificationStamp

public void revertModificationStamp(long value)
                             throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Reverts this resource's modification stamp. This is intended to be used by a client that is rolling back or undoing a previous change to this resource.

It is the caller's responsibility to ensure that the value of the reverted modification stamp matches this resource's modification stamp prior to the change that has been rolled back. More generally, the caller must ensure that the specification of modification stamps outlined in getModificationStamp is honored; the modification stamp of two distinct resource states should be different if and only if one or more of the attributes listed in the specification as affecting the modification stamp have changed.

Reverting the modification stamp will not be reported in a subsequent resource change event.

Note that a resource's modification stamp is unrelated to the local time stamp for this resource on disk, if any. A resource's local time stamp is modified using the setLocalTimeStamp method.

Specified by:
revertModificationStamp in interface IResource
Parameters:
value - A non-negative modification stamp value
Throws:
org.eclipse.core.runtime.CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • This resource is not accessible.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
See Also:
IResource.getModificationStamp()

setDerived

public void setDerived(boolean isDerived)
                throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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 are 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 autobuilds.

Specified by:
setDerived in interface IResource
Parameters:
isDerived - true if this resource is to be marked as derived, and false otherwise
Throws:
org.eclipse.core.runtime.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.
See Also:
IResource.isDerived()

setHidden

public void setHidden(boolean isHidden)
               throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Sets whether this resource and its members are hidden in the resource tree.

Hidden resources are invisible to most clients. Newly-created resources are not hidden resources by default.

The workspace root is never considered hidden resource; attempts to mark it as hidden are ignored.

This operation does not result in a resource change event, and does not trigger autobuilds.

This operation is not related to ResourceAttributes.setHidden(boolean). Whether a resource is hidden in the resource tree is unrelated to whether the underlying file is hidden in the file system.

Specified by:
setHidden in interface IResource
Parameters:
isHidden - true if this resource is to be marked as hidden, and false otherwise
Throws:
org.eclipse.core.runtime.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.
See Also:
IResource.isHidden()

setLocal

public void setLocal(boolean flag,
                     int depth,
                     org.eclipse.core.runtime.IProgressMonitor monitor)
              throws org.eclipse.core.runtime.CoreException
Deprecated. 

Description copied from interface: IResource
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.

Specified by:
setLocal in interface IResource
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 is not desired
Throws:
org.eclipse.core.runtime.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:
IResource.setLocal(boolean, int, IProgressMonitor)

setLocalTimeStamp

public long setLocalTimeStamp(long value)
                       throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Sets the local time stamp on disk for this resource. The time must be represented as the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970). Returns the actual time stamp that was recorded. Due to varying file system timing granularities, the provided value may be rounded or otherwise truncated, so the actual recorded time stamp that is returned may not be the same as the supplied value.

Specified by:
setLocalTimeStamp in interface IResource
Parameters:
value - a time stamp in milliseconds.
Returns:
a local file system time stamp.
Throws:
org.eclipse.core.runtime.CoreException - if this method fails. Reasons include:
  • This resource does not exist.
  • This resource is not local.
  • This resource is not accessible.
  • Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.

setPersistentProperty

public void setPersistentProperty(org.eclipse.core.runtime.QualifiedName key,
                                  java.lang.String value)
                           throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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 that must be short - 2KB or less in length. 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").

Specified by:
setPersistentProperty in interface IResource
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:
org.eclipse.core.runtime.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:
IResource.getPersistentProperty(QualifiedName), IResource.isLocal(int)

setReadOnly

public void setReadOnly(boolean readonly)
Deprecated. 

(non-Javadoc)

Specified by:
setReadOnly in interface IResource
Parameters:
readonly - true to set it to read-only, false to unset
See Also:
IResource.setReadOnly(boolean)

setResourceAttributes

public void setResourceAttributes(ResourceAttributes attributes)
                           throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
Sets this resource with the given extended attributes. This sets the attributes in the file system. Only attributes that are supported by the underlying file system will be set.

Sample usage:

IResource resource;
...
if (attributes != null) { attributes.setExecutable(true);
resource.setResourceAttributes(attributes);
}

Note that a resource cannot be converted into a symbolic link by setting resource attributes with ResourceAttributes.isSymbolicLink() set to true.

Specified by:
setResourceAttributes in interface IResource
Parameters:
attributes - the attributes to set
Throws:
org.eclipse.core.runtime.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:
IResource.getResourceAttributes()

setSessionProperty

public void setSessionProperty(org.eclipse.core.runtime.QualifiedName key,
                               java.lang.Object value)
                        throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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").

Specified by:
setSessionProperty in interface IResource
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:
org.eclipse.core.runtime.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:
IResource.getSessionProperty(QualifiedName)

setTeamPrivateMember

public void setTeamPrivateMember(boolean isTeamPrivate)
                          throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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 are 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 team private are ignored.

This operation does not result in a resource change event, and does not trigger autobuilds.

Specified by:
setTeamPrivateMember in interface IResource
Parameters:
isTeamPrivate - true if this resource is to be marked as team private, and false otherwise
Throws:
org.eclipse.core.runtime.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.
See Also:
IResource.isTeamPrivateMember()

synchronizing

public boolean synchronizing(ResourceInfo info)
Returns true if this resource has the potential to be (or have been) synchronized.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

touch

public void touch(org.eclipse.core.runtime.IProgressMonitor monitor)
           throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResource
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. If the resource is a project, the change event will indicate a description change.

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

Specified by:
touch in interface IResource
Parameters:
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
org.eclipse.core.runtime.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.
See Also:
IResourceRuleFactory.modifyRule(IResource), IResourceDelta.CONTENT, IResourceDelta.DESCRIPTION