org.eclipse.core.internal.events
Class ResourceDelta

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.core.internal.events.ResourceDelta
All Implemented Interfaces:
IResourceDelta, org.eclipse.core.runtime.IAdaptable

public class ResourceDelta
extends org.eclipse.core.runtime.PlatformObject
implements IResourceDelta

Concrete implementation of the IResourceDelta interface. Each ResourceDelta object represents changes that have occurred between two states of the resource tree.


Field Summary
 
Fields inherited from interface org.eclipse.core.resources.IResourceDelta
ADDED, ADDED_PHANTOM, ALL_WITH_PHANTOMS, CHANGED, CONTENT, COPIED_FROM, DESCRIPTION, ENCODING, LOCAL_CHANGED, MARKERS, MOVED_FROM, MOVED_TO, NO_CHANGE, OPEN, REMOVED, REMOVED_PHANTOM, REPLACED, SYNC, TYPE
 
Method Summary
 void accept(IResourceDeltaVisitor visitor)
          Accepts the given visitor.
 void accept(IResourceDeltaVisitor visitor, boolean includePhantoms)
          Accepts the given visitor.
 void accept(IResourceDeltaVisitor visitor, int memberFlags)
          Accepts the given visitor.
 IResourceDelta findMember(org.eclipse.core.runtime.IPath path)
          Finds and returns the descendent delta identified by the given path in this delta, or null if no such descendent exists.
 IResourceDelta[] getAffectedChildren()
          Returns resource deltas for all children of this resource which were added, removed, or changed.
 IResourceDelta[] getAffectedChildren(int kindMask)
          Returns resource deltas for all children of this resource whose kind is included in the given mask.
 IResourceDelta[] getAffectedChildren(int kindMask, int memberFlags)
          Returns resource deltas for all children of this resource whose kind is included in the given mask.
 int getFlags()
          Returns flags which describe in more detail how a resource has been affected.
 org.eclipse.core.runtime.IPath getFullPath()
          Returns the full, absolute path of this resource delta.
 int getKind()
          Returns the kind of this resource delta.
 IMarkerDelta[] getMarkerDeltas()
          Returns the changes to markers on the corresponding resource.
 org.eclipse.core.runtime.IPath getMovedFromPath()
          Returns the full path (in the "before" state) from which this resource (in the "after" state) was moved.
 org.eclipse.core.runtime.IPath getMovedToPath()
          Returns the full path (in the "after" state) to which this resource (in the "before" state) was moved.
 org.eclipse.core.runtime.IPath getProjectRelativePath()
          Returns the project-relative path of this resource delta.
 IResource getResource()
          Returns a handle for the affected resource.
 java.lang.String toDebugString()
          Returns a string representation of this delta's immediate structure suitable for debug purposes.
 java.lang.String toDeepDebugString()
          Returns a string representation of this delta's deep structure suitable for debug purposes.
 java.lang.String toString()
          For debugging only
 void updateMarkers(java.util.Map markers)
          Provides a new set of markers for the delta.
 void writeDebugString(java.lang.StringBuffer buffer)
          Writes a string representation of this delta's immediate structure on the given string buffer.
 void writeMarkerDebugString(java.lang.StringBuffer buffer)
           
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Method Detail

accept

public void accept(IResourceDeltaVisitor visitor)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResourceDelta
Accepts the given visitor. The only kinds of resource deltas visited are ADDED, REMOVED, and CHANGED. The visitor's visit method is called with this resource delta if applicable. If the visitor returns true, the resource delta's children are also visited.

This is a convenience method, fully equivalent to accept(visitor, IResource.NONE). Although the visitor will be invoked for this resource delta, it will not be invoked for any team-private member resources.

Specified by:
accept in interface IResourceDelta
Parameters:
visitor - the visitor
Throws:
org.eclipse.core.runtime.CoreException - if the visitor failed with this exception.
See Also:
IResourceDeltaVisitor.visit(IResourceDelta)

accept

public void accept(IResourceDeltaVisitor visitor,
                   boolean includePhantoms)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResourceDelta
Accepts the given visitor. The visitor's visit method is called with this resource delta. If the visitor returns true, the resource delta's children are also visited.

This is a convenience method, fully equivalent to:

   accept(visitor, includePhantoms ? INCLUDE_PHANTOMS : IResource.NONE);
 
Although the visitor will be invoked for this resource delta, it will not be invoked for any team-private member resources.

Specified by:
accept in interface IResourceDelta
Parameters:
visitor - the visitor
includePhantoms - true if phantom resources are of interest; false if phantom resources are not of interest
Throws:
org.eclipse.core.runtime.CoreException - if the visitor failed with this exception.
See Also:
IResourceDelta.accept(IResourceDeltaVisitor), IResource.isPhantom(), IResourceDeltaVisitor.visit(IResourceDelta)

accept

public void accept(IResourceDeltaVisitor visitor,
                   int memberFlags)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: IResourceDelta
Accepts the given visitor. The visitor's visit method is called with this resource delta. If the visitor returns true, the resource delta's children are also visited.

The member flags determine which child deltas of this resource delta will be visited. The visitor will always be invoked for this resource delta.

