Class ResourceTraversal
java.lang.Object
org.eclipse.core.resources.mapping.ResourceTraversal
A resource traversal is simply a set of resources and the depth to which
each is to be traversed. A set of traversals is used to describe the
resources that constitute a model element.
The flags of the traversal indicate which special resources should be
included or excluded from the traversal. The flags used are the same as
those passed to the IResource.accept(IResourceVisitor, int, int)
method.
This class may be instantiated or subclassed by clients.
- Since:
- 3.2
- See Also:
-
Constructor Summary
ConstructorDescriptionResourceTraversal
(IResource[] resources, int depth, int flags) Creates a new resource traversal. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(IResourceVisitor visitor) Visits all existing resources defined by this traversal.boolean
Return whether the given resource is contained in or covered by this traversal, regardless of whether the resource currently exists.IMarker[]
findMarkers
(String type, boolean includeSubtypes) Returns all markers of the specified type on existing resources in this traversal.int
getDepth()
Returns the depth to which the resources should be traversed.int
getFlags()
Return the flags for this traversal.Returns the file system resource(s) for this traversal.
-
Constructor Details
-
ResourceTraversal
Creates a new resource traversal.- Parameters:
resources
- The resources in the traversaldepth
- The traversal depthflags
- the flags for this traversal. The traversal flags match those that are passed to theIResource#accept
method.
-
-
Method Details
-
accept
Visits all existing resources defined by this traversal.- Parameters:
visitor
- a resource visitor- Throws:
CoreException
- if this method fails. Reasons include:- The visitor failed with this exception.
-
contains
Return whether the given resource is contained in or covered by this traversal, regardless of whether the resource currently exists.- Parameters:
resource
- the resource to be tested- Returns:
true
if the resource is in this traversal, andfalse
otherwise.
-
findMarkers
Returns all markers of the specified type on existing resources in this traversal. IfincludeSubtypes
isfalse
, only markers whose type exactly matches the given type are returned. Returns an empty array if there are no matching markers.- Parameters:
type
- the type of marker to consider, ornull
to indicate all typesincludeSubtypes
- whether or not to consider sub-types of the given type- Returns:
- an array of markers
- Throws:
CoreException
- if this method fails.- See Also:
-
getDepth
public int getDepth()Returns the depth to which the resources should be traversed.- Returns:
- the depth to which the physical resources are to be traversed (one of IResource.DEPTH_ZERO, IResource.DEPTH_ONE or IResource.DEPTH_INFINITE)
-
getFlags
public int getFlags()Return the flags for this traversal. The flags of the traversal indicate which special resources should be included or excluded from the traversal. The flags used are the same as those passed to theIResource#accept(IResourceVisitor, int, int)
method. Clients who traverse the resources manually (i.e. without callingaccept
) should respect the flags when determining which resources are included in the traversal.- Returns:
- the flags for this traversal
-
getResources
Returns the file system resource(s) for this traversal. The returned resources must be contained within the same project and need not exist in the local file system. The traversal of the returned resources should be done considering the flag returned by getDepth. If a resource returned by a traversal is a file, it should always be visited. If a resource of a traversal is a folder then files contained in the folder can only be visited if the folder is IResource.DEPTH_ONE or IResource.DEPTH_INFINITE. Child folders should only be visited if the depth is IResource.DEPTH_INFINITE.- Returns:
- The resources in this traversal
-