|
Eclipse Platform Release 3.4 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.team.core.mapping.DelegatingStorageMerger
This storage merger delegates to the appropriate merger or returns a conflict if no merger is available or if a merge was not possible.
The target storage is used to look for an appropriate merger. If the target
is an IFile
, the content type of the file is used. Otherwise, the
IContentTypeManager
is used to find an appropriate content type. If an
appropriate merger is not found, a status containing the
CONFLICT
is returned.
Clients may use this class directly or subclass it.
Field Summary |
Fields inherited from interface org.eclipse.team.core.mapping.IStorageMerger |
CONFLICT, INTERNAL_ERROR, OK, UNSUPPORTED_ENCODING |
Constructor Summary | |
DelegatingStorageMerger()
Default no-arg constructor. |
Method Summary | |
boolean |
canMergeWithoutAncestor()
Return whether this merger can merge the two contributors without an ancestor. |
protected IStorageMerger |
createDelegateMerger(IStorage target)
Create a merger for the given storage or return null
if an appropriate merger could not be created. |
static IStorageMerger |
createTextMerger()
Return the storage merger associated with the IContentTypeManager.CT_TEXT
content type. |
static IContentType |
getContentType(IStorage target)
A helper method that finds the content type for the given storage or returns null if a content
type cannot be found. |
static String |
getExtension(String name)
Helper method for returning the extension of a file name |
static IStorageMerger |
getInstance()
Helper method that returns a singleton instance that can be used to merge two IStorage instances. |
protected int |
getType(IStorage target)
Return the Team content type associated with the given target. |
IStatus |
merge(OutputStream output,
String outputEncoding,
IStorage ancestor,
IStorage target,
IStorage other,
IProgressMonitor monitor)
Performs a merge operation on the given storage instances and writes the merge result to the output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DelegatingStorageMerger()
Method Detail |
public static IStorageMerger createTextMerger()
IContentTypeManager.CT_TEXT
content type.
IContentTypeManager.CT_TEXT
content typepublic static IStorageMerger getInstance()
IStorage
instances.
public IStatus merge(OutputStream output, String outputEncoding, IStorage ancestor, IStorage target, IStorage other, IProgressMonitor monitor) throws CoreException
IStorageMerger
IStatus.OK
is returned, on error a status IStatus.ERROR
.
If the merge operation cannot deal with conflicts, the code of the error status has the value IStreamMerger.CONFLICT
.
For text oriented mergers the encoding for the input and output is honored if they implement
IEncodedStorage
.
It is the responsibility of callers to close the output stream.
The provided ancestor may be null
if this merger
returns true
from IStorageMerger.canMergeWithoutAncestor()
.
merge
in interface IStorageMerger
output
- the byte stream to which the merge result is written; the merger will not close the streamoutputEncoding
- the encoding to use when writing to the output streamancestor
- the storage from which the common ancestor is readtarget
- the storage containing the target of the mergeother
- the storage containing the target of the mergemonitor
- reports progress of the merge operation
CoreException
- if an error occursprotected IStorageMerger createDelegateMerger(IStorage target) throws CoreException
null
if an appropriate merger could not be created. This method is called
by merge(OutputStream, String, IStorage, IStorage, IStorage, IProgressMonitor)
to create the merger to which the merge should be delegated.
target
- the storage that contains the target contents of the merge.
null
CoreException
protected int getType(IStorage target)
target
- the storage that contains the target contents for the merge.
Team.getFileContentManager()
,
IFileContentManager.getType(IStorage)
public static String getExtension(String name)
name
- the file name
null
if the file name does not have an extensionpublic static IContentType getContentType(IStorage target) throws CoreException
null
if a content
type cannot be found. Any exceptions that occur when trying to determine
the content type are propagated.
target
- the storage that contains the target contents of the merge.
null
CoreException
- if an exception occurspublic boolean canMergeWithoutAncestor()
IStorageMerger
canMergeWithoutAncestor
in interface IStorageMerger
|
Eclipse Platform Release 3.4 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.