Package org.eclipse.compare
Class HistoryItem
- java.lang.Object
-
- org.eclipse.compare.HistoryItem
-
- All Implemented Interfaces:
IEncodedStreamContentAccessor,IModificationDate,IResourceProvider,IStreamContentAccessor,ITypedElement
public class HistoryItem extends Object implements IEncodedStreamContentAccessor, ITypedElement, IModificationDate, IResourceProvider
A combinationIFileStateandITypedElementthat can be used as an input to a compare viewer or other places where anIStreamContentAccessoris needed.Clients may instantiate this class; it is not intended to be subclassed.
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Field Summary
-
Fields inherited from interface org.eclipse.compare.ITypedElement
FOLDER_TYPE, TEXT_TYPE, UNKNOWN_TYPE
-
-
Constructor Summary
Constructors Constructor Description HistoryItem(ITypedElement base, IFileState fileState)Creates aHistoryItemobject which combines the givenIFileStateandITypedElementinto an object which is suitable as input for a compare viewer orReplaceWithEditionDialog.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCharset()Returns the name of a charset encoding to be used when decoding this stream accessor's contents into characters.InputStreamgetContents()Returns an openInputStreamfor this object which can be used to retrieve the object's content.ImagegetImage()Returns an image for this object.longgetModificationDate()Returns the modification time of this object.StringgetName()Returns the name of this object.IResourcegetResource()Returns the corresponding resource for this object ornull.StringgetType()Returns the type of this object.
-
-
-
Constructor Detail
-
HistoryItem
public HistoryItem(ITypedElement base, IFileState fileState)
Creates aHistoryItemobject which combines the givenIFileStateandITypedElementinto an object which is suitable as input for a compare viewer orReplaceWithEditionDialog.- Parameters:
base- the implementation of theITypedElementinterface delegates to this baseITypedElementfileState- theIFileStatefrom which the streamable contents and the modification time is derived from
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:ITypedElementReturns the name of this object. The name is used when displaying this object in the UI.- Specified by:
getNamein interfaceITypedElement- Returns:
- the name of this object
-
getImage
public Image getImage()
Description copied from interface:ITypedElementReturns an image for this object. This image is used when displaying this object in the UI.- Specified by:
getImagein interfaceITypedElement- Returns:
- the image of this object or
nullif this type of input has no image
-
getType
public String getType()
Description copied from interface:ITypedElementReturns the type of this object. For objects with a file name this is typically the file extension. For folders its the constantFOLDER_TYPE. The type is used for determining a suitable viewer for this object.- Specified by:
getTypein interfaceITypedElement- Returns:
- the type of this object
-
getModificationDate
public long getModificationDate()
Description copied from interface:IModificationDateReturns the modification time of this object.Note that this value should only be used to give the user a general idea of how old the object is.
- Specified by:
getModificationDatein interfaceIModificationDate- Returns:
- the time of last modification, in milliseconds since January 1, 1970, 00:00:00 GMT
-
getContents
public InputStream getContents() throws CoreException
Description copied from interface:IStreamContentAccessorReturns an openInputStreamfor this object which can be used to retrieve the object's content. The client is responsible for closing the stream when finished. Returnsnullif this object has no streamable contents.- Specified by:
getContentsin interfaceIStreamContentAccessor- Returns:
- an input stream containing the contents of this object
- Throws:
CoreException- if the contents of this object could not be accessed
-
getCharset
public String getCharset() throws CoreException
Description copied from interface:IEncodedStreamContentAccessorReturns the name of a charset encoding to be used when decoding this stream accessor's contents into characters. Returnsnullif a proper encoding cannot be determined.Note: this method does not check whether the result is a supported charset name. Callers should be prepared to handle
UnsupportedEncodingExceptionwhere this charset is used.- Specified by:
getCharsetin interfaceIEncodedStreamContentAccessor- Returns:
- the name of a charset, or
null - Throws:
CoreException- if an error happens while determining the charset. See any refinements for more information.- See Also:
IStreamContentAccessor.getContents()
-
getResource
public IResource getResource()
Description copied from interface:IResourceProviderReturns the corresponding resource for this object ornull.- Specified by:
getResourcein interfaceIResourceProvider- Returns:
- the corresponding resource or
null
-
-