Class AbstractDocument
- All Implemented Interfaces:
IDocument,IDocumentExtension,IDocumentExtension2,IDocumentExtension3,IDocumentExtension4,IRepairableDocument,IRepairableDocumentExtension
- Direct Known Subclasses:
Document,ProjectionDocument
IDocument and its extension
interfaces IDocumentExtension,
IDocumentExtension2,
IDocumentExtension3,
IDocumentExtension4, as well as
IRepairableDocument.
An AbstractDocument supports the following implementation
plug-ins:
- a text store implementing
ITextStorefor storing and managing the document's content, - a line tracker implementing
ILineTrackerto map character positions to line numbers and vice versa
This class must be subclassed. Subclasses must configure which implementation plug-ins the document instance should use. Subclasses are not intended to overwrite existing methods.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jface.text.IDocumentExtension
IDocumentExtension.IReplace -
Field Summary
Fields inherited from interface org.eclipse.jface.text.IDocument
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPEFields inherited from interface org.eclipse.jface.text.IDocumentExtension3
DEFAULT_PARTITIONINGFields inherited from interface org.eclipse.jface.text.IDocumentExtension4
UNKNOWN_MODIFICATION_STAMP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThe default constructor does not perform any configuration but leaves it to the clients who must first initialize the implementation plug-ins and then callcompleteInitialization. -
Method Summary
Modifier and TypeMethodDescriptionvoidTells the receiver to accept calls toregisterPostNotificationReplaceuntilignorePostNotificationReplacesis called.voidaddDocumentListener(IDocumentListener listener) Registers the document listener with the document.voidRegisters the document partitioning listener with the document.voidRegisters the document rewrite session listener with the document.voidaddPosition(String category, Position position) Adds the position to the specified position category of the document.voidaddPosition(Position position) Adds the position to the document's default position category.voidaddPositionCategory(String category) Adds a new position category to the document.voidaddPositionUpdater(IPositionUpdater updater) Appends a new position updater to the document's list of position updaters.voidAdds the given document listener as one which is notified before those document listeners added withaddDocumentListenerare notified.protected final voidcheckStateOfPartitioner(IDocumentPartitioner partitioner, String partitioning) Checks the state for the given partitioner and stops the active rewrite session.protected voidInitializes document listeners, positions, and position updaters.intcomputeIndexInCategory(String category, int offset) Computes the index at which aPositionwith the specified offset would be inserted into the given category.protected intcomputeIndexInPositionList(List<? extends Position> positions, int offset) Deprecated.protected intcomputeIndexInPositionList(List<? extends Position> positions, int offset, boolean orderedByOffset) Computes the index in the list of positions at which a position with the given position would be inserted.intcomputeNumberOfLines(String text) Computes the number of lines in the given text.computePartitioning(int offset, int length) Computes the partitioning of the given document range using the document's partitioner.computePartitioning(String partitioning, int offset, int length, boolean includeZeroLengthPartitions) Computes the partitioning of the given document range based on the given partitioning type.booleancontainsPosition(String category, int offset, int length) Determines whether a position described by the parameters is managed by this document.booleancontainsPositionCategory(String category) Checks the presence of the specified position category.protected voidNotifies all listeners about the given document change.protected voiddoFireDocumentChanged(DocumentEvent event, boolean firePartitionChange, IRegion partitionChange) Deprecated.as of 3.0.protected voidNotifies all listeners about the given document change.protected voidFires the given document event to all registers document listeners informing them about the forthcoming document manipulation.protected voidfireDocumentChanged(DocumentEvent event) Updates the internal document structures and informs all document listeners if listener notification has been enabled.protected voidDeprecated.as of 2.0.protected voidFires the document partitioning changed notification to all registered document partitioning listeners.protected voidDeprecated.as of 3.0.protected voidFires the given event to all registered rewrite session listeners.get()Returns this document's complete text.get(int pos, int length) Returns this document's text for the specified range.final DocumentRewriteSessionReturns the active rewrite session of this document ornull.chargetChar(int pos) Returns the character at the given document offset in this document.getContentType(int offset) Returns the type of the document partition containing the given offset.getContentType(String partitioning, int offset, boolean preferOpenPartitions) Returns the type of the document partition containing the given offset for the given partitioning.Returns this document's default line delimiter.protected List<IDocumentListener> Returns the document's document listeners.Returns all positions managed by the document grouped by category.Returns this document's partitioner.getDocumentPartitioner(String partitioning) Returns the partitioner for the given partitioning ornullif no partitioner is registered.protected List<IDocumentPartitioningListener> Returns the document's partitioning listeners.String[]Returns the set of legal content types of document partitions.String[]getLegalContentTypes(String partitioning) Returns the set of legal content types of document partitions for the given partitioning This set can be empty.String[]Returns the document's legal line delimiters.intReturns the number of characters in this document.getLineDelimiter(int line) Returns the line delimiter of that line ornullif the line is not closed with a line delimiter.getLineInformation(int line) Returns a description of the specified line.getLineInformationOfOffset(int offset) Returns a description of the line at the given offset.intgetLineLength(int line) Returns the length of the given line including the line's delimiter.intgetLineOffset(int line) Determines the offset of the first character of the given line.intgetLineOfOffset(int pos) Returns the number of the line at which the character of the specified position is located.longReturns the modification stamp of this document.intReturns the number of lines in this document.intgetNumberOfLines(int offset, int length) Returns the number of lines which are occupied by a given text range.getPartition(int offset) Returns the document partition in which the position is located.getPartition(String partitioning, int offset, boolean preferOpenPartitions) Returns the document partition of the given partitioning in which the given offset is located.String[]Returns the existing partitionings for this document.String[]Returns all position categories of this document.Position[]getPositions(String category) Returns all positions of the given position category.Position[]getPositions(String category, int offset, int length, boolean canStartBefore, boolean canEndAfter) Returns all positions of the given category that are inside the given region.Returns the list of position updaters attached to the document.protected ITextStoregetStore()Returns the document's text store.protected ILineTrackerReturns the document's line tracker.voidTells the receiver to ignore calls toregisterPostNotificationReplaceuntilacceptPostNotificationReplacesis called.voidinsertPositionUpdater(IPositionUpdater updater, int index) Inserts the position updater at the specified index in the document's list of position updaters.booleanisLineInformationRepairNeeded(int offset, int length, String text) Tells whether the line information of the document implementing this interface needs to be repaired after replacing the given text.voidCallback for document listeners to be used insidedocumentChangedto register a post notification replace operation on the document notifying them.voidremoveDocumentListener(IDocumentListener listener) Removes the listener from the document's list of document listeners.voidRemoves the listener from this document's list of document partitioning listeners.voidRemoves the listener from the document's list of document rewrite session listeners.voidremovePosition(String category, Position position) Removes the given position from the specified position category.voidremovePosition(Position position) Removes the given position from the document's default position category.voidremovePositionCategory(String category) Deletes the position category from the document.voidremovePositionUpdater(IPositionUpdater updater) Removes the position updater from the document's list of position updaters.voidRemoves the given document listener from the document's list of pre-notified document listeners.voidRepairs the line information of the document implementing this interface.voidSubstitutes the given text for the specified document range.voidSubstitutes the given text for the specified document range.voidResumes the notification of document listeners which must previously have been stopped by a call tostopListenerNotification.voidResumes the processing of post notification replace operations.intsearch(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) Deprecated.as of 3.0 search is provided byFindReplaceDocumentAdaptervoidReplaces the content of the document with the given text.voidReplaces the content of the document with the given text.voidsetDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner) Sets this document's partitioner.voidsetDocumentPartitioner(IDocumentPartitioner partitioner) Sets this document's partitioner.voidsetInitialLineDelimiter(String lineDelimiter) Sets this document's initial line delimiter i.e. the one which is returned bygetDefaultLineDelimiterif the document does not yet contain any line delimiter.protected voidsetLineTracker(ILineTracker tracker) Sets the document's line tracker.protected voidsetTextStore(ITextStore store) Sets the document's text store.startRewriteSession(DocumentRewriteSessionType sessionType) Tells the document that it is about to be rewritten.protected final voidStarts the given rewrite session.voidstartSequentialRewrite(boolean normalized) Deprecated.since 3.1.voidCan be called prior to areplaceoperation.voidStops the processing of registered post notification replace operations untilresumePostNotificationProcessingis called.voidstopRewriteSession(DocumentRewriteSession session) Tells the document to stop the rewrite session.protected final voidStops the given rewrite session.voidDeprecated.As of 3.1, replaced byIDocumentExtension4.stopRewriteSession(DocumentRewriteSession)protected voidUpdates document partitioning and document positions according to the specification given by the document event.protected voidupdatePositions(DocumentEvent event) Updates all positions of all categories to the change described by the document event.
-
Constructor Details
-
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 callcompleteInitialization. Results in the construction of an empty document.
-
-
Method Details
-
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
Returns the document's line tracker. Assumes that the document has been initialized with a line tracker.- Returns:
- the document's line tracker
-
getDocumentListeners
Returns the document's document listeners.- Returns:
- the document's document listeners
-
getDocumentPartitioningListeners
Returns the document's partitioning listeners.- Returns:
- the document's partitioning listeners
-
getDocumentManagedPositions
Returns all positions managed by the document grouped by category.- Returns:
- the document's positions
-
getDocumentPartitioner
Description copied from interface:IDocumentReturns this document's partitioner.Use
IDocumentExtension3.getDocumentPartitioner(String)when the document supports multiple partitionings. In that case this method is equivalent to:IDocumentExtension3 extension= (IDocumentExtension3) document; return extension.getDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING);- Specified by:
getDocumentPartitionerin interfaceIDocument- Returns:
- this document's partitioner
-
setTextStore
Sets the document's text store. Must be called at the beginning of the constructor.- Parameters:
store- the document's text store
-
setLineTracker
Sets the document's line tracker. Must be called at the beginning of the constructor.- Parameters:
tracker- the document's line tracker
-
setDocumentPartitioner
Description copied from interface:IDocumentSets 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.Use
IDocumentExtension3.setDocumentPartitioner(String, IDocumentPartitioner)when the document supports multiple partitionings. In that case this method is equivalent to:IDocumentExtension3 extension= (IDocumentExtension3) document; extension.setDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING, partitioner);- Specified by:
setDocumentPartitionerin interfaceIDocument- Parameters:
partitioner- the document's new partitioner- See Also:
-
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
Description copied from interface:IDocumentRegisters 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
IDocumentListenermay call back to this method when being inside a document notification.- Specified by:
addDocumentListenerin interfaceIDocument- Parameters:
listener- the listener to be registered
-
removeDocumentListener
Description copied from interface:IDocumentRemoves the listener from the document's list of document listeners. If the listener is not registered with the document nothing happens.An
IDocumentListenermay call back to this method when being inside a document notification.- Specified by:
removeDocumentListenerin interfaceIDocument- Parameters:
listener- the listener to be removed
-
addPrenotifiedDocumentListener
Description copied from interface:IDocumentAdds the given document listener as one which is notified before those document listeners added withaddDocumentListenerare notified. If the given listener is also registered usingaddDocumentListenerit will be notified twice. If the listener is already registered nothing happens.This method is not for public use.
- Specified by:
addPrenotifiedDocumentListenerin interfaceIDocument- Parameters:
listener- the listener to be added as pre-notified document listener- See Also:
-
removePrenotifiedDocumentListener
Description copied from interface:IDocumentRemoves the given document listener from the document's list of pre-notified document listeners. If the listener is not registered with the document nothing happens.This method is not for public use.
- Specified by:
removePrenotifiedDocumentListenerin interfaceIDocument- Parameters:
listener- the listener to be removed- See Also:
-
addDocumentPartitioningListener
Description copied from interface:IDocumentRegisters 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:- listener.documentAboutToBeChanged(DocumentEvent);
- listener.documentPartitioningChanged();
- listener.documentChanged(DocumentEvent);
An
IDocumentPartitioningListenermay call back to this method when being inside a document notification.- Specified by:
addDocumentPartitioningListenerin interfaceIDocument- Parameters:
listener- the listener to be added
-
removeDocumentPartitioningListener
Description copied from interface:IDocumentRemoves the listener from this document's list of document partitioning listeners. If the listener is not registered with the document nothing happens.An
IDocumentPartitioningListenermay call back to this method when being inside a document notification.- Specified by:
removeDocumentPartitioningListenerin interfaceIDocument- Parameters:
listener- the listener to be removed
-
addPosition
public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException Description copied from interface:IDocumentAdds the position to the specified position category of the document. Positions may be added multiple times. The order of the category is maintained.Note: The position is only updated on each change applied to the document if a
IPositionUpdaterhas been registered that handles the given category.- Specified by:
addPositionin interfaceIDocument- Parameters:
category- the category to which to addposition- the position to be added- Throws:
BadLocationException- if position describes an invalid range in this documentBadPositionCategoryException- if the category is undefined in this document
-
addPosition
Description copied from interface:IDocumentAdds the position to the document's default position category. This is a convenience method foraddPosition(DEFAULT_CATEGORY, position).- Specified by:
addPositionin interfaceIDocument- Parameters:
position- the position to be added- Throws:
BadLocationException- if position describes an invalid range in this document
-
addPositionCategory
Description copied from interface:IDocumentAdds a new position category to the document. If the position category already exists nothing happens.- Specified by:
addPositionCategoryin interfaceIDocument- Parameters:
category- the category to be added
-
addPositionUpdater
Description copied from interface:IDocumentAppends a new position updater to the document's list of position updaters. Position updaters may be added multiple times.An
IPositionUpdatermay call back to this method when being inside a document notification.- Specified by:
addPositionUpdaterin interfaceIDocument- Parameters:
updater- the updater to be added
-
containsPosition
Description copied from interface:IDocumentDetermines whether a position described by the parameters is managed by this document.- Specified by:
containsPositionin interfaceIDocument- Parameters:
category- the category to checkoffset- the offset of the position to findlength- the length of the position to find- Returns:
trueif position is found
-
containsPositionCategory
Description copied from interface:IDocumentChecks the presence of the specified position category.- Specified by:
containsPositionCategoryin interfaceIDocument- Parameters:
category- the category to check- Returns:
trueif category is defined
-
computeIndexInPositionList
@Deprecated protected int computeIndexInPositionList(List<? extends Position> positions, int offset) Deprecated.As of 3.4, replaced bycomputeIndexInPositionList(List, int, boolean)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 computedoffset- the offset for which the index is computed- Returns:
- the computed index
- See Also:
-
computeIndexInPositionList
protected int computeIndexInPositionList(List<? extends Position> positions, int offset, boolean orderedByOffset) Computes the index in the list of positions at which a position with the given position would be inserted. The position to insert is supposed to become the first in this list of all positions with the same position.- Parameters:
positions- the list in which the index is computedoffset- the offset for which the index is computedorderedByOffset-trueif ordered by offset, false if ordered by end position- Returns:
- the computed index
- Since:
- 3.4
-
computeIndexInCategory
public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException Description copied from interface:IDocumentComputes the index at which aPositionwith 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 chosen to be the first of all positions with the same offset.- Specified by:
computeIndexInCategoryin interfaceIDocument- Parameters:
category- the category in which would be addedoffset- the position offset to be considered- Returns:
- the index into the category
- Throws:
BadLocationException- if offset is invalid in this documentBadPositionCategoryException- if category is undefined in this document
-
fireDocumentPartitioningChanged
Deprecated.as of 2.0. UsefireDocumentPartitioningChanged(IRegion)instead.Fires the document partitioning changed notification to all registered document partitioning listeners. Uses a robust iterator. -
fireDocumentPartitioningChanged
Deprecated.as of 3.0. UsefireDocumentPartitioningChanged(DocumentPartitioningChangedEvent)instead.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:
-
fireDocumentPartitioningChanged
Fires the document partitioning changed notification to all registered document partitioning listeners. Uses a robust iterator.- Parameters:
event- the document partitioning changed event- Since:
- 3.0
- See Also:
-
fireDocumentAboutToBeChanged
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
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
-
doFireDocumentChanged
Notifies all listeners about the given document change. Uses a robust iterator.Executes all registered post notification replace operation.
- Parameters:
event- the event to be sent out.
-
doFireDocumentChanged
@Deprecated protected void doFireDocumentChanged(DocumentEvent event, boolean firePartitionChange, IRegion partitionChange) Deprecated.as of 3.0. UsedoFireDocumentChanged2(DocumentEvent)instead; this method will be removed.Notifies all listeners about the given document change. Uses a robust iterator.Executes all registered post notification replace operation.
- Parameters:
event- the event to be sent outfirePartitionChange-trueif a partition change notification should be sentpartitionChange- the region whose partitioning changed- Since:
- 2.0
-
doFireDocumentChanged2
Notifies all listeners about the given document change. Uses a robust iterator.Executes all registered post notification replace operation.
This method will be renamed to
doFireDocumentChanged.- Parameters:
event- the event to be sent out- Since:
- 3.0
-
fireDocumentChanged
Updates the internal document structures and informs all document listeners if listener notification has been enabled. Otherwise it remembers the event to be sent to the listeners on resume.- Parameters:
event- the document event to be sent out
-
getChar
Description copied from interface:IDocumentReturns the character at the given document offset in this document.- Specified by:
getCharin interfaceIDocument- Parameters:
pos- a document offset- Returns:
- the character at the offset
- Throws:
BadLocationException- if the offset is invalid in this document
-
getContentType
Description copied from interface:IDocumentReturns the type of the document partition containing the given offset. This is a convenience method forgetPartition(offset).getType().Use
IDocumentExtension3.getContentType(String, int, boolean)when the document supports multiple partitionings. In that case this method is equivalent to:IDocumentExtension3 extension= (IDocumentExtension3) document; return extension.getContentType(IDocumentExtension3.DEFAULT_PARTITIONING, offset, false);- Specified by:
getContentTypein interfaceIDocument- Parameters:
offset- the document offset- Returns:
- the partition type
- Throws:
BadLocationException- if offset is invalid in this document
-
getLegalContentTypes
Description copied from interface:IDocumentReturns 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 ofgetPartitioning(0, getLength()).Use
IDocumentExtension3.getLegalContentTypes(String)when the document supports multiple partitionings. In that case this method is equivalent to:IDocumentExtension3 extension= (IDocumentExtension3) document; return extension.getLegalContentTypes(IDocumentExtension3.DEFAULT_PARTITIONING);- Specified by:
getLegalContentTypesin interfaceIDocument- Returns:
- the set of legal content types
-
getLength
public int getLength()Description copied from interface:IDocumentReturns the number of characters in this document. -
getLineDelimiter
Description copied from interface:IDocumentReturns the line delimiter of that line ornullif the line is not closed with a line delimiter.- Specified by:
getLineDelimiterin interfaceIDocument- Parameters:
line- the line of interest- Returns:
- the line's delimiter or
nullif line does not have a delimiter - Throws:
BadLocationException- if the line number is invalid in this document
-
getLegalLineDelimiters
Description copied from interface:IDocumentReturns the document's legal line delimiters.- Specified by:
getLegalLineDelimitersin interfaceIDocument- Returns:
- the document's legal line delimiters
-
getDefaultLineDelimiter
Description copied from interface:IDocumentExtension4Returns this document's default line delimiter.This default line delimiter should be used by clients who want unique delimiters (e.g. 'CR's) in the document.
- Specified by:
getDefaultLineDelimiterin interfaceIDocumentExtension4- Returns:
- the default line delimiter or
nullif none
-
setInitialLineDelimiter
Description copied from interface:IDocumentExtension4Sets this document's initial line delimiter i.e. the one which is returned bygetDefaultLineDelimiterif the document does not yet contain any line delimiter.- Specified by:
setInitialLineDelimiterin interfaceIDocumentExtension4- Parameters:
lineDelimiter- the default line delimiter
-
getLineLength
Description copied from interface:IDocumentReturns the length of the given line including the line's delimiter.- Specified by:
getLineLengthin interfaceIDocument- Parameters:
line- the line of interest- Returns:
- the length of the line
- Throws:
BadLocationException- if the line number is invalid in this document
-
getLineOfOffset
Description copied from interface:IDocumentReturns 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.(offset == document length)is a valid argument although there is no corresponding character.- Specified by:
getLineOfOffsetin interfaceIDocument- Parameters:
pos- the document offset- Returns:
- the number of the line
- Throws:
BadLocationException- if the offset is invalid in this document
-
getLineOffset
Description copied from interface:IDocumentDetermines the offset of the first character of the given line.- Specified by:
getLineOffsetin interfaceIDocument- Parameters:
line- the line of interest- Returns:
- the document offset
- Throws:
BadLocationException- if the line number is invalid in this document
-
getLineInformation
Description copied from interface:IDocumentReturns a description of the specified line. The line is described by its offset and its length excluding the line's delimiter.- Specified by:
getLineInformationin interfaceIDocument- Parameters:
line- the line of interest- Returns:
- a line description
- Throws:
BadLocationException- if the line number is invalid in this document
-
getLineInformationOfOffset
Description copied from interface:IDocumentReturns 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:
getLineInformationOfOffsetin interfaceIDocument- 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:IDocumentReturns the number of lines in this document.Note that a document always has at least one line.
- Specified by:
getNumberOfLinesin interfaceIDocument- Returns:
- the number of lines in this document.
-
getNumberOfLines
Description copied from interface:IDocumentReturns the number of lines which are occupied by a given text range.- Specified by:
getNumberOfLinesin interfaceIDocument- Parameters:
offset- the offset of the specified text rangelength- 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
Description copied from interface:IDocumentComputes the number of lines in the given text. For a given implementer of this interface this method returns the same result asset(text); getNumberOfLines().- Specified by:
computeNumberOfLinesin interfaceIDocument- Parameters:
text- the text whose number of lines should be computed- Returns:
- the number of lines in the given text
-
getPartition
Description copied from interface:IDocumentReturns the document partition in which the position is located.Use
IDocumentExtension3.getPartition(String, int, boolean)when the document supports multiple partitionings. In that case this method is equivalent:IDocumentExtension3 extension= (IDocumentExtension3) document; return extension.getPartition(IDocumentExtension3.DEFAULT_PARTITIONING, offset, false);- Specified by:
getPartitionin interfaceIDocument- Parameters:
offset- the document offset- Returns:
- a specification of the partition
- Throws:
BadLocationException- if offset is invalid in this document
-
computePartitioning
Description copied from interface:IDocumentComputes the partitioning of the given document range using the document's partitioner.Use
IDocumentExtension3.computePartitioning(String, int, int, boolean)when the document supports multiple partitionings. In that case this method is equivalent:IDocumentExtension3 extension= (IDocumentExtension3) document; return extension.computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING, offset, length, false);- Specified by:
computePartitioningin interfaceIDocument- Parameters:
offset- the document offset at which the range startslength- 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
Description copied from interface:IDocumentReturns 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:
getPositionsin interfaceIDocument- Parameters:
category- the category- Returns:
- the list of all positions
- Throws:
BadPositionCategoryException- if category is undefined in this document
-
getPositionCategories
Description copied from interface:IDocumentReturns all position categories of this document. This includes the default position category.- Specified by:
getPositionCategoriesin interfaceIDocument- Returns:
- the document's position categories
-
getPositionUpdaters
Description copied from interface:IDocumentReturns the list of position updaters attached to the document.- Specified by:
getPositionUpdatersin interfaceIDocument- Returns:
- the list of position updaters
-
get
Description copied from interface:IDocumentReturns this document's complete text. -
get
Description copied from interface:IDocumentReturns this document's text for the specified range.- Specified by:
getin interfaceIDocument- Parameters:
pos- the document offsetlength- 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
Description copied from interface:IDocumentInserts the position updater at the specified index in the document's list of position updaters. Positions updaters may be inserted multiple times.An
IPositionUpdatermay call back to this method when being inside a document notification.- Specified by:
insertPositionUpdaterin interfaceIDocument- Parameters:
updater- the updater to be insertedindex- the index in the document's updater list
-
removePosition
Description copied from interface:IDocumentRemoves 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 occurrence is deleted.- Specified by:
removePositionin interfaceIDocument- Parameters:
category- the category from which to deleteposition- the position to be deleted- Throws:
BadPositionCategoryException- if category is undefined in this document
-
removePosition
Description copied from interface:IDocumentRemoves the given position from the document's default position category. This is a convenience method forremovePosition(DEFAULT_CATEGORY, position).- Specified by:
removePositionin interfaceIDocument- Parameters:
position- the position to be removed
-
removePositionCategory
Description copied from interface:IDocumentDeletes the position category from the document. All positions in this category are thus deleted as well.- Specified by:
removePositionCategoryin interfaceIDocument- Parameters:
category- the category to be removed- Throws:
BadPositionCategoryException- if category is undefined in this document
-
removePositionUpdater
Description copied from interface:IDocumentRemoves the position updater from the document's list of position updaters. If the position updater has multiple occurrences only the first occurrence is removed. If the position updater is not registered with this document, nothing happens.An
IPositionUpdatermay call back to this method when being inside a document notification.- Specified by:
removePositionUpdaterin interfaceIDocument- Parameters:
updater- the updater to be removed
-
getModificationStamp
public long getModificationStamp()Description copied from interface:IDocumentExtension4Returns the modification stamp of this document. The modification stamp is updated each time a modifying operation is called on this document. If two modification stamps of the same document are identical then the document content is too, however, same content does not imply same modification stamp.The magnitude or sign of the numerical difference between two modification stamps is not significant.
- Specified by:
getModificationStampin interfaceIDocumentExtension4- Returns:
- the modification stamp of this document or
UNKNOWN_MODIFICATION_STAMP
-
replace
public void replace(int pos, int length, String text, long modificationStamp) throws BadLocationException Description copied from interface:IDocumentExtension4Substitutes the given text for the specified document range. Sends aDocumentEventto all registeredIDocumentListener.- Specified by:
replacein interfaceIDocumentExtension4- Parameters:
pos- the document offsetlength- the length of the specified rangetext- the substitution textmodificationStamp- of the document after replacing- Throws:
BadLocationException- if the offset is invalid in this document- See Also:
-
isLineInformationRepairNeeded
public boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException Tells whether the line information of the document implementing this interface needs to be repaired after replacing the given text.- Specified by:
isLineInformationRepairNeededin interfaceIRepairableDocumentExtension- Parameters:
offset- the document offsetlength- the length of the specified rangetext- the substitution text to check- Returns:
trueif the line information must be repaired after replacing- Throws:
BadLocationException- if the offset is invalid in this document- Since:
- 3.4
- See Also:
-
replace
Description copied from interface:IDocumentSubstitutes the given text for the specified document range. Sends aDocumentEventto all registeredIDocumentListener.- Specified by:
replacein interfaceIDocument- Parameters:
pos- the document offsetlength- the length of the specified rangetext- the substitution text- Throws:
BadLocationException- if the offset is invalid in this document- See Also:
-
set
Description copied from interface:IDocumentReplaces the content of the document with the given text. Sends aDocumentEventto all registeredIDocumentListener. This method is a convenience method forreplace(0, getLength(), text). -
set
Description copied from interface:IDocumentExtension4Replaces the content of the document with the given text. Sends aDocumentEventto all registeredIDocumentListener. This method is a convenience method forreplace(0, getLength(), text).- Specified by:
setin interfaceIDocumentExtension4- Parameters:
text- the new content of the documentmodificationStamp- of the document after setting the content- See Also:
-
updatePositions
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
@Deprecated public int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException Deprecated.as of 3.0 search is provided byFindReplaceDocumentAdapterReturns the offset of a given search string in the document based on a set of search criteria.- Specified by:
searchin interfaceIDocument- Parameters:
startPosition- document offset at which search startsfindString- the string to findforwardSearch- the search directioncaseSensitive- indicates whether lower and upper case should be distinguishedwholeWord- indicates whether the findString should be limited by white spaces as defined by Character.isWhiteSpace- Returns:
- the offset of the first occurrence of findString based on the parameters or -1 if no match is found
- Throws:
BadLocationException- if startOffset is an invalid document offset
-
acceptPostNotificationReplaces
public void acceptPostNotificationReplaces()Description copied from interface:IDocumentExtension2Tells the receiver to accept calls toregisterPostNotificationReplaceuntilignorePostNotificationReplacesis called.- Specified by:
acceptPostNotificationReplacesin interfaceIDocumentExtension2
-
ignorePostNotificationReplaces
public void ignorePostNotificationReplaces()Description copied from interface:IDocumentExtension2Tells the receiver to ignore calls toregisterPostNotificationReplaceuntilacceptPostNotificationReplacesis called.- Specified by:
ignorePostNotificationReplacesin interfaceIDocumentExtension2
-
registerPostNotificationReplace
public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) Description copied from interface:IDocumentExtensionCallback for document listeners to be used insidedocumentChangedto register a post notification replace operation on the document notifying them.- Specified by:
registerPostNotificationReplacein interfaceIDocumentExtension- Parameters:
owner- the owner of the replace operationreplace- the replace operation to be executed
-
stopPostNotificationProcessing
public void stopPostNotificationProcessing()Description copied from interface:IDocumentExtensionStops the processing of registered post notification replace operations untilresumePostNotificationProcessingis called.- Specified by:
stopPostNotificationProcessingin interfaceIDocumentExtension
-
resumePostNotificationProcessing
public void resumePostNotificationProcessing()Description copied from interface:IDocumentExtensionResumes the processing of post notification replace operations. If the queue of registeredIDocumentExtension.IReplaceobjects 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:
resumePostNotificationProcessingin interfaceIDocumentExtension
-
startSequentialRewrite
Deprecated.since 3.1. UseIDocumentExtension4.startRewriteSession(DocumentRewriteSessionType)instead.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. Thenormalizeflag indicates whether the rewrite is performed from the start of the document to its end or from an arbitrary start offset.The document is considered being in sequential rewrite mode as long as
stopSequentialRewritehas not been called.- Specified by:
startSequentialRewritein interfaceIDocumentExtension- Parameters:
normalized-trueif performed from the start to the end of the document- Since:
- 2.0
-
stopSequentialRewrite
Deprecated.As of 3.1, replaced byIDocumentExtension4.stopRewriteSession(DocumentRewriteSession)Tells the document that the sequential rewrite has been finished. This method has only any effect ifstartSequentialRewritehas been called before.- Specified by:
stopSequentialRewritein interfaceIDocumentExtension- Since:
- 2.0
-
resumeListenerNotification
public void resumeListenerNotification()Description copied from interface:IDocumentExtension2Resumes the notification of document listeners which must previously have been stopped by a call tostopListenerNotification.- Specified by:
resumeListenerNotificationin interfaceIDocumentExtension2
-
stopListenerNotification
public void stopListenerNotification()Description copied from interface:IDocumentExtension2Can be called prior to areplaceoperation. After thereplaceresumeListenerNotificationmust be called. The effect of these calls is that no document listener is notified untilresumeListenerNotificationis called. This allows clients to update structure before any listener is informed about the change.Listener notification can only be stopped for a single
replaceoperation. Otherwise, document change notifications will be lost.- Specified by:
stopListenerNotificationin interfaceIDocumentExtension2
-
computePartitioning
public ITypedRegion[] computePartitioning(String partitioning, int offset, int length, boolean includeZeroLengthPartitions) throws BadLocationException, BadPartitioningException Description copied from interface:IDocumentExtension3Computes the partitioning of the given document range based on the given partitioning type.If
includeZeroLengthPartitionsistrue, a zero-length partition of an open partition type (usually the default partition) is included between two closed partitions. If it isfalse, no zero-length partitions are included.This is only supported if the connected
IDocumentPartitionersupports it, i.e. implementsIDocumentPartitionerExtension2. Otherwise,includeZeroLengthPartitionsis ignored.- Specified by:
computePartitioningin interfaceIDocumentExtension3- Parameters:
partitioning- the document's partitioning typeoffset- the document offset at which the range startslength- the length of the document rangeincludeZeroLengthPartitions-trueif zero-length partitions should be returned as part of the computed partitioning- Returns:
- a specification of the range's partitioning
- Throws:
BadLocationException- if the range is invalid in this document$BadPartitioningException- if partitioning is invalid for this document
-
getContentType
public String getContentType(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException Description copied from interface:IDocumentExtension3Returns the type of the document partition containing the given offset for the given partitioning. This is a convenience method forgetPartition(partitioning, offset, boolean).getType().If
preferOpenPartitionsistrue, precedence is given to an open partition ending atoffsetover a delimited partition starting atoffset. If it isfalse, precedence is given to the partition that does not end atoffset.This is only supported if the connected
IDocumentPartitionersupports it, i.e. implementsIDocumentPartitionerExtension2. Otherwise,preferOpenPartitionsis ignored.- Specified by:
getContentTypein interfaceIDocumentExtension3- Parameters:
partitioning- the partitioningoffset- the document offsetpreferOpenPartitions-trueif precedence should be given to a open partition ending atoffsetover a closed partition starting atoffset- Returns:
- the partition type
- Throws:
BadLocationException- if offset is invalid in this documentBadPartitioningException- if partitioning is invalid for this document
-
getDocumentPartitioner
Description copied from interface:IDocumentExtension3Returns the partitioner for the given partitioning ornullif no partitioner is registered.- Specified by:
getDocumentPartitionerin interfaceIDocumentExtension3- Parameters:
partitioning- the partitioning for which to set the partitioner- Returns:
- the partitioner for the given partitioning
-
getLegalContentTypes
Description copied from interface:IDocumentExtension3Returns the set of legal content types of document partitions for the given partitioning This set can be empty. The set can contain more content types than contained by the result ofgetPartitioning(partitioning, 0, getLength()).- Specified by:
getLegalContentTypesin interfaceIDocumentExtension3- Parameters:
partitioning- the partitioning for which to return the legal content types- Returns:
- the set of legal content types
- Throws:
BadPartitioningException- if partitioning is invalid for this document
-
getPartition
public ITypedRegion getPartition(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException Description copied from interface:IDocumentExtension3Returns the document partition of the given partitioning in which the given offset is located.If
preferOpenPartitionsistrue, precedence is given to an open partition ending atoffsetover a delimited partition starting atoffset. If it isfalse, precedence is given to the partition that does not end atoffset.This is only supported if the connected
IDocumentPartitionersupports it, i.e. implementsIDocumentPartitionerExtension2. Otherwise,preferOpenPartitionsis ignored.- Specified by:
getPartitionin interfaceIDocumentExtension3- Parameters:
partitioning- the partitioningoffset- the document offsetpreferOpenPartitions-trueif precedence should be given to a open partition ending atoffsetover a closed partition starting atoffset- Returns:
- a specification of the partition
- Throws:
BadLocationException- if offset is invalid in this documentBadPartitioningException- if partitioning is invalid for this document
-
getPartitionings
Description copied from interface:IDocumentExtension3Returns the existing partitionings for this document. This includes the default partitioning.- Specified by:
getPartitioningsin interfaceIDocumentExtension3- Returns:
- the existing partitionings for this document
-
setDocumentPartitioner
Description copied from interface:IDocumentExtension3Sets 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:
setDocumentPartitionerin interfaceIDocumentExtension3- Parameters:
partitioning- the partitioning for which to set the partitionerpartitioner- the document's new partitioner- See Also:
-
repairLineInformation
public void repairLineInformation()Description copied from interface:IRepairableDocumentRepairs the line information of the document implementing this interface.- Specified by:
repairLineInformationin interfaceIRepairableDocument
-
fireRewriteSessionChanged
Fires the given event to all registered rewrite session listeners. Uses robust iterators.- Parameters:
event- the event to be fired- Since:
- 3.1
-
getActiveRewriteSession
Description copied from interface:IDocumentExtension4Returns the active rewrite session of this document ornull.- Specified by:
getActiveRewriteSessionin interfaceIDocumentExtension4- Returns:
- the active rewrite session or
null
-
startRewriteSession
Description copied from interface:IDocumentExtension4Tells the document that it is about to be rewritten. That is, a sequence of replace operations that form a semantic unit will be performed on this document. A specification of the nature of the operation sequence is given in form of the session type.The document is considered being in rewrite mode as long as
stopRewriteSessionhas not been called.- Specified by:
startRewriteSessionin interfaceIDocumentExtension4- Parameters:
sessionType- the session type- Returns:
- the started rewrite session
-
startRewriteSessionOnPartitioners
Starts the given rewrite session.- Parameters:
session- the rewrite session- Since:
- 3.1
-
stopRewriteSession
Description copied from interface:IDocumentExtension4Tells the document to stop the rewrite session. This method has only any effect ifstartRewriteSessionhas been called before.This method does not have any effect if the given session is not the active rewrite session.
- Specified by:
stopRewriteSessionin interfaceIDocumentExtension4- Parameters:
session- the session to stop
-
stopRewriteSessionOnPartitioners
Stops the given rewrite session.- Parameters:
session- the rewrite session- Since:
- 3.1
-
addDocumentRewriteSessionListener
Description copied from interface:IDocumentExtension4Registers the document rewrite session listener with the document. After registration theIDocumentRewriteSessionListeneris informed about each state change of rewrite sessions performed on this document.If the listener is already registered nothing happens.
An
IRewriteSessionDocumentListenermay call back to this document when being inside a document notification.- Specified by:
addDocumentRewriteSessionListenerin interfaceIDocumentExtension4- Parameters:
listener- the listener to be registered
-
removeDocumentRewriteSessionListener
Description copied from interface:IDocumentExtension4Removes the listener from the document's list of document rewrite session listeners. If the listener is not registered with the document nothing happens.An
IDocumentRewriteSessionListenermay call back to this document when being inside a document notification.- Specified by:
removeDocumentRewriteSessionListenerin interfaceIDocumentExtension4- Parameters:
listener- the listener to be removed
-
checkStateOfPartitioner
Checks the state for the given partitioner and stops the active rewrite session.- Parameters:
partitioner- the document partitioner to be checkedpartitioning- the document partitioning the partitioner is registered for- Since:
- 3.1
-
getPositions
public Position[] getPositions(String category, int offset, int length, boolean canStartBefore, boolean canEndAfter) throws BadPositionCategoryException Returns all positions of the given category that are inside the given region.- Parameters:
category- the position categoryoffset- the start position of the region, must be >= 0length- the length of the region, must be >= 0canStartBefore- iftruethen positions are included which start before the region if they end at or after the regions startcanEndAfter- iftruethen positions are included which end after the region if they start at or before the regions end- Returns:
- all positions inside the region of the given category
- Throws:
BadPositionCategoryException- if category is undefined in this document- Since:
- 3.4
-
computeIndexInPositionList(List, int, boolean)