Package org.eclipse.compare.structuremergeviewer

# Class SharedDocumentAdapterWrapper

java.lang.Object
org.eclipse.compare.structuremergeviewer.SharedDocumentAdapterWrapper

All Implemented Interfaces:
  `ISharedDocumentAdapter`

public class SharedDocumentAdapterWrapper extends Object implements ISharedDocumentAdapter
An implementation of `ISharedDocumentAdapter` that wraps another shared document adapter.

Clients may subclass this class.

Since:
  3.3

## Constructor Summary

Constructors
Constructor
Description
`SharedDocumentAdapterWrapper(ISharedDocumentAdapter wrappedAdapter)`
Creates a shared document adapter that wraps the given adapter.

## Method Summary

Modifier and Type
Method
Description
`void`
`connect(IDocumentProvider provider, IEditorInput documentKey)`
Connect the given element to its document provider.
`void`
`disconnect(Object element)`
A helper disconnect method that looks up the appropriate key (using `ISharedDocumentAdapter.getDocumentKey(Object)` and the appropriate provider and calls `ISharedDocumentAdapter.disconnect(IDocumentProvider, IEditorInput)`.
`void`
`disconnect(IDocumentProvider provider, IEditorInput documentKey)`
Disconnect the element from the document provider.
`void`
`flushDocument(IDocumentProvider provider, IEditorInput documentKey, IDocument document, boolean overwrite)`
Flush the contents of the given document into the typed element that provided the document.
`static ISharedDocumentAdapter`
`getAdapter(Object element)`
Helper method that returns the shared document adapter for the given typed element or `null` if there isn't one.
`IEditorInput`
`getDocumentKey(Object element)`
Return the object that is to be used as the key for retrieving the appropriate `IDocumentProvider` from the `DocumentProviderRegistry` and for obtaining the shared `IDocument` from the document provider.
`final ISharedDocumentAdapter`
`getWrappedAdapter()`
Returns the wrapped adapter.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SharedDocumentAdapterWrapper

public SharedDocumentAdapterWrapper(ISharedDocumentAdapter wrappedAdapter)
Creates a shared document adapter that wraps the given adapter.

Parameters:
  `wrappedAdapter` - the wrapped adapter

## Method Details

### getAdapter

public static ISharedDocumentAdapter getAdapter(Object element)
Helper method that returns the shared document adapter for the given typed element or `null` if there isn't one.

Parameters:
  `element` - the typed element
Returns:
  the shared document adapter for the given typed element or `null`

### connect

public void connect(IDocumentProvider provider, IEditorInput documentKey) throws CoreException
Description copied from interface: `ISharedDocumentAdapter`
Connect the given element to its document provider. All connections must be performed through this adapter so that the adapter can track whether it is connected or not.

Specified by:
  `connect` in interface `ISharedDocumentAdapter`
Parameters:
  `provider` - the document provider
  `documentKey` - the element's key returned from `ISharedDocumentAdapter.getDocumentKey(Object)`
Throws:
  `CoreException` - if connection was not possible
See Also:
  - `IDocumentProvider.connect(Object)`

### disconnect

public void disconnect(IDocumentProvider provider, IEditorInput documentKey)
Description copied from interface: `ISharedDocumentAdapter`
Disconnect the element from the document provider. All connects and disconnects must occur through the adapter so that the adapter can track whether it is connected or not.

Specified by:
  `disconnect` in interface `ISharedDocumentAdapter`
Parameters:
  `provider` - the document provider
  `documentKey` - the element's key returned from `ISharedDocumentAdapter.getDocumentKey(Object)`
See Also:
  - `IDocumentProvider.disconnect(Object)`

### getDocumentKey

public IEditorInput getDocumentKey(Object element)
Description copied from interface: `ISharedDocumentAdapter`
Return the object that is to be used as the key for retrieving the appropriate `IDocumentProvider` from the `DocumentProviderRegistry` and for obtaining the shared `IDocument` from the document provider. Returns `null` if the element does not have a shared document.

Specified by:
  `getDocumentKey` in interface `ISharedDocumentAdapter`
Parameters:
  `element` - the element being queried for a shared document
Returns:
  the object that acts as the key to obtain a document provider and document or `null`

### flushDocument

public void flushDocument(IDocumentProvider provider, IEditorInput documentKey, IDocument document, boolean overwrite) throws CoreException
Description copied from interface: `ISharedDocumentAdapter`
Flush the contents of the given document into the typed element that provided the document. This method is invoked by the Compare framework classes when a request to flush the viewers has been made. It is up to the implementor to decide whether the changes in the buffer should be saved to disk at the time of the flush or buffered to be saved at a later time.

Specified by:
  `flushDocument` in interface `ISharedDocumentAdapter`
Parameters:
  `provider` - the document provider
  `documentKey` - the element's key returned from `ISharedDocumentAdapter.getDocumentKey(Object)`
  `document` - the document
  `overwrite` - indicates whether overwrite should be performed while saving the given element if necessary
Throws:
  `CoreException` - if document could not be stored to the given element
See Also:
  - `IDocumentProvider.saveDocument(IProgressMonitor, Object, IDocument, boolean)`

### getWrappedAdapter

public final ISharedDocumentAdapter getWrappedAdapter()
Returns the wrapped adapter.

Returns:
  the wrapped adapter

### disconnect

public void disconnect(Object element)
Description copied from interface: `ISharedDocumentAdapter`
A helper disconnect method that looks up the appropriate key (using `ISharedDocumentAdapter.getDocumentKey(Object)` and the appropriate provider and calls `ISharedDocumentAdapter.disconnect(IDocumentProvider, IEditorInput)`.

Specified by:
  `disconnect` in interface `ISharedDocumentAdapter`
Parameters:
  `element` - the element that was used to previously connect to a document
See Also:
  - `IDocumentProvider.disconnect(Object)`