Class ResourceSnapshotFactory

java.lang.Object
org.eclipse.core.resources.undo.snapshot.ResourceSnapshotFactory

public class ResourceSnapshotFactory extends Object
ResourceSnapshotFactory provides utility methods for creating snapshots of resources or markers.
Since:
3.20
  • Constructor Details

    • ResourceSnapshotFactory

      public ResourceSnapshotFactory()
  • Method Details

    • fromResource

      public static <T extends IResource> IResourceSnapshot<T> fromResource(T resource)
      Create a resource snapshot given the specified resource. The resource is assumed to exist.
      Parameters:
      resource - the resource from which a description should be created
      Returns:
      the resource description
    • fromProjectDescription

      public static IContainerSnapshot<IProject> fromProjectDescription(IProjectDescription projectDescription)
      Create a project snapshot from a specified IProjectDescription. Used when the project does not yet exist.
      Parameters:
      projectDescription - the project description for the future project
    • fromContainer

      public static IContainerSnapshot<? extends IContainer> fromContainer(IContainer container)
      Create a container description from the specified container handle that can be used to create the container. The returned ContainerDescription should represent any non-existing parents in addition to the specified container.
      Parameters:
      container - the handle of the container to be described
      Returns:
      a container description describing the container and any non-existing parents.
    • fromVirtualFolderContainer

      public static IContainerSnapshot<? extends IContainer> fromVirtualFolderContainer(IContainer container)
      Create a group container description from the specified container handle that can be used to create the container. The returned ContainerDescription should represent any non-existing parents in addition to the specified container.
      Parameters:
      container - the handle of the container to be described
      Returns:
      a container description describing the container and any non-existing parents.
    • fromFileDetails

      public static IResourceSnapshot<IFile> fromFileDetails(IFile file, URI linkLocation, InputStream contents)
      Create a file snapshot from the specified file handle. The handle does not exist, so no information should be derived from it. If a location path is specified, this file should represent a link to another location. The content description describes any state that should be used when the file resource is created.
      Parameters:
      file - the file to be described
      linkLocation - the location of the file's link, or null if the file is not linked
      contents - an input stream representing the contents of the file
    • fromMarker

      public static IMarkerSnapshot fromMarker(IMarker marker) throws CoreException
      Create a marker snapshot from the specified marker.
      Parameters:
      marker - the marker to be described
      Throws:
      CoreException
    • fromMarkerDetails

      public static IMarkerSnapshot fromMarkerDetails(String type, Map<String,Object> attributes, IResource resource)
      Create a marker snapshot from the specified marker type, attributes, and resource.
      Parameters:
      type - the type of marker to be created.
      attributes - the attributes to be assigned to the marker
      resource - the resource on which the marker should be created