Eclipse Platform
Release 3.1

org.eclipse.text.edits
Class TextEditProcessor

java.lang.Object
  extended byorg.eclipse.text.edits.TextEditProcessor

public class TextEditProcessor
extends Object

A TextEditProcessor manages a set of edits and applies them as a whole to an IDocument.

This class isn't intended to be subclassed.

Since:
3.0
See Also:
TextEdit.apply(IDocument)

Constructor Summary
TextEditProcessor(IDocument document, TextEdit root, int style)
          Constructs a new edit processor for the given document.
 
Method Summary
 boolean canPerformEdits()
          Checks if the processor can execute all its edits.
protected  boolean considerEdit(TextEdit edit)
           
 IDocument getDocument()
          Returns the document to be manipulated.
 TextEdit getRoot()
          Returns the edit processor's root edit.
 int getStyle()
          Returns the style bits of the text edit processor
 UndoEdit performEdits()
          Executes the text edits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextEditProcessor

public TextEditProcessor(IDocument document,
                         TextEdit root,
                         int style)
Constructs a new edit processor for the given document.

Parameters:
document - the document to manipulate
root - the root of the text edit tree describing the modifications. By passing a text edit a a text edit processor the ownership of the edit is transfered to the text edit processors. Clients must not modify the edit (e.g adding new children) any longer.
style - TextEdit.NONE, TextEdit.CREATE_UNDO or TextEdit.UPDATE_REGIONS)
Method Detail

getDocument

public IDocument getDocument()
Returns the document to be manipulated.

Returns:
the document

getRoot

public TextEdit getRoot()
Returns the edit processor's root edit.

Returns:
the processor's root edit

getStyle

public int getStyle()
Returns the style bits of the text edit processor

Returns:
the style bits
See Also:
TextEdit.CREATE_UNDO, TextEdit.UPDATE_REGIONS

canPerformEdits

public boolean canPerformEdits()
Checks if the processor can execute all its edits.

Returns:
true if the edits can be executed. Return false otherwise. One major reason why edits cannot be executed are wrong offset or length values of edits. Calling perform in this case will very likely end in a BadLocationException.

performEdits

public UndoEdit performEdits()
                      throws MalformedTreeException,
                             BadLocationException
Executes the text edits.

Returns:
an object representing the undo of the executed edits
Throws:
MalformedTreeException - is thrown if the edit tree isn't in a valid state. This exception is thrown before any edit is executed. So the document is still in its original state.
BadLocationException - is thrown if one of the edits in the tree can't be executed. The state of the document is undefined if this exception is thrown.

considerEdit

protected boolean considerEdit(TextEdit edit)

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.