Package org.eclipse.compare
Class ResourceNode
java.lang.Object
org.eclipse.compare.BufferedContent
org.eclipse.compare.ResourceNode
- All Implemented Interfaces:
IContentChangeNotifier,IEditableContent,IEditableContentExtension,IEncodedStreamContentAccessor,IModificationDate,IResourceProvider,IStreamContentAccessor,ITypedElement,IStructureComparator
- Direct Known Subclasses:
BufferedResourceNode
public class ResourceNode
extends BufferedContent
implements IEncodedStreamContentAccessor, IStructureComparator, ITypedElement, IEditableContent, IModificationDate, IResourceProvider, IEditableContentExtension
A
ResourceNode wraps an IResources so that it can be used
as input for the differencing engine (interfaces IStructureComparator and ITypedElement)
and the ReplaceWithEditionDialog (interfaces ITypedElement and IModificationDate).
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
ConstructorsConstructorDescriptionResourceNode(IResource resource) Creates aResourceNodefor the given resource. -
Method Summary
Modifier and TypeMethodDescriptionprotected IStructureComparatorcreateChild(IResource child) This hook method is called fromgetChildrenonce for every member of a container resource.protected InputStreamReturns an open stream if the corresponding resource implements theIStorageinterface.booleanReturns whether some other object is "equal to" this one with respect to a structural comparison.Returns the name of a charset encoding to be used when decoding this stream accessor's contents into characters.Object[]Returns an iterator for all children of this object ornullif there are no children.Returns an openInputStreamfor this object which can be used to retrieve the object's content.getImage()Returns an image for this object.longReturns the modification time of this object.getName()Returns the name of this object.Returns the corresponding resource for this object.getType()Returns the type of this object.inthashCode()Returns the hash code of the name.booleanReturnstrueif this object can be modified.booleanReturn whether the typed element being displayed is read-only. a read-only element will require a call to validateEdit before the element can be modified on disk.replace(ITypedElement child, ITypedElement other) This method is called on a parent to add or remove a child, or to copy the contents of a child.validateEdit(Shell shell) If the element is read-only, this method should be called to attempt to make it writable.Methods inherited from class org.eclipse.compare.BufferedContent
addContentChangeListener, discardBuffer, fireContentChanged, getContent, removeContentChangeListener, setContentMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.compare.IEditableContent
setContent
-
Constructor Details
-
ResourceNode
Creates aResourceNodefor the given resource.- Parameters:
resource- the resource
-
-
Method Details
-
getResource
Returns the corresponding resource for this object.- Specified by:
getResourcein interfaceIResourceProvider- Returns:
- the corresponding resource
-
getContents
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- Overrides:
getContentsin classBufferedContent- Returns:
- an input stream containing the contents of this object
- Throws:
CoreException- if the contents of this object could not be accessed
-
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
-
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
-
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
-
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
-
equals
Description copied from interface:IStructureComparatorReturns whether some other object is "equal to" this one with respect to a structural comparison. For example, when comparing Java class methods,equalswould returntrueif two methods have the same signature (the argument names and the method body might differ).- Specified by:
equalsin interfaceIStructureComparator- Overrides:
equalsin classObject- Parameters:
other- the reference object with which to compare- Returns:
trueif this object is the same as the other argument;falseotherwise- See Also:
-
hashCode
public int hashCode()Returns the hash code of the name. -
getChildren
Description copied from interface:IStructureComparatorReturns an iterator for all children of this object ornullif there are no children.- Specified by:
getChildrenin interfaceIStructureComparator- Returns:
- an array with all children of this object, or an empty array if there are no children
-
createChild
This hook method is called fromgetChildrenonce for every member of a container resource. This implementation creates a newResourceNodefor the given child resource. Clients may override this method to create a different type ofIStructureComparatoror to filter children by returningnull.- Parameters:
child- the child resource for which aIStructureComparatormust be returned- Returns:
- a
ResourceNodefor the given child ornull
-
createStream
Returns an open stream if the corresponding resource implements theIStorageinterface. Otherwise the valuenullis returned.- Specified by:
createStreamin classBufferedContent- Returns:
- a buffered input stream containing the contents of this storage
- Throws:
CoreException- if the contents of this storage could not be accessed
-
isEditable
public boolean isEditable()Description copied from interface:IEditableContentReturnstrueif this object can be modified. If it returnsfalsethe other methods of this API must not be called.- Specified by:
isEditablein interfaceIEditableContent- Returns:
trueif this object can be modified
-
replace
Description copied from interface:IEditableContentThis method is called on a parent to add or remove a child, or to copy the contents of a child. What to do is encoded in the two arguments as follows:add: dest == null src != null remove: dest != null src == null copy: dest != null src != null - Specified by:
replacein interfaceIEditableContent- Parameters:
child- the existing child of this object to be replaced; ifnulla new child can be added.other- the new child to be added or replaced; ifnullan existing child can be removed.- Returns:
- the argument
dest
-
getCharset
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 - See Also:
-
isReadOnly
public boolean isReadOnly()Description copied from interface:IEditableContentExtensionReturn whether the typed element being displayed is read-only. a read-only element will require a call to validateEdit before the element can be modified on disk.- Specified by:
isReadOnlyin interfaceIEditableContentExtension- Returns:
- whether the typed element is read-only
-
validateEdit
Description copied from interface:IEditableContentExtensionIf the element is read-only, this method should be called to attempt to make it writable.- Specified by:
validateEditin interfaceIEditableContentExtension- Parameters:
shell- a shell used to prompt the user if required.- Returns:
- a status object that is
OKif things are fine, otherwise a status describing reasons why modifying the given files is not reasonable. A status with a severity ofCANCELis returned if the validation was canceled, indicating the edit should not proceed.
-