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 Summary
Constructors Constructor Description StreamAccessorStorage(org.eclipse.compare.IStreamContentAccessor accessor, String fullPath)
Wraps the given accessor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Adapter
createStoragePathAdapter(String path, boolean isLocal)
This method is used to create a new StoragePathAdapter.static org.eclipse.team.core.history.IFileRevision
findCommitId(org.eclipse.compare.ITypedElement element)
Get the commit id for the given elementstatic StreamAccessorStorage
fromTypedElement(String storagePath, org.eclipse.compare.ITypedElement element)
Creates a StreamAccessorStorage given the input typed element.static StreamAccessorStorage
fromTypedElement(org.eclipse.compare.ITypedElement element)
This is a short-hand forfromTypedElement(String, ITypedElement)
.Object
getAdapter(Class adapter)
InputStream
getContents()
org.eclipse.core.runtime.IPath
getFullPath()
String
getName()
boolean
isReadOnly()
-
-
-
Constructor Detail
-
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 Detail
-
fromTypedElement
public static StreamAccessorStorage fromTypedElement(org.eclipse.compare.ITypedElement element) throws IllegalArgumentException
This is a short-hand forfromTypedElement(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 implementIStreamContentAccessor
.
-
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- implementIStreamContentAccessor
as well.- Parameters:
storagePath
- The full path to this storage, can benull
.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 implementIStreamContentAccessor
.
-
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 interfaceIStoragePathAdapterProvider
- 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 interfaceorg.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 interfaceorg.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 interfaceorg.eclipse.core.resources.IStorage
- See Also:
IStorage.getFullPath()
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.eclipse.core.resources.IStorage
- See Also:
IStorage.getName()
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceorg.eclipse.core.resources.IStorage
- See Also:
IStorage.isReadOnly()
-
-