## Merging multiple streams

The search plug-in allows you to customize views that assist the user in merging different content streams. In some cases, however, the ability to merge streams without the assist of a user is desirable. The extension point org.eclipse.compare.streamMergers allows you to contribute a class that merges three different input streams into a single output stream. Stream mergers can be associated with file extensions or bound to a particular content type. The search plug-in defines a stream merger for merging three streams of plain text:

    <extension
    	point="org.eclipse.compare.streamMergers">
    	<streamMerger
    		extensions="txt"
    		class="org.eclipse.compare.internal.merge.TextStreamMerger"
    		id="org.eclipse.compare.internal.merge.TextStreamMerger">
    	</streamMerger>
    	<contentTypeBinding
    		contentTypeId="org.eclipse.core.runtime.text"
    		streamMergerId="org.eclipse.compare.internal.merge.TextStreamMerger">
    	</contentTypeBinding>
    </extension>

The stream merger itself is described in the streamMerger element. You must specify the id of the merger and the class that implements it. You may also specify any file extensions for which the the stream merger should be used.

You may also use the contentTypeBinding element to associate a content type with a stream merger.

Stream mergers must implement IStreamMerger. This simple interface merges the contents from three different input streams into a single output stream. The not-so-simple implementation depends upon your plug-in and its content types.

New IStreamMergers can be created for registered types with the createStreamMerger methods of CompareUI.