If the INCLUDE_PHANTOMS member flag is not specified (recommended), only child resource deltas involving existing resources will be visited (kinds ADDED, REMOVED, and CHANGED). If the INCLUDE_PHANTOMS member flag is specified, the result will also include additions and removes of phantom resources (kinds ADDED_PHANTOM and REMOVED_PHANTOM).

If the INCLUDE_TEAM_PRIVATE_MEMBERS member flag is not specified (recommended), resource deltas involving team private member resources will be excluded from the visit. If the INCLUDE_TEAM_PRIVATE_MEMBERS member flag is specified, the visit will also include additions and removes of team private member resources.

Specified by:
accept in interface IResourceDelta
Parameters:
visitor - the visitor
memberFlags - bit-wise or of member flag constants (IContainer.INCLUDE_PHANTOMS, INCLUDE_HIDDEN and INCLUDE_TEAM_PRIVATE_MEMBERS) indicating which members are of interest
Throws:
org.eclipse.core.runtime.CoreException - if the visitor failed with this exception.
See Also:
IResource.isPhantom(), IResource.isTeamPrivateMember(), IResource.isHidden(), IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS, IContainer.INCLUDE_HIDDEN, IResourceDeltaVisitor.visit(IResourceDelta)

findMember

public IResourceDelta findMember(org.eclipse.core.runtime.IPath path)
Description copied from interface: IResourceDelta
Finds and returns the descendent delta identified by the given path in this delta, or null if no such descendent exists. The supplied path may be absolute or relative; in either case, it is interpreted as relative to this delta. Trailing separators are ignored. If the path is empty this delta is returned.

This is a convenience method to avoid manual traversal of the delta tree in cases where the listener is only interested in changes to particular resources. Calling this method will generally be faster than manually traversing the delta to a particular descendent.

Specified by:
findMember in interface IResourceDelta
Parameters:
path - the path of the desired descendent delta
Returns:
the descendent delta, or null if no such descendent exists in the delta
See Also:
IResourceDelta.findMember(IPath)

getAffectedChildren

public IResourceDelta[] getAffectedChildren()
Description copied from interface: IResourceDelta
Returns resource deltas for all children of this resource which were added, removed, or changed. Returns an empty array if there are no affected children.

This is a convenience method, fully equivalent to:

   getAffectedChildren(ADDED | REMOVED | CHANGED, IResource.NONE);
 
Team-private member resources are not included in the result; neither are phantom resources.

Specified by:
getAffectedChildren in interface IResourceDelta
Returns:
the resource deltas for all affected children
See Also:
IResourceDelta.getAffectedChildren()

getAffectedChildren

public IResourceDelta[] getAffectedChildren(int kindMask)
Description copied from interface: IResourceDelta
Returns resource deltas for all children of this resource whose kind is included in the given mask. Kind masks are formed by the bitwise or of IResourceDelta kind constants. Returns an empty array if there are no affected children.

This is a convenience method, fully equivalent to:

   getAffectedChildren(kindMask, IResource.NONE);
 
Team-private member resources are not included in the result.

Specified by:
getAffectedChildren in interface IResourceDelta
Parameters:
kindMask - a mask formed by the bitwise or of IResourceDelta delta kind constants
Returns:
the resource deltas for all affected children
See Also:
IResourceDelta.getAffectedChildren(int)

getAffectedChildren

public IResourceDelta[] getAffectedChildren(int kindMask,
                                            int memberFlags)
Description copied from interface: IResourceDelta
Returns resource deltas for all children of this resource whose kind is included in the given mask. Masks are formed by the bitwise or of IResourceDelta kind constants. Returns an empty array if there are no affected children.

If the INCLUDE_TEAM_PRIVATE_MEMBERS member flag is not specified, (recommended), resource deltas involving team private member resources will be excluded. If the INCLUDE_TEAM_PRIVATE_MEMBERS member flag is specified, the result will also include resource deltas of the specified kinds to team private member resources.

If the IContainer.INCLUDE_HIDDEN member flag is not specified, (recommended), resource deltas involving hidden resources will be excluded. If the IContainer.INCLUDE_HIDDEN member flag is specified, the result will also include resource deltas of the specified kinds to hidden resources.

Specifying the IContainer.INCLUDE_PHANTOMS member flag is equivalent to including IContainer.ADDED_PHANTOM and IContainer.REMOVED_PHANTOM in the kind mask.

Specified by:
getAffectedChildren in interface IResourceDelta
Parameters:
kindMask - a mask formed by the bitwise or of IResourceDelta delta kind constants
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
Returns:
the resource deltas for all affected children
See Also:
IResourceDelta.ADDED, IResourceDelta.REMOVED, IResourceDelta.CHANGED, IResourceDelta.ADDED_PHANTOM, IResourceDelta.REMOVED_PHANTOM, IResourceDelta.ALL_WITH_PHANTOMS, IContainer.INCLUDE_PHANTOMS, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS, IContainer.INCLUDE_HIDDEN

getFlags

public int getFlags()
Description copied from interface: IResourceDelta
Returns flags which describe in more detail how a resource has been affected.

