## org.eclipse.emf.compare.diff.merge
Class DefaultMerger

    java.lang.Object
      org.eclipse.emf.compare.diff.merge.DefaultMerger

All Implemented Interfaces:
  IMerger

    public class DefaultMerger

extends java.lang.Object
implements IMerger

Basic implementation of an `IMerger`. Clients can extend this class instead of implementing IMerger to avoid reimplementing all methods.

Field Summary
`protected DiffElement` `diff` `DiffElement` to be merged by this merger.
`protected org.eclipse.emf.ecore.resource.Resource` `leftResource` Deprecated.
`protected org.eclipse.emf.ecore.resource.Resource` `rightResource` Deprecated.

Constructor Summary
`DefaultMerger()`

Method Summary
`void` `applyInOrigin()` Applies the modification in the original (left) model.
`boolean` `canApplyInOrigin()` Returns `True` if the merger is allowed to apply changes in the origin (left) model.
`boolean` `canUndoInTarget()` Returns `True` if the merger is allowed to undo changes in the target (right) model.
`protected void` `cleanDiffGroup(DiffGroup diffGroup)` Removes the given `DiffGroup` from its container if it was its last child, also calls for the same cleanup operation on its hierarchy.
`protected org.eclipse.emf.ecore.EObject` `copy(org.eclipse.emf.ecore.EObject eObject)` Creates a copy of the given EObject as would `EcoreUtil.copy(EObject)` would, except we use specific handling for unmatched references.
`protected DiffModel` `getDiffModel()` Returns the `DiffModel` containing the `DiffElement` this merger is intended to merge.
`protected java.lang.String` `getXMIID(org.eclipse.emf.ecore.EObject object)` Returns the XMI ID of the given `EObject` or `null` if it cannot be resolved.
`protected void` `removeDanglingReferences(org.eclipse.emf.ecore.EObject deletedObject)` Removes all references to the given `EObject` from the `DiffModel`.
`protected void` `removeFromContainer(DiffElement diffElement)` Removes a `DiffElement` from its `DiffGroup`.
`void` `setDiffElement(DiffElement element)` Sets the `DiffElement` to be merged.
`protected void` `setXMIID(org.eclipse.emf.ecore.EObject object, java.lang.String id)` Sets the XMI ID of the given `EObject` if it belongs in an `XMIResource`.
`void` `undoInTarget()` Cancels the modification in the target (right) model.

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

Field Detail

### diff

    protected DiffElement diff

  `DiffElement` to be merged by this merger.

### leftResource

    @Deprecated
    protected org.eclipse.emf.ecore.resource.Resource leftResource

  Deprecated.
  Keeps a reference on the left resource for this merger.

### rightResource

    @Deprecated
    protected org.eclipse.emf.ecore.resource.Resource rightResource

  Deprecated.
  Keeps a reference on the right resource for this merger.

Constructor Detail

### DefaultMerger

    public DefaultMerger()

Method Detail

### applyInOrigin

    public void applyInOrigin()

  Applies the modification in the original (left) model.

  Specified by:
    `applyInOrigin` in interface `IMerger`
  See Also:
    `IMerger.applyInOrigin()`

### canApplyInOrigin

    public boolean canApplyInOrigin()

  Returns `True` if the merger is allowed to apply changes in the origin (left) model.

  Specified by:
    `canApplyInOrigin` in interface `IMerger`
  Returns:
    `True` if the merger is allowed to apply changes in the origin (left) model, `False` otherwise.
  See Also:
    `IMerger.canApplyInOrigin()`

### canUndoInTarget

    public boolean canUndoInTarget()

  Returns `True` if the merger is allowed to undo changes in the target (right) model.

  Specified by:
    `canUndoInTarget` in interface `IMerger`
  Returns:
    `True` if the merger is allowed to undo changes in the target (right) model, `False` otherwise.
  See Also:
    `IMerger.canUndoInTarget()`

### setDiffElement

    public void setDiffElement(DiffElement element)

  Sets the `DiffElement` to be merged.

  Specified by:
    `setDiffElement` in interface `IMerger`
  Parameters:
    `element` - The `DiffElement` to be merged.
  See Also:
    `IMerger.setDiffElement(org.eclipse.emf.compare.diff.metamodel.DiffElement)`

### undoInTarget

    public void undoInTarget()

  Cancels the modification in the target (right) model.

  Specified by:
    `undoInTarget` in interface `IMerger`
  See Also:
    `IMerger.undoInTarget()`

### cleanDiffGroup

    protected void cleanDiffGroup(DiffGroup diffGroup)

  Removes the given `DiffGroup` from its container if it was its last child, also calls for the same cleanup operation on its hierarchy.

  Parameters:
    `diffGroup` - `DiffGroup` we want to cleanup.

### copy

    protected org.eclipse.emf.ecore.EObject copy(org.eclipse.emf.ecore.EObject eObject)

  Creates a copy of the given EObject as would `EcoreUtil.copy(EObject)` would, except we use specific handling for unmatched references.

  Parameters:
    `eObject` - The object to copy.
  Returns:
    the copied object.

### getDiffModel

    protected DiffModel getDiffModel()

  Returns the `DiffModel` containing the `DiffElement` this merger is intended to merge.

  Returns:
    The `DiffModel` containing the `DiffElement` this merger is intended to merge.

### getXMIID

    protected java.lang.String getXMIID(org.eclipse.emf.ecore.EObject object)

  Returns the XMI ID of the given `EObject` or `null` if it cannot be resolved.

  Parameters:
    `object` - Object which we seek the XMI ID of.
  Returns:
    `object`'s XMI ID, `null` if not applicable.

### removeDanglingReferences

    protected void removeDanglingReferences(org.eclipse.emf.ecore.EObject deletedObject)

  Removes all references to the given `EObject` from the `DiffModel`.

  Parameters:
    `deletedObject` - Object to remove all references to.

### removeFromContainer

    protected void removeFromContainer(DiffElement diffElement)

  Removes a `DiffElement` from its `DiffGroup`.

  Parameters:
    `diffElement` - `DiffElement` to remove from its container.

### setXMIID

    protected void setXMIID(org.eclipse.emf.ecore.EObject object,
                            java.lang.String id)

  Sets the XMI ID of the given `EObject` if it belongs in an `XMIResource`.

  Parameters:
    `object` - Object we want to set the XMI ID of.
    `id` - XMI ID to give to `object`.

Copyright 2006 IBM Corporation and others. All Rights Reserved.