org.eclipse.core.filebuffers.manipulation

## Class TextFileBufferOperation

- java.lang.Object
- - org.eclipse.core.filebuffers.manipulation.TextFileBufferOperation

All Implemented Interfaces:
  IFileBufferOperation

Direct Known Subclasses:
  ConvertLineDelimitersOperation, RemoveTrailingWhitespaceOperation

    public abstract class TextFileBufferOperation
    extends Object
    implements IFileBufferOperation

Abstraction for a file buffer operation that works on text file buffers. Subclasses have to override the `computeTextEdits` method in order to provide a sequence of `TextEdit` objects.

Since:
  3.1

### Constructor Summary

Constructors
`protected` `TextFileBufferOperation(String operationName)` Creates a new operation with the given name.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected abstract MultiTextEditWithProgress` `computeTextEdit(ITextFileBuffer textFileBuffer, IProgressMonitor progressMonitor)` Computes and returns a text edit.
`protected abstract DocumentRewriteSessionType` `getDocumentRewriteSessionType()` Returns the rewrite session type that corresponds to the text edit sequence.
`String` `getOperationName()` Returns the name of this file buffer operation.
`void` `run(IFileBuffer fileBuffer, IProgressMonitor progressMonitor)` Runs this operation, that is manipulates the content of the given file buffer.

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

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

### Constructor Detail

#### TextFileBufferOperation

    protected TextFileBufferOperation(String operationName)

Creates a new operation with the given name.

Parameters:
  `operationName` - the name of the operation

### Method Detail

#### computeTextEdit

    protected abstract MultiTextEditWithProgress computeTextEdit(ITextFileBuffer textFileBuffer,
                                                                 IProgressMonitor progressMonitor)
                                                          throws CoreException,
                                                                 OperationCanceledException

Computes and returns a text edit. Subclasses have to provide that method.

Parameters:
  `textFileBuffer` - the text file buffer to manipulate
  `progressMonitor` - the progress monitor
Returns:
  the text edits describing the content manipulation
Throws:
  `CoreException` - in case the computation failed
  `OperationCanceledException` - in case the progress monitor has been set to canceled

#### getDocumentRewriteSessionType

    protected abstract DocumentRewriteSessionType getDocumentRewriteSessionType()

Returns the rewrite session type that corresponds to the text edit sequence.

Returns:
  the rewrite session type

#### getOperationName

    public String getOperationName()

Description copied from interface: `IFileBufferOperation`
Returns the name of this file buffer operation. The operation name is used by the `FileBufferOperationRunner` while reporting progress.

Specified by:
  `getOperationName` in interface `IFileBufferOperation`
Returns:
  the operation name or `null`

#### run

    public void run(IFileBuffer fileBuffer,
                    IProgressMonitor progressMonitor)
             throws CoreException,
                    OperationCanceledException

Description copied from interface: `IFileBufferOperation`
Runs this operation, that is manipulates the content of the given file buffer.

Specified by:
  `run` in interface `IFileBufferOperation`
Parameters:
  `fileBuffer` - the file buffer
  `progressMonitor` - the progress monitor
Throws:
  `CoreException` - in case the content manipulation failed
  `OperationCanceledException` - in case the monitor has been set to canceled