The following codes (bit masks) are used when kind is CHANGED, and also when the resource is involved in a move:

The following code is only used if kind is REMOVED (or CHANGED in conjunction with REPLACED): The following code is only used if kind is ADDED (or CHANGED in conjunction with REPLACED): A simple move operation would result in the following delta information. If a resource is moved from A to B (with no other changes to A or B), then A will have kind REMOVED, with flag MOVED_TO, and getMovedToPath on A will return the path for B. B will have kind ADDED, with flag MOVED_FROM, and getMovedFromPath on B will return the path for A. B's other flags will describe any other changes to the resource, as compared to its previous location at A.

Note that the move flags only describe the changes to a single resource; they don't necessarily imply anything about the parent or children of the resource. If the children were moved as a consequence of a subtree move operation, they will have corresponding move flags as well.

Note that it is possible for a file resource to be replaced in the workspace by a folder resource (or the other way around). The resource delta, which is actually expressed in terms of paths instead or resources, shows this as a change to either the content or children.

Specified by:
getFlags in interface IResourceDelta
Returns:
the flags
See Also:
IResourceDelta.getFlags()

getFullPath

public org.eclipse.core.runtime.IPath getFullPath()
Description copied from interface: IResourceDelta
Returns the full, absolute path of this resource delta.

Note: the returned path never has a trailing separator.

Specified by:
getFullPath in interface IResourceDelta
Returns:
the full, absolute path of this resource delta
See Also:
IResourceDelta.getFullPath()

getKind

public int getKind()
Description copied from interface: IResourceDelta
Returns the kind of this resource delta. Normally, one of ADDED, REMOVED, CHANGED. When phantom resources have been explicitly requested, there are two additional kinds: ADDED_PHANTOM and REMOVED_PHANTOM.

Specified by:
getKind in interface IResourceDelta
Returns:
the kind of this resource delta
See Also:
IResourceDelta.getKind()

getMarkerDeltas

public IMarkerDelta[] getMarkerDeltas()
Description copied from interface: IResourceDelta
Returns the changes to markers on the corresponding resource. Returns an empty array if no markers changed.

Specified by:
getMarkerDeltas in interface IResourceDelta
Returns:
the marker deltas
See Also:
IResourceDelta.getMarkerDeltas()

getMovedFromPath

public org.eclipse.core.runtime.IPath getMovedFromPath()
Description copied from interface: IResourceDelta
Returns the full path (in the "before" state) from which this resource (in the "after" state) was moved. This value is only valid if the MOVED_FROM change flag is set; otherwise, null is returned.

Note: the returned path never has a trailing separator.

Specified by:
getMovedFromPath in interface IResourceDelta
Returns:
a path, or null
See Also:
IResourceDelta.getMovedFromPath()

getMovedToPath

public org.eclipse.core.runtime.IPath getMovedToPath()
Description copied from interface: IResourceDelta
Returns the full path (in the "after" state) to which this resource (in the "before" state) was moved. This value is only valid if the MOVED_TO change flag is set; otherwise, null is returned.

Note: the returned path never has a trailing separator.

Specified by:
getMovedToPath in interface IResourceDelta
Returns:
a path, or null
See Also:
IResourceDelta.getMovedToPath()

getProjectRelativePath

public org.eclipse.core.runtime.IPath getProjectRelativePath()
Description copied from interface: IResourceDelta
Returns the project-relative path of this resource delta. Returns the empty path for projects and the workspace root.

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

Specified by:
getProjectRelativePath in interface IResourceDelta
Returns:
the project-relative path of this resource delta
See Also:
IResourceDelta.getProjectRelativePath()

getResource

public IResource getResource()
Description copied from interface: IResourceDelta
Returns a handle for the affected resource.

For additions (ADDED), this handle describes the newly-added resource; i.e., the one in the "after" state.

For changes (CHANGED), this handle also describes the resource in the "after" state. When a file or folder resource has changed type, the former type of the handle can be inferred.

For removals (REMOVED), this handle describes the resource in the "before" state. Even though this resource would not normally exist in the current workspace, the type of resource that was removed can be determined from the handle.

For phantom additions and removals (ADDED_PHANTOM and REMOVED_PHANTOM), this is the handle of the phantom resource.

Specified by:
getResource in interface IResourceDelta
Returns:
the affected resource (handle)
See Also:
IResourceDelta.getResource()

toDebugString

public java.lang.String toDebugString()
Returns a string representation of this delta's immediate structure suitable for debug purposes.


toDeepDebugString

public java.lang.String toDeepDebugString()
Returns a string representation of this delta's deep structure suitable for debug purposes.


toString

public java.lang.String toString()
For debugging only

Overrides:
toString in class java.lang.Object

updateMarkers

public void updateMarkers(java.util.Map markers)
Provides a new set of markers for the delta. This is used when the delta is reused in cases where the only changes are marker changes.


writeDebugString

public void writeDebugString(java.lang.StringBuffer buffer)
Writes a string representation of this delta's immediate structure on the given string buffer.


writeMarkerDebugString

public void writeMarkerDebugString(java.lang.StringBuffer buffer)