Class StreamSource
java.lang.Object
org.netbeans.api.diff.StreamSource
This class provides streams and information about them to be used by diff
and merge services.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the stream source.abstract Reader
Create a reader, that reads the source.static StreamSource
createSource
(String name, String title, String MIMEType, File file) Create the default implementation ofStreamSource
, that has just reader and writer from/to a file.static StreamSource
createSource
(String name, String title, String MIMEType, Reader r) Create the default implementation ofStreamSource
, that has just reader and no writer.abstract Writer
createWriter
(Difference[] conflicts) Create a writer, that writes to the source.org.openide.util.Lookup
Source lookup that may define the content of this source.abstract String
Get the MIME type of the source.abstract String
getName()
Get the name of the source.abstract String
getTitle()
Get the title of the source.boolean
Hint for a diff visualizer about editability of this source.
-
Constructor Details
-
StreamSource
public StreamSource()
-
-
Method Details
-
getName
Get the name of the source. -
getTitle
Get the title of the source. -
getMIMEType
Get the MIME type of the source. -
isEditable
public boolean isEditable()Hint for a diff visualizer about editability of this source. The source will only be made editable if it provides some editable entity in its lookup (eg. FileObject) and this method returns true and the diff visualizer supports it.- Returns:
- true if this source can be editable in the diff visualizer, false otherwise
- Since:
- 1.17
-
getLookup
public org.openide.util.Lookup getLookup()Source lookup that may define the content of this source. In case the lookup does not provide anything usable, createReader() is used instead. Diff engines can process these inputs:- instance of
FileObject
- in this case, the content of the source is defined by calling DataObject.find(fileObject).openDocument(). If the source is editable then it is saved back via SaveCookie.save() when the Diff component closes. - instance of
Document
- in this case, the content of the source is defined by this Document and the source will NOT be editable.
- Returns:
- an instance of Lookup
- Since:
- 1.17
- instance of
-
createReader
Create a reader, that reads the source.- Throws:
IOException
-
createWriter
Create a writer, that writes to the source.- Parameters:
conflicts
- The list of conflicts remaining in the source. Can benull
if there are no conflicts.- Returns:
- The writer or
null
, when no writer can be created. - Throws:
IOException
-
close
public void close()Close the stream source. This method, is called when this object will never be asked for the streams any more and thus can release it's resources in this method. -
createSource
Create the default implementation ofStreamSource
, that has just reader and no writer. -
createSource
Create the default implementation ofStreamSource
, that has just reader and writer from/to a file.
-