Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.compare
Class ResourceNode  view ResourceNode download ResourceNode.java

java.lang.Object
  extended byorg.eclipse.compare.BufferedContent
      extended byorg.eclipse.compare.ResourceNode
All Implemented Interfaces:
IContentChangeNotifier, IEditableContent, IEncodedStreamContentAccessor, IModificationDate, IStreamContentAccessor, org.eclipse.compare.structuremergeviewer.IStructureComparator, ITypedElement

public class ResourceNode
extends BufferedContent
implements IEncodedStreamContentAccessor, org.eclipse.compare.structuremergeviewer.IStructureComparator, ITypedElement, IEditableContent, IModificationDate

A ResourceNode wrappers 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.


Field Summary
private  java.util.ArrayList fChildren
           
private  org.eclipse.core.resources.IResource fResource
           
 
Fields inherited from class org.eclipse.compare.BufferedContent
fContent
 
Fields inherited from interface org.eclipse.compare.ITypedElement
FOLDER_TYPE, TEXT_TYPE, UNKNOWN_TYPE
 
Constructor Summary
ResourceNode(org.eclipse.core.resources.IResource resource)
          Creates a ResourceNode for the given resource.
 
Method Summary
protected  org.eclipse.compare.structuremergeviewer.IStructureComparator createChild(org.eclipse.core.resources.IResource child)
          This hook method is called from getChildren once for every member of a container resource.
protected  java.io.InputStream createStream()
          Returns an open stream if the corresponding resource implements the IStorage interface.
 boolean equals(java.lang.Object other)
          Returns true if the other object is of type ITypedElement and their names are identical.
 java.lang.String getCharset()
          Returns the name of a charset encoding to be used when decoding this stream accessor's contents into characters.
 java.lang.Object[] getChildren()
          Returns an iterator for all children of this object or null if there are no children.
 java.io.InputStream getContents()
          Returns an open InputStream for this object which can be used to retrieve the object's content.
 org.eclipse.swt.graphics.Image getImage()
          Returns an image for this object.
 long getModificationDate()
          Returns the modification time of this object.
 java.lang.String getName()
          Returns the name of this object.
 org.eclipse.core.resources.IResource getResource()
          Returns the corresponding resource for this object.
 java.lang.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.
 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.
 
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
 

Field Detail

fResource

private org.eclipse.core.resources.IResource fResource

fChildren

private java.util.ArrayList fChildren
Constructor Detail

ResourceNode

public ResourceNode(org.eclipse.core.resources.IResource resource)
Creates a ResourceNode for the given resource.

Method Detail

getResource

public org.eclipse.core.resources.IResource getResource()
Returns the corresponding resource for this object.


getContents

public java.io.InputStream getContents()
                                throws org.eclipse.core.runtime.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

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

getName

public java.lang.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

getType

public java.lang.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

getImage

public org.eclipse.swt.graphics.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

equals

public boolean equals(java.lang.Object other)
Returns true if the other object is of type ITypedElement and their names are identical. The content is not considered.

Specified by:
equals in interface org.eclipse.compare.structuremergeviewer.IStructureComparator

hashCode

public int hashCode()
Returns the hash code of the name.


getChildren

public java.lang.Object[] getChildren()
Description copied from interface: org.eclipse.compare.structuremergeviewer.IStructureComparator
Returns an iterator for all children of this object or null if there are no children.

Specified by:
getChildren in interface org.eclipse.compare.structuremergeviewer.IStructureComparator

createChild

protected org.eclipse.compare.structuremergeviewer.IStructureComparator createChild(org.eclipse.core.resources.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.


createStream

protected java.io.InputStream createStream()
                                    throws org.eclipse.core.runtime.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

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

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: child == null other != null
remove: child != null other == null
copy: child != null other != null

Specified by:
replace in interface IEditableContent

getCharset

public java.lang.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