Eclipse Platform
2.0

org.eclipse.jface.text
Class AbstractDocument

java.lang.Object
  |
  +--org.eclipse.jface.text.AbstractDocument
All Implemented Interfaces:
IDocument, IDocumentExtension
Direct Known Subclasses:
ChildDocument, Document

public abstract class AbstractDocument
extends Object
implements IDocument, IDocumentExtension

Abstract implementation of IDocument. Implements the complete contract of IDocument and IDocumentExtension. An AbstractDocument supports the following implementation plug-ins:

This class must be subclassed. Subclasses must configure which implementation plug-ins the document should use. Subclasses are not intended to overwrite existing methods.

See Also:
IDocument, ITextStore, ILineTracker

Nested Class Summary
 
Nested classes inherited from class org.eclipse.jface.text.IDocumentExtension
IDocumentExtension.IReplace
 
Field Summary
 
Fields inherited from interface org.eclipse.jface.text.IDocument
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE
 
Constructor Summary
protected AbstractDocument()
          The default constructor does not perform any configuration but leaves it to the clients who must first initialize the implementation plug-ins and then call completeInitialization.
 
Method Summary
 void addDocumentListener(IDocumentListener listener)
          Registers the document listener with the document.
 void addDocumentPartitioningListener(IDocumentPartitioningListener listener)
          Registers the document partitioning listener with the document.
 void addPosition(Position position)
          Adds the position to the document's default position category.
 void addPosition(String category, Position position)
          Adds the position to the specified position category of the document.
 void addPositionCategory(String category)
          Adds a new position category to the document.
 void addPositionUpdater(IPositionUpdater updater)
          Appends a new position updater to the document's list of position updaters.
 void addPrenotifiedDocumentListener(IDocumentListener listener)
          Adds the given document listener as one which is notified before those document listeners added with addDocumentListener are notified.
protected  void completeInitialization()
          Initializes document listeners, positions, and position updaters.
 int computeIndexInCategory(String category, int offset)
          Computes the index at which a Position with the specified offset would be inserted into the given category.
protected  int computeIndexInPositionList(List positions, int offset)
          Computes the index in the list of positions at which a position with the given offset would be inserted.
 int computeNumberOfLines(String text)
          Computes the number of lines in the given text.
 ITypedRegion[] computePartitioning(int offset, int length)
          Computes the partitioning of the given document range using the document's partitioner.
 boolean containsPosition(String category, int offset, int length)
          Determines whether a position described by the parameters is managed by this document.
 boolean containsPositionCategory(String category)
          Checks the presence of the specified position category.
protected  void fireDocumentAboutToBeChanged(DocumentEvent event)
          Fires the given document event to all registers document listeners informing them about the forthcoming document manipulation.
protected  void fireDocumentChanged(DocumentEvent event)
          Updates the internal document structures and informs all document listeners.
protected  void fireDocumentPartitioningChanged()
          Deprecated. use fireDocumentPartitioningChanged(IRegion) instead
protected  void fireDocumentPartitioningChanged(IRegion region)
          Fires the document partitioning changed notification to all registered document partitioning listeners.
 String get()
          Returns this document's complete text.
 String get(int pos, int length)
          Returns this document's text for the specified range.
 char getChar(int pos)
          Returns the character at the given document offset in this document.
 String getContentType(int offset)
          Returns the type of the document partition containing the given offset.
protected  List getDocumentListeners()
          Returns the document's document listeners.
protected  Map getDocumentManagedPositions()
          Returns all positions managed by the document grouped by category.
 IDocumentPartitioner getDocumentPartitioner()
          Returns this document's partitioner.
