Class StreamAccessorStorage

java.lang.Object
org.eclipse.emf.compare.ide.ui.internal.logical.StreamAccessorStorage
All Implemented Interfaces:
org.eclipse.core.resources.IStorage, org.eclipse.core.runtime.IAdaptable, IStoragePathAdapterProvider

public class StreamAccessorStorage extends Object implements org.eclipse.core.resources.IStorage, IStoragePathAdapterProvider
This implementation of IStorage simply wraps a stream content accessor.
  • Constructor Details

    • StreamAccessorStorage

      public StreamAccessorStorage(org.eclipse.compare.IStreamContentAccessor accessor, String fullPath)
      Wraps the given accessor.
      Parameters:
      accessor - The accessor to wrap as an IStorage.
      fullPath - Full path to the underlying storage.
  • Method Details

    • fromTypedElement

      public static StreamAccessorStorage fromTypedElement(org.eclipse.compare.ITypedElement element) throws IllegalArgumentException
      This is a short-hand for fromTypedElement(String, ITypedElement). This second one should be preferred in case the given element is remote and we need a proper path for it.
      Parameters:
      element - The typed element for which we need to create a wrapper.
      Returns:
      The wrapped typed element.
      Throws:
      IllegalArgumentException - If the given element does not implement IStreamContentAccessor.
    • fromTypedElement

      public static StreamAccessorStorage fromTypedElement(String storagePath, org.eclipse.compare.ITypedElement element) throws IllegalArgumentException
      Creates a StreamAccessorStorage given the input typed element. Note that the given typed element -must- implement IStreamContentAccessor as well.
      Parameters:
      storagePath - The full path to this storage, can be null.
      element - The typed element for which we need to create a wrapper.
      Returns:
      The wrapped typed element.
      Throws:
      IllegalArgumentException - If the given element does not implement IStreamContentAccessor.
    • findCommitId

      public static org.eclipse.team.core.history.IFileRevision findCommitId(org.eclipse.compare.ITypedElement element)
      Get the commit id for the given element
      Parameters:
      element - The element for which we want the commit id
      Returns:
      the commit id
    • createStoragePathAdapter

      public Adapter createStoragePathAdapter(String path, boolean isLocal)
      This method is used to create a new StoragePathAdapter.
      Specified by:
      createStoragePathAdapter in interface IStoragePathAdapterProvider
      Parameters:
      path - The path to use.
      isLocal - Whether this storage is local.
      Returns:
      the new adapter
      See Also:
      • IStoragePathAdapterProvider#createStoragePathAdapter()
    • getAdapter

      public Object getAdapter(Class adapter)
      Specified by:
      getAdapter in interface org.eclipse.core.runtime.IAdaptable
      See Also:
      • IAdaptable.getAdapter(java.lang.Class)
    • getContents

      public InputStream getContents() throws org.eclipse.core.runtime.CoreException
      Specified by:
      getContents in interface org.eclipse.core.resources.IStorage
      Throws:
      org.eclipse.core.runtime.CoreException
      See Also:
      • IStorage.getContents()
    • getFullPath

      public org.eclipse.core.runtime.IPath getFullPath()
      Specified by:
      getFullPath in interface org.eclipse.core.resources.IStorage
      See Also:
      • IStorage.getFullPath()
    • getName

      public String getName()
      Specified by:
      getName in interface org.eclipse.core.resources.IStorage
      See Also:
      • IStorage.getName()
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface org.eclipse.core.resources.IStorage
      See Also:
      • IStorage.isReadOnly()