Eclipse Platform Release 3.7

## 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

    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
`ResourceNode(IResource resource)` Creates a `ResourceNode` for the given resource.

Method Summary
`protected IStructureComparator` `createChild(IResource child)` This hook method is called from `getChildren` once for every member of a container resource.
`protected InputStream` `createStream()` Returns an open stream if the corresponding resource implements the `IStorage` interface.
`boolean` `equals(Object other)` Returns whether some other object is "equal to" this one with respect to a structural comparison.
`String` `getCharset()` Returns the name of a charset encoding to be used when decoding this stream accessor's contents into characters.
`Object[]` `getChildren()` Returns an iterator for all children of this object or `null` if there are no children.
`InputStream` `getContents()` Returns an open `InputStream` for this object which can be used to retrieve the object's content.
`Image` `getImage()` Returns an image for this object.
`long` `getModificationDate()` Returns the modification time of this object.
`String` `getName()` Returns the name of this object.
`IResource` `getResource()` Returns the corresponding resource for this object.
`String` `getType()` Returns the type of this object.
`int` `hashCode()` Returns the hash code of the name.
`boolean` `isEditable()` Returns `true` if this object can be modified.
`boolean` `isReadOnly()` Return 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.
`ITypedElement` `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.
`IStatus` `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, setContent`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.eclipse.compare.IEditableContent
`setContent`

Constructor Detail

### ResourceNode

    public ResourceNode(IResource resource)

  Creates a `ResourceNode` for the given resource.

  Parameters:
    `resource` - the resource

Method Detail

### getResource

    public IResource getResource()

  Returns the corresponding resource for this object.

  Specified by:
    `getResource` in interface `IResourceProvider`
  Returns:
    the corresponding resource

### getContents

    public InputStream getContents()
                            throws CoreException

  Description copied from interface: `IStreamContentAccessor`
  Returns an open `InputStream` for this object which can be used to retrieve the object's content. The client is responsible for closing the stream when finished. Returns `null` if this object has no streamable contents.

  Specified by:
    `getContents` in interface `IStreamContentAccessor`
  Overrides:
    `getContents` in class `BufferedContent`
  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: `IModificationDate`
  Returns 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:
    `getModificationDate` in interface `IModificationDate`
  Returns:
    the time of last modification, in milliseconds since January 1, 1970, 00:00:00 GMT

### getName

    public String getName()

  Description copied from interface: `ITypedElement`
  Returns the name of this object. The name is used when displaying this object in the UI.

  Specified by:
    `getName` in interface `ITypedElement`
  Returns:
    the name of this object

### getType

    public String getType()

  Description copied from interface: `ITypedElement`
  Returns the type of this object. For objects with a file name this is typically the file extension. For folders its the constant `FOLDER_TYPE`. The type is used for determining a suitable viewer for this object.

  Specified by:
    `getType` in interface `ITypedElement`
  Returns:
    the type of this object

### getImage

    public Image getImage()

  Description copied from interface: `ITypedElement`
  Returns an image for this object. This image is used when displaying this object in the UI.

  Specified by:
    `getImage` in interface `ITypedElement`
  Returns:
    the image of this object or `null` if this type of input has no image

### equals

    public boolean equals(Object other)

  Description copied from interface: `IStructureComparator`
  Returns whether some other object is "equal to" this one with respect to a structural comparison. For example, when comparing Java class methods, `equals` would return `true` if two methods have the same signature (the argument names and the method body might differ).

  Specified by:
    `equals` in interface `IStructureComparator`
  Overrides:
    `equals` in class `Object`
  Parameters:
    `other` - the reference object with which to compare
  Returns:
    `true` if this object is the same as the other argument; `false` otherwise
  See Also:
    `Object.equals(java.lang.Object)`

### hashCode

    public int hashCode()

  Returns the hash code of the name.

  Overrides:
    `hashCode` in class `Object`
  Returns:
    a hash code value for this object.

### getChildren

    public Object[] getChildren()

  Description copied from interface: `IStructureComparator`
  Returns an iterator for all children of this object or `null` if there are no children.

  Specified by:
    `getChildren` in interface `IStructureComparator`
  Returns:
    an array with all children of this object, or an empty array if there are no children

### createChild

    protected IStructureComparator createChild(IResource child)

  This hook method is called from `getChildren` once for every member of a container resource. This implementation creates a new `ResourceNode` for the given child resource. Clients may override this method to create a different type of `IStructureComparator` or to filter children by returning `null`.

  Parameters:
    `child` - the child resource for which a `IStructureComparator` must be returned
  Returns:
    a `ResourceNode` for the given child or `null`

### createStream

    protected InputStream createStream()
                                throws CoreException

  Returns an open stream if the corresponding resource implements the `IStorage` interface. Otherwise the value `null` is returned.

  Specified by:
    `createStream` in class `BufferedContent`
  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: `IEditableContent`
  Returns `true` if this object can be modified. If it returns `false` the other methods of this API must not be called.

  Specified by:
    `isEditable` in interface `IEditableContent`
  Returns:
    `true` if this object can be modified

### replace

    public ITypedElement replace(ITypedElement child,
                                 ITypedElement other)

  Description copied from interface: `IEditableContent`
  This 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:
    `replace` in interface `IEditableContent`
  Parameters:
    `child` - the existing child of this object to be replaced; if `null` a new child can be added.
    `other` - the new child to be added or replaced; if `null` an existing child can be removed.
  Returns:
    the argument `dest`

### getCharset

    public String getCharset()

  Description copied from interface: `IEncodedStreamContentAccessor`
  Returns the name of a charset encoding to be used when decoding this stream accessor's contents into characters. Returns `null` if 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 `UnsupportedEncodingException` where this charset is used.

  Specified by:
    `getCharset` in interface `IEncodedStreamContentAccessor`
  Returns:
    the name of a charset, or `null`
  See Also:
    `IStreamContentAccessor.getContents()`

### isReadOnly

    public boolean isReadOnly()

  Description copied from interface: `IEditableContentExtension`
  Return 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:
    `isReadOnly` in interface `IEditableContentExtension`
  Returns:
    whether the typed element is read-only

### validateEdit

    public IStatus validateEdit(Shell shell)

  Description copied from interface: `IEditableContentExtension`
  If the element is read-only, this method should be called to attempt to make it writable.

  Specified by:
    `validateEdit` in interface `IEditableContentExtension`
  Parameters:
    `shell` - a shell used to prompt the user if required.
  Returns:
    a status object that is `OK` if things are fine, otherwise a status describing reasons why modifying the given files is not reasonable. A status with a severity of `CANCEL` is returned if the validation was canceled, indicating the edit should not proceed.

Eclipse Platform Release 3.7

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2011. All rights reserved.