protected  List getDocumentPartitioningListeners()
          Returns the document's partitioning listeners .
 String[] getLegalContentTypes()
          Returns the set of legal content types of document partitions.
 String[] getLegalLineDelimiters()
          Returns the document's legal line delimiters.
 int getLength()
          Returns the number of characters in this document.
 String getLineDelimiter(int line)
          Returns the line delimiter of that line.
 IRegion getLineInformation(int line)
          Returns a description of the specified line.
 IRegion getLineInformationOfOffset(int offset)
          Returns a description of the line at the given offset.
 int getLineLength(int line)
          Returns the length of the given line including the line's delimiter.
 int getLineOffset(int line)
          Determines the offset of the first character of the given line.
 int getLineOfOffset(int pos)
          Returns the number of the line at which the character of the specified position is located.
 int getNumberOfLines()
          Returns the number of lines in this document
 int getNumberOfLines(int offset, int length)
          Returns the number of lines which are occupied by a given text range.
 ITypedRegion getPartition(int offset)
          Returns the document partition in which the position is located.
 String[] getPositionCategories()
          Returns all position categories of this document.
 Position[] getPositions(String category)
          Returns all positions of the given position category.
 IPositionUpdater[] getPositionUpdaters()
          Returns the list of position updaters attached to the document.
protected  ITextStore getStore()
          Returns the document's text store.
protected  ILineTracker getTracker()
          Returns the document's line tracker.
 void insertPositionUpdater(IPositionUpdater updater, int index)
          Inserts the position updater at the specified index in the document's list of position updaters.
 void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace)
          Callback for document listeners to be used inside documentChanged to register a post notification replace operation on the document notifying them.
 void removeDocumentListener(IDocumentListener listener)
          Removes the listener from the document's list of document listeners.
 void removeDocumentPartitioningListener(IDocumentPartitioningListener listener)
          Removes the listener from this document's list of document partitioning listeners.
 void removePosition(Position position)
          Removes the given position from the document's default position category.
 void removePosition(String category, Position position)
          Removes the given position from the specified position category.
 void removePositionCategory(String category)
          Deletes the position category from the document.
 void removePositionUpdater(IPositionUpdater updater)
          Removes the position updater from the document's list of position updaters.
 void removePrenotifiedDocumentListener(IDocumentListener listener)
          Removes the given document listener from the document's list of prenotified document listeners.
 void replace(int pos, int length, String text)
          Subsitutes the given text for the specified document range.
 void resumePostNotificationProcessing()
          Resumes the processing of post notification replace operations.
 int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord)
          Returns the offset of a given search string in the document based on a set of search criteria.
 void set(String text)
          Replaces the content of the document with the given text.
 void setDocumentPartitioner(IDocumentPartitioner partitioner)
          Sets this document's partitioner.
protected  void setLineTracker(ILineTracker tracker)
          Sets the document's line tracker.
protected  void setTextStore(ITextStore store)
          Sets the document's text store.
 void startSequentialRewrite(boolean normalized)
          Tells the document that it is about to be sequentially rewritten.
 void stopPostNotificationProcessing()
          Stops the processing of registered post notification replace operations until resumePostNotificationProcessing is called.
 void stopSequentialRewrite()
          Tells the document that the sequential rewrite has been finished.
protected  void updateDocumentStructures(DocumentEvent event)
          Updates document partitioning and document positions according to the specification given by the document event.
protected  void updatePositions(DocumentEvent event)
          Updates all positions of all categories to the change described by the document event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDocument

protected AbstractDocument()
The default constructor does not perform any configuration but leaves it to the clients who must first initialize the implementation plug-ins and then call completeInitialization. Results in the construction of an empty document.

Method Detail

getStore

protected ITextStore getStore()
Returns the document's text store. Assumes that the document has been initialized with a text store.

Returns:
the document's text store

getTracker

protected ILineTracker getTracker()
Returns the document's line tracker. Assumes that the document has been initialized with a line tracker.

Returns:
the document's line tracker

getDocumentListeners

protected List getDocumentListeners()
Returns the document's document listeners.

Returns:
the document's document listeners

getDocumentPartitioningListeners

protected List getDocumentPartitioningListeners()
Returns the document's partitioning listeners .

Returns:
the document's partitioning listeners

getDocumentManagedPositions

protected Map getDocumentManagedPositions()
Returns all positions managed by the document grouped by category.

Returns:
the document's positions

getDocumentPartitioner

public IDocumentPartitioner getDocumentPartitioner()
Description copied from interface: IDocument
Returns this document's partitioner.

