Interface AResource

    • Field Detail

      • COMPARING_BY_NAME

        static final java.util.Comparator<AResource> COMPARING_BY_NAME
        A Comparator comparing resources by name.
    • Method Detail

      • getName

        java.lang.String getName()
        The local name of this resource inside its parent.
        Returns:
        this resource's name
      • getType

        AResource.AResourceType getType()
        A resource type can be used instead of checking for instanceof with concrete implementations.
        Returns:
        the resource's type
      • exists

        boolean exists()
        A resource exists if its file-system equivalent exists (the path corresponds to an actual file/folder).
        Returns:
        whether this resource exists
      • isAccessible

        boolean isAccessible()
        An accessible resource exists() and can be used. For example a project in Eclipse needs to be open to be accessible.
        Returns:
        whether this resource is accessible
      • isDerived

        boolean isDerived()
        Returns whether this resource is derived (can be recreated from source files).
      • setDerived

        void setDerived​(boolean isDerived,
                        @CheckForNull
                        org.eclipse.core.runtime.IProgressMonitor monitor)
        Sets this resource (and, in case this is a container, its children) as derived.
        Parameters:
        isDerived - whether to mark this resource as derived
        monitor - a progress monitor that is notified about this process. When marking a directory as (not) derived, individual file processing is reported to the monitor to allow fine-grained progress reporting. The monitor may be null when progress does not need to be reported.
      • getParent

        @CheckForNull
        AContainer getParent()
        A resource's parent ist the resource representing the containing folder. Not all resources have a parent, for example a workspace only contains other resources but has not parent.
        Returns:
        this resource's parent, or null if it has no parent
      • getProject

        @CheckForNull
        AProject getProject()
        Returns the project containing this resource.
        Returns:
        the project containing this resource; the project itself if this resource is a project and null if this resource is the workspace.
      • getWorkspace

        AWorkspace getWorkspace()
        Returns the workspace containing this resource.
        Returns:
        the workspace containing this resource; the workspace itself if this resource is a workspace.
      • getLocation

        java.nio.file.Path getLocation()
        Returns the absolute location of this resource in the file system.
        Returns:
        this resource's location
      • getProjectRelativePath

        java.nio.file.Path getProjectRelativePath()
        Returns the relative location of this resource in the containing project.
        Returns:
        this resource's location relative to its project or an empty path if the resource is not contained in a project
      • getWorkspaceRelativePath

        java.nio.file.Path getWorkspaceRelativePath()
        Returns the relative location of this resource in the containing workspace.
        Returns:
        this resource's location relative to its project or an empty path if the resource is not contained in a workspace
      • getModificationStamp

        long getModificationStamp()
        Returns the corresponding file's modification stamp. This may correspond to the getLocalTimeStamp() from the file system or be more fine-grained.
        Returns:
        the file's modification time stamp, or -1 if the file does not exist
      • getLocalTimeStamp

        long getLocalTimeStamp()
        Returns the corresponding file's last modification as milliseconds since the epoch (1970-1-1).
        Returns:
        the file's time stamp, or -1 if the file does not exist
      • refreshLocal

        void refreshLocal​(AResource.AResourceTreeTraversalDepth depth,
                          @CheckForNull
                          org.eclipse.core.runtime.IProgressMonitor monitor)
        Synchronizes this resource with its corresponding file-system objects.
        Parameters:
        depth - whether to synchronize only this resource, or also its children (and their children...)
        monitor - a progress monitor that is notified about this process. When synchronizing a directory, individual file synchronization is reported to the monitor to allow fine-grained progress reporting. The monitor may be null when progress does not need to be reported.
      • isSynchronized

        boolean isSynchronized​(AResource.AResourceTreeTraversalDepth depth)
        Checks whether this resource is in sync with its corresponding file-system resource. Both need to
        Parameters:
        depth - whether to check only this resource, or also its children (and their children...)
        Returns:
        whether this resource (and its children) is/are in sync with its/their corresponding file-system resource(s)
      • touch

        void touch​(org.eclipse.core.runtime.IProgressMonitor monitor)
        Marks this resource as modified, updating the local time stamp and modification stamp.
        Parameters:
        monitor - a progress monitor that is notified about this process. The monitor may be null when progress does not need to be reported.
      • findMarkers

        java.util.Set<AMarker> findMarkers​(java.lang.String type,
                                           boolean includeSubtypes,
                                           AResource.AResourceTreeTraversalDepth depth)
        Returns all markers of the given type on this resource. If includeSubtypes is true, then markers of types that are subtypes of the given type are also returned. The depth determines whether only markers from this resource are returned or also from its children (if this resource is a container).
        Parameters:
        type - a marker type
        includeSubtypes - whether to include subtypes of the given marker type
        depth - whether to scan only this resource, or also its children (and their children...)
        Returns:
        all markers matching the given type and search depth
      • createMarker

        AMarker createMarker​(java.lang.String markerType)
        Creates a new marker of the given type for this resource.
        Parameters:
        markerType - the marker type
        Returns:
        the created marker
      • deleteMarkers

        void deleteMarkers​(java.lang.String type,
                           boolean includeSubtypes,
                           AResource.AResourceTreeTraversalDepth depth)
        Deletes all markers of the given type from this resource. If includeSubtypes is true, then markers of types that are subtypes of the given type are also deleted. The depth determines whether only markers from this resource are deleted or also from its children.
        Parameters:
        type - a marker type
        includeSubtypes - whether to include subtypes of the given marker type
        depth - whether to clean only this resource, or also its children (and their children...)
      • delete

        void delete​(@CheckForNull
                    org.eclipse.core.runtime.IProgressMonitor monitor)
        Deletes the resource from the file system.
        Parameters:
        monitor - a progress monitor that is notified about the deletion process. When deleting a directory, individual file deletions are reported to the monitor to allow fine-grained progress reporting. The monitor may be null when progress does not need to be reported.
      • copy

        void copy​(java.nio.file.Path destination,
                  @CheckForNull
                  org.eclipse.core.runtime.IProgressMonitor monitor)
        Copies this resource to the given destination.
        Parameters:
        destination - an existing resource of the same type as this resource
        monitor - a progress monitor that is notified about the copy process. When copying a directory, individual file copies are reported to the monitor to allow fine-grained progress reporting. The monitor may be null when progress does not need to be reported.
      • move

        void move​(java.nio.file.Path destination,
                  @CheckForNull
                  org.eclipse.core.runtime.IProgressMonitor monitor)
        Moves this resource to the given destination.
        Parameters:
        destination - an existing resource of the same type as this resource
        monitor - a progress monitor that is notified about the move process. When moving a directory, individual file copies are reported to the monitor to allow fine-grained progress reporting. The monitor may be null when progress does not need to be reported.
      • compareTo

        default int compareTo​(AResource o)
        Specified by:
        compareTo in interface java.lang.Comparable<AResource>