Specified by:
getDocumentPartitioner in interface IDocument
Returns:
this document's partitioner

setTextStore

protected void setTextStore(ITextStore store)
Sets the document's text store. Must be called first inside the constructor.

Parameters:
store - the document's text store

setLineTracker

protected void setLineTracker(ILineTracker tracker)
Sets the document's line tracker. Must be called first inside the constructor.

Parameters:
tracker - the document's line tracker

setDocumentPartitioner

public void setDocumentPartitioner(IDocumentPartitioner partitioner)
Description copied from interface: IDocument
Sets this document's partitioner. The caller of this method is responsible for disconnecting the document's old partitioner from the document and to connect the new partitioner to the document. Informs all document partitioning listeners about this change.

Specified by:
setDocumentPartitioner in interface IDocument
See Also:
IDocumentPartitioningListener

completeInitialization

protected void completeInitialization()
Initializes document listeners, positions, and position updaters. Must be called inside the constructor after the implementation plug-ins have been set.


addDocumentListener

public void addDocumentListener(IDocumentListener listener)
Description copied from interface: IDocument
Registers the document listener with the document. After registration the IDocumentListener is informed about each change of this document. If the listener is already registered nothing happens.

An IDocumentListener may call back to this method when being inside a document notification.

Specified by:
addDocumentListener in interface IDocument
Parameters:
listener - the listener to be registered

removeDocumentListener

public void removeDocumentListener(IDocumentListener listener)
Description copied from interface: IDocument
Removes the listener from the document's list of document listeners. If the listener is not registered with the document nothing happens.

An IDocumentListener may call back to this method when being inside a document notification.

Specified by:
removeDocumentListener in interface IDocument
Parameters:
listener - the listener to be removed

addPrenotifiedDocumentListener

public void addPrenotifiedDocumentListener(IDocumentListener listener)
Description copied from interface: IDocument
Adds the given document listener as one which is notified before those document listeners added with addDocumentListener are notified. If the given listener is also registered using addDocumentListener it will be notified twice. If the listener is already registered nothing happens.

This method is not for public use, it may only be called by implementers of IDocumentAdapter and only if those implementers need to implement IDocumentListener.

Specified by:
addPrenotifiedDocumentListener in interface IDocument
Parameters:
listener - the listener to be added as prenotified document listener

removePrenotifiedDocumentListener

public void removePrenotifiedDocumentListener(IDocumentListener listener)
Description copied from interface: IDocument
Removes the given document listener from the document's list of prenotified document listeners. If the listener is not registered with the document nothing happens.

This method is not for public use, it may only be called by implementers of IDocumentAdapter and only if those implementers need to implement IDocumentListener.

Specified by:
removePrenotifiedDocumentListener in interface IDocument
Parameters:
listener - the listener to be removed
See Also:
IDocument.addPrenotifiedDocumentListener(IDocumentListener)

addDocumentPartitioningListener

public void addDocumentPartitioningListener(IDocumentPartitioningListener listener)
Description copied from interface: IDocument
Registers the document partitioning listener with the document. After registration the document partitioning listener is informed about each partition change cause by a document manipulation or by changing the document's partitioner. If a document partitioning listener is also a document listener, the following notification sequence is guaranteed if a document manipulation changes the document partitioning: If the listener is already registered nothing happens.

An IDocumentPartitioningListener may call back to this method when being inside a document notification.

Specified by:
addDocumentPartitioningListener in interface IDocument
Parameters:
listener - the listener to be added

removeDocumentPartitioningListener

public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener)
Description copied from interface: IDocument
Removes the listener from this document's list of document partitioning listeners. If the listener is not registered with the document nothing happens.

An IDocumentPartitioningListener may call back to this method when being inside a document notification.

Specified by:
removeDocumentPartitioningListener in interface IDocument
Parameters:
listener - the listener to be removed

addPosition

public void addPosition(String category,
                        Position position)
                 throws BadLocationException,
                        BadPositionCategoryException
Description copied from interface: IDocument
Adds the position to the specified position category of the document. A position that has been added to a position category is updated on each change applied to the document. Positions may be added multiple times. The order of the category is maintained.

Specified by:
addPosition in interface IDocument
Parameters:
category - the category to which to add
position - the position to be added
Throws:
BadPositionCategoryException - if the category is undefined in this document
BadLocationException - if position describes an invalid range in this document

addPosition

public void addPosition(Position position)
                 throws BadLocationException
Description copied from interface: IDocument
Adds the position to the document's default position category. This is a convenience method for addPosition(DEFAULT_CATEGORY, position).

Specified by:
addPosition in interface IDocument
Parameters:
position - the position to be added
Throws:
BadLocationException - if position describes an invalid range in this document

addPositionCategory

public void addPositionCategory(String category)
Description copied from interface: IDocument
Adds a new position category to the document. If the position category already exists nothing happens.

Specified by:
addPositionCategory in interface IDocument
Parameters:
category - the category to be added

addPositionUpdater

public void addPositionUpdater(IPositionUpdater updater)
Description copied from interface: IDocument
Appends a new position updater to the document's list of position updaters. Position updaters may be added multiple times.

An IPositionUpdater may call back to this method when being inside a document notification.

Specified by:
addPositionUpdater in interface IDocument
Parameters:
updater - the updater to be added

containsPosition

public boolean containsPosition(String category,
                                int offset,
                                int length)
Description copied from interface: IDocument
Determines whether a position described by the parameters is managed by this document.

Specified by:
containsPosition in interface IDocument
Parameters:
category - the category to check
offset - the offset of the position to find
length - the length of the position to find
Returns:
true if position is found

containsPositionCategory

public boolean containsPositionCategory(String category)
Description copied from interface: IDocument
Checks the presence of the specified position category.

Specified by:
containsPositionCategory in interface IDocument
Parameters:
category - the category to check
Returns:
true if category is defined

computeIndexInPositionList

protected int computeIndexInPositionList(List positions,
                                         int offset)
Computes the index in the list of positions at which a position with the given offset would be inserted. The position is supposed to become the first in this list of all positions with the same offset.

Parameters:
positions - the list in which the index is computed
offset - the offset for which the index is computed
Returns:
the computed index
See Also:
IDocument.computeIndexInCategory(String, int)

computeIndexInCategory

public int computeIndexInCategory(String category,
                                  int offset)
                           throws BadLocationException,
                                  BadPositionCategoryException
Description copied from interface: IDocument
Computes the index at which a Position with the specified offset would be inserted into the given category. As the ordering inside a category only depends on the offset, the index must be choosen to be the first of all positions with the same offset.

Specified by:
computeIndexInCategory in interface IDocument
Parameters:
category - the category in which would be added
offset - the position offset to be considered
Returns:
the index into the category
Throws:
BadPositionCategoryException - if category is undefined in this document
BadLocationException - if offset is invalid in this document

fireDocumentPartitioningChanged

protected void fireDocumentPartitioningChanged()
Deprecated. use fireDocumentPartitioningChanged(IRegion) instead

Fires the document partitioning changed notification to all registered document partitioning listeners. Uses a robust iterator.


fireDocumentPartitioningChanged

protected void fireDocumentPartitioningChanged(IRegion region)
Fires the document partitioning changed notification to all registered document partitioning listeners. Uses a robust iterator.

Parameters:
region - the region in which partitioning has changed
Since:
2.0
See Also:
IDocumentPartitioningListenerExtension

fireDocumentAboutToBeChanged

protected void fireDocumentAboutToBeChanged(DocumentEvent event)
Fires the given document event to all registers document listeners informing them about the forthcoming document manipulation. Uses a robust iterator.

Parameters:
event - the event to be sent out

updateDocumentStructures

protected void updateDocumentStructures(DocumentEvent event)
Updates document partitioning and document positions according to the specification given by the document event.

Parameters:
event - the document event describing the change to which structures must be adapted

fireDocumentChanged

protected void fireDocumentChanged(DocumentEvent event)
Updates the internal document structures and informs all document listeners. Uses a robust iterator.

Executes all registered post notification replace operation.

Parameters:
event - the document event to be sent out
See Also:
IDocumentExtension

getChar

public char getChar(int pos)
             throws BadLocationException
Description copied from interface: IDocument
Returns the character at the given document offset in this document.

Specified by:
getChar in interface IDocument
Parameters:
pos - a document offset
Returns:
the character at the offset
Throws:
BadLocationException - if the offset is invalid in this document

getContentType

public String getContentType(int offset)
                      throws BadLocationException
Description copied from interface: IDocument
Returns the type of the document partition containing the given offset. This is a convenience method for getPartition(offset).getType().

Specified by:
getContentType in interface IDocument
Parameters:
offset - the document offset
Returns:
the partition type
Throws:
BadLocationException - if offset is invalid in this document

getLegalContentTypes

public String[] getLegalContentTypes()
Description copied from interface: IDocument
Returns the set of legal content types of document partitions. This set can be empty. The set can contain more content types than contained by the result of getPartitioning(0, getLength()).

Specified by:
getLegalContentTypes in interface IDocument
Returns:
the set of legal content types

getLength

public int getLength()
Description copied from interface: IDocument
Returns the number of characters in this document.

Specified by:
getLength in interface IDocument
Returns:
the number of characters in this document

getLineDelimiter

public String getLineDelimiter(int line)
                        throws BadLocationException
Description copied from interface: IDocument
Returns the line delimiter of that line.

Specified by:
getLineDelimiter in interface IDocument
Parameters:
line - the line of interest
Returns:
the line delimiter of that line
Throws:
BadLocationException - if the line number is invalid in this document

getLegalLineDelimiters

public String[] getLegalLineDelimiters()
Description copied from interface: IDocument
Returns the document's legal line delimiters.

Specified by:
getLegalLineDelimiters in interface IDocument
Returns:
the document's legal line delimiters

getLineLength

public int getLineLength(int line)
                  throws BadLocationException
Description copied from interface: IDocument
Returns the length of the given line including the line's delimiter.

Specified by:
getLineLength in interface IDocument
Parameters:
line - the line of interest
Returns:
the length of the line
Throws:
BadLocationException - if the line number is invalid in this document

getLineOfOffset

public int getLineOfOffset(int pos)
                    throws BadLocationException
Description copied from interface: IDocument
Returns the number of the line at which the character of the specified position is located. The first line has the line number 0. A new line starts directly after a line delimiter. (pos == document length) is a valid argument also there is no corresponding character.

Specified by:
getLineOfOffset in interface IDocument
Parameters:
pos - the document offset
Returns:
the number of the line
Throws:
BadLocationException - if the offset is invalid in this document

getLineOffset

public int getLineOffset(int line)
                  throws BadLocationException
Description copied from interface: IDocument
Determines the offset of the first character of the given line.

Specified by:
getLineOffset in interface IDocument
Parameters:
line - the line of interest
Returns:
the document offset
Throws:
BadLocationException - if the line number is invalid in this document

getLineInformation

public IRegion getLineInformation(int line)
                           throws BadLocationException
Description copied from interface: IDocument
Returns a description of the specified line. The line is described by its offset and its length excluding the line's delimiter.

Specified by:
getLineInformation in interface IDocument
Parameters:
line - the line of interest
Returns:
a line description
Throws:
BadLocationException - if the line number is invalid in this document

getLineInformationOfOffset

public IRegion getLineInformationOfOffset(int offset)
                                   throws BadLocationException
Description copied from interface: IDocument
Returns a description of the line at the given offset. The description contains the offset and the length of the line excluding the line's delimiter.

Specified by:
getLineInformationOfOffset in interface IDocument
Parameters:
offset - the offset whose line should be described
Returns:
a region describing the line
Throws:
BadLocationException - if offset is invalid in this document

getNumberOfLines

public int getNumberOfLines()
Description copied from interface: IDocument
Returns the number of lines in this document

Specified by:
getNumberOfLines in interface IDocument
Returns:
the number of lines in this document

getNumberOfLines

public int getNumberOfLines(int offset,
                            int length)
                     throws BadLocationException
Description copied from interface: IDocument
Returns the number of lines which are occupied by a given text range.

Specified by:
getNumberOfLines in interface IDocument
Parameters:
offset - the offset of the specified text range
length - the length of the specified text range
Returns:
the number of lines occupied by the specified range
Throws:
BadLocationException - if specified range is invalid in this tracker

computeNumberOfLines

public int computeNumberOfLines(String text)
Description copied from interface: IDocument
Computes the number of lines in the given text. For a given implementer of this interface this method returns the same result as set(text); getNumberOfLines().

Specified by:
computeNumberOfLines in interface IDocument
Parameters:
text - the text whose number of lines should be computed
Returns:
the number of lines in the given text

getPartition

public ITypedRegion getPartition(int offset)
                          throws BadLocationException
Description copied from interface: IDocument
Returns the document partition in which the position is located.

Specified by:
getPartition in interface IDocument
Parameters:
offset - the document offset
Returns:
a specification of the partition
Throws:
BadLocationException - if offset is invalid in this document

computePartitioning

public ITypedRegion[] computePartitioning(int offset,
                                          int length)
                                   throws BadLocationException
Description copied from interface: IDocument
Computes the partitioning of the given document range using the document's partitioner.

Specified by:
computePartitioning in interface IDocument
Parameters:
offset - the document offset at which the range starts
length - the length of the document range
Returns:
a specification of the range's partitioning
Throws:
BadLocationException - if the range is invalid in this document

getPositions

public Position[] getPositions(String category)
                        throws BadPositionCategoryException
Description copied from interface: IDocument
Returns all positions of the given position category. The positions are ordered according to the category's order. Manipulating this list does not affect the document, but manipulating the position does affect the document.

Specified by:
getPositions in interface IDocument
Parameters:
category - the category
Returns:
the list of all positions
Throws:
BadPositionCategoryException - if category is undefined in this document

getPositionCategories

public String[] getPositionCategories()
Description copied from interface: IDocument
Returns all position categories of this document. This includes the default position category.

Specified by:
getPositionCategories in interface IDocument
Returns:
the document's position categories

getPositionUpdaters

public IPositionUpdater[] getPositionUpdaters()
Description copied from interface: IDocument
Returns the list of position updaters attached to the document.

Specified by:
getPositionUpdaters in interface IDocument
Returns:
the list of position updaters

get

public String get()
Description copied from interface: IDocument
Returns this document's complete text.

Specified by:
get in interface IDocument
Returns:
the document's complete text

get

public String get(int pos,
                  int length)
           throws BadLocationException
Description copied from interface: IDocument
Returns this document's text for the specified range.

Specified by:
get in interface IDocument
Parameters:
pos - the document offset
length - the length of the specified range
Returns:
the document's text for the specified range
Throws:
BadLocationException - if the range is invalid in this document

insertPositionUpdater

public void insertPositionUpdater(IPositionUpdater updater,
                                  int index)
Description copied from interface: IDocument
Inserts the position updater at the specified index in the document's list of position updaters. Positions updaters may be inserted multiple times.

An IPositionUpdater may call back to this method when being inside a document notification.

Specified by:
insertPositionUpdater in interface IDocument
Parameters:
updater - the updater to be inserted
index - the index in the document's updater list

removePosition

public void removePosition(String category,
                           Position position)
                    throws BadPositionCategoryException
Description copied from interface: IDocument
Removes the given position from the specified position category. If the position is not part of the specified category nothing happens. If the position has been added multiple times, only the first occurence is deleted.

Specified by:
removePosition in interface IDocument
Parameters:
category - the category from which to delete
position - the position to be deleted
Throws:
BadPositionCategoryException - if category is undefined in this document

removePosition

public void removePosition(Position position)
Description copied from interface: IDocument
Removes the given position from the document's default position category. This is a convenience method for removePosition(DEFAULT_CATEGORY, position).

Specified by:
removePosition in interface IDocument
Parameters:
position - the position to be removed

removePositionCategory

public void removePositionCategory(String category)
                            throws BadPositionCategoryException
Description copied from interface: IDocument
Deletes the position category from the document. All positions in this category are thus deleted as well.

Specified by:
removePositionCategory in interface IDocument
Parameters:
category - the category to be removed
Throws:
BadPositionCategoryException - if category is undefined in this document

removePositionUpdater

public void removePositionUpdater(IPositionUpdater updater)
Description copied from interface: IDocument
Removes the position updater from the document's list of position updaters. If the position updater has multiple occurences only the first occurence is removed. If the position updater is not registered with this document, nothing happens.

An IPositionUpdater may call back to this method when being inside a document notification.

Specified by:
removePositionUpdater in interface IDocument
Parameters:
updater - the updater to be removed

replace

public void replace(int pos,
                    int length,
                    String text)
             throws BadLocationException
Description copied from interface: IDocument
Subsitutes the given text for the specified document range. Sends a DocumentEvent to all registered IDocumentListener.

Specified by:
replace in interface IDocument
Parameters:
pos - the document offset
length - the length of the specified range
text - the substitution text
Throws:
BadLocationException - if the offset is invalid in this document
See Also:
DocumentEvent, IDocumentListener

set

public void set(String text)
Description copied from interface: IDocument
Replaces the content of the document with the given text. Sends a DocumentEvent to all registered IDocumentListener. This method is a convenience method for replace(0, getLength(), text).

Specified by:
set in interface IDocument
Parameters:
text - the new content of the document
See Also:
DocumentEvent, IDocumentListener

updatePositions

protected void updatePositions(DocumentEvent event)
Updates all positions of all categories to the change described by the document event. All registered document updaters are called in the sequence they have been arranged. Uses a robust iterator.

Parameters:
event - the document event describing the change to which to adapt the positions

search

public int search(int startPosition,
                  String findString,
                  boolean forwardSearch,
                  boolean caseSensitive,
                  boolean wholeWord)
           throws BadLocationException
Description copied from interface: IDocument
Returns the offset of a given search string in the document based on a set of search criteria.

Specified by:
search in interface IDocument
Parameters:
startPosition - document offset at which search starts
findString - the string to find
forwardSearch - the search direction
caseSensitive - indicates whether lower and upper case should be distinguished
wholeWord - indicates whether the findString should be limited by white spaces as defined by Character.isWhiteSpace
Returns:
the offset of the first occurence of findString based on the parameters
Throws:
BadLocationException - if startOffset is an invalid document offset

registerPostNotificationReplace

public void registerPostNotificationReplace(IDocumentListener owner,
                                            IDocumentExtension.IReplace replace)
Description copied from interface: IDocumentExtension
Callback for document listeners to be used inside documentChanged to register a post notification replace operation on the document notifying them.

Specified by:
registerPostNotificationReplace in interface IDocumentExtension
Parameters:
owner - the owner of the replace operation

stopPostNotificationProcessing

public void stopPostNotificationProcessing()
Description copied from interface: IDocumentExtension
Stops the processing of registered post notification replace operations until resumePostNotificationProcessing is called.

Specified by:
stopPostNotificationProcessing in interface IDocumentExtension

resumePostNotificationProcessing

public void resumePostNotificationProcessing()
Description copied from interface: IDocumentExtension
Resumes the processing of post notification replace operations. If the queue of registered IDocumentExtension.IReplace objects is not empty, they are immediately processed if the document is not inside a replace operation. If the document is inside a replace operation, they are processed directly after the replace operation has finished.

Specified by:
resumePostNotificationProcessing in interface IDocumentExtension

startSequentialRewrite

public void startSequentialRewrite(boolean normalized)
Description copied from interface: IDocumentExtension
Tells the document that it is about to be sequentially rewritten. That is a sequence of non-overlapping replace operations will be performed on it. The normalize flag indicates whether the rewrite is preformed from the start of the document to its end or from an arbitrary start offset.

Specified by:
startSequentialRewrite in interface IDocumentExtension
Parameters:
normalized - true if performed from the start to the end of the document

stopSequentialRewrite

public void stopSequentialRewrite()
Description copied from interface: IDocumentExtension
Tells the document that the sequential rewrite has been finished.

Specified by:
stopSequentialRewrite in interface IDocumentExtension

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.