public abstract class AbstractDocument extends Object implements IDocument, IDocumentExtension, IDocumentExtension2, IDocumentExtension3, IDocumentExtension4, IRepairableDocument, IRepairableDocumentExtension
IDocument
and its extension
interfaces IDocumentExtension
,
IDocumentExtension2
,
IDocumentExtension3
,
IDocumentExtension4
, as well as
IRepairableDocument
.
An AbstractDocument
supports the following implementation
plug-ins:
ITextStore
for
storing and managing the document's content,ILineTracker
to map character positions to line numbers and vice versaThis class must be subclassed. Subclasses must configure which implementation plug-ins the document instance should use. Subclasses are not intended to overwrite existing methods.
ITextStore
,
ILineTracker
IDocumentExtension.IReplace
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE
DEFAULT_PARTITIONING
UNKNOWN_MODIFICATION_STAMP
Modifier | Constructor and Description |
---|---|
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 . |
Modifier and Type | Method and Description |
---|---|
void |
acceptPostNotificationReplaces()
Tells the receiver to accept calls to
registerPostNotificationReplace until
ignorePostNotificationReplaces is called. |
void |
addDocumentListener(IDocumentListener listener)
Registers the document listener with the document.
|
void |
addDocumentPartitioningListener(IDocumentPartitioningListener listener)
Registers the document partitioning listener with the document.
|
void |
addDocumentRewriteSessionListener(IDocumentRewriteSessionListener listener)
Registers the document rewrite session 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 |
checkStateOfPartitioner(IDocumentPartitioner partitioner,
String partitioning)
Checks the state for the given partitioner and stops the
active rewrite session.
|
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)
Deprecated.
As of 3.4, replaced by
computeIndexInPositionList(List, int, boolean) |
protected int |
computeIndexInPositionList(List positions,
int offset,
boolean orderedByOffset)
Computes the index in the list of positions at which a position with the given
position 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.
|
ITypedRegion[] |
computePartitioning(String partitioning,
int offset,
int length,
boolean includeZeroLengthPartitions)
Computes the partitioning of the given document range based on the given
partitioning type.
|
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 |
doFireDocumentChanged(DocumentEvent event)
Notifies all listeners about the given document change.
|
protected void |
doFireDocumentChanged(DocumentEvent event,
boolean firePartitionChange,
IRegion partitionChange)
Deprecated.
as of 3.0. Use
doFireDocumentChanged2(DocumentEvent) instead; this method will be removed. |
protected void |
doFireDocumentChanged2(DocumentEvent event)
Notifies all listeners about the given document change.
|
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
if listener notification has been enabled.
|
protected void |
fireDocumentPartitioningChanged()
Deprecated.
as of 2.0. Use
fireDocumentPartitioningChanged(IRegion) instead. |
protected void |
fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent event)
Fires the document partitioning changed notification to all registered
document partitioning listeners.
|
protected void |
fireDocumentPartitioningChanged(IRegion region)
Deprecated.
as of 3.0. Use
fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent)
instead. |
protected void |
fireRewriteSessionChanged(DocumentRewriteSessionEvent event)
Fires the given event to all registered rewrite session listeners.
|
String |
get()
Returns this document's complete text.
|
String |
get(int pos,
int length)
Returns this document's text for the specified range.
|
DocumentRewriteSession |
getActiveRewriteSession()
Returns the active rewrite session of this document or
null . |
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.
|
String |
getContentType(String partitioning,
int offset,
boolean preferOpenPartitions)
Returns the type of the document partition containing the given offset
for the given partitioning.
|
String |
getDefaultLineDelimiter()
Returns this document's default line delimiter.
|
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.
|
IDocumentPartitioner |
getDocumentPartitioner(String partitioning)
Returns the partitioner for the given partitioning or
null if
no partitioner is registered. |
protected List |
getDocumentPartitioningListeners()
Returns the document's partitioning listeners.
|
String[] |
getLegalContentTypes()
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[] |
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 or
null if the
line is not closed with a line delimiter. |
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.
|
long |
getModificationStamp()
Returns the modification stamp of this document.
|
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.
|
ITypedRegion |
getPartition(String partitioning,
int offset,
boolean preferOpenPartitions)
Returns the document partition of the given partitioning in which the
given offset is located.
|
String[] |
getPartitionings()
Returns the existing partitionings for this document.
|
String[] |
getPositionCategories()
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.
|
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 |
ignorePostNotificationReplaces()
Tells the receiver to ignore calls to
registerPostNotificationReplace until
acceptPostNotificationReplaces is called. |
void |
insertPositionUpdater(IPositionUpdater updater,
int index)
Inserts the position updater at the specified index in the document's
list of position updaters.
|
boolean |
isLineInformationRepairNeeded(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.
|
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 |
removeDocumentRewriteSessionListener(IDocumentRewriteSessionListener listener)
Removes the listener from the document's list of document rewrite session
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
pre-notified document listeners.
|
void |
repairLineInformation()
Repairs the line information of the document implementing this interface.
|
void |
replace(int pos,
int length,
String text)
Substitutes the given text for the specified document range.
|
void |
replace(int pos,
int length,
String text,
long modificationStamp)
Substitutes the given text for the specified document range.
|
void |
resumeListenerNotification()
Resumes the notification of document listeners which must previously
have been stopped by a call to
stopListenerNotification . |
void |
resumePostNotificationProcessing()
Resumes the processing of post notification replace operations.
|
int |
search(int startPosition,
String findString,
boolean forwardSearch,
boolean caseSensitive,
boolean wholeWord)
Deprecated.
as of 3.0 search is provided by
FindReplaceDocumentAdapter |
void |
set(String text)
Replaces the content of the document with the given text.
|
void |
set(String text,
long modificationStamp)
Replaces the content of the document with the given text.
|
void |
setDocumentPartitioner(IDocumentPartitioner partitioner)
Sets this document's partitioner.
|
void |
setDocumentPartitioner(String partitioning,
IDocumentPartitioner partitioner)
Sets this document's partitioner.
|
void |
setInitialLineDelimiter(String lineDelimiter)
Sets this document's initial line delimiter i.e. the one
which is returned by
getDefaultLineDelimiter
if the document does not yet contain any line delimiter. |
protected void |
setLineTracker(ILineTracker tracker)
Sets the document's line tracker.
|
protected void |
setTextStore(ITextStore store)
Sets the document's text store.
|
DocumentRewriteSession |
startRewriteSession(DocumentRewriteSessionType sessionType)
Tells the document that it is about to be rewritten.
|
protected void |
startRewriteSessionOnPartitioners(DocumentRewriteSession session)
Starts the given rewrite session.
|
void |
startSequentialRewrite(boolean normalized)
Deprecated.
since 3.1. Use
IDocumentExtension4.startRewriteSession(DocumentRewriteSessionType)
instead. |
void |
stopListenerNotification()
Can be called prior to a
replace operation. |
void |
stopPostNotificationProcessing()
Stops the processing of registered post notification replace operations until
resumePostNotificationProcessing is called. |
void |
stopRewriteSession(DocumentRewriteSession session)
Tells the document to stop the rewrite session.
|
protected void |
stopRewriteSessionOnPartitioners(DocumentRewriteSession session)
Stops the given rewrite session.
|
void |
stopSequentialRewrite()
Deprecated.
As of 3.1, replaced by
IDocumentExtension4.stopRewriteSession(DocumentRewriteSession) |
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.
|
protected AbstractDocument()
completeInitialization
.
Results in the construction of an empty document.protected ITextStore getStore()
protected ILineTracker getTracker()
protected List getDocumentListeners()
protected List getDocumentPartitioningListeners()
protected Map getDocumentManagedPositions()
public IDocumentPartitioner getDocumentPartitioner()
IDocument
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);
getDocumentPartitioner
in interface IDocument
protected void setTextStore(ITextStore store)
store
- the document's text storeprotected void setLineTracker(ILineTracker tracker)
tracker
- the document's line trackerpublic void setDocumentPartitioner(IDocumentPartitioner partitioner)
IDocument
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);
setDocumentPartitioner
in interface IDocument
partitioner
- the document's new partitionerIDocumentPartitioningListener
protected void completeInitialization()
public void addDocumentListener(IDocumentListener listener)
IDocument
An IDocumentListener
may call back to this method
when being inside a document notification.
addDocumentListener
in interface IDocument
listener
- the listener to be registeredpublic void removeDocumentListener(IDocumentListener listener)
IDocument
An IDocumentListener
may call back to this method
when being inside a document notification.
removeDocumentListener
in interface IDocument
listener
- the listener to be removedpublic void addPrenotifiedDocumentListener(IDocumentListener listener)
IDocument
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.
addPrenotifiedDocumentListener
in interface IDocument
listener
- the listener to be added as pre-notified document listenerIDocument.removePrenotifiedDocumentListener(IDocumentListener)
public void removePrenotifiedDocumentListener(IDocumentListener listener)
IDocument
This method is not for public use.
removePrenotifiedDocumentListener
in interface IDocument
listener
- the listener to be removedIDocument.addPrenotifiedDocumentListener(IDocumentListener)
public void addDocumentPartitioningListener(IDocumentPartitioningListener listener)
IDocument
An IDocumentPartitioningListener
may call back to this method
when being inside a document notification.
addDocumentPartitioningListener
in interface IDocument
listener
- the listener to be addedpublic void removeDocumentPartitioningListener(IDocumentPartitioningListener listener)
IDocument
An IDocumentPartitioningListener
may call back to this method
when being inside a document notification.
removeDocumentPartitioningListener
in interface IDocument
listener
- the listener to be removedpublic void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException
IDocument
Note: The position is only updated on each change
applied to the document if a IPositionUpdater
has been
registered that handles the given category.
addPosition
in interface IDocument
category
- the category to which to addposition
- the position to be addedBadLocationException
- if position describes an invalid range in this documentBadPositionCategoryException
- if the category is undefined in this documentpublic void addPosition(Position position) throws BadLocationException
IDocument
addPosition(DEFAULT_CATEGORY, position)
.addPosition
in interface IDocument
position
- the position to be addedBadLocationException
- if position describes an invalid range in this documentpublic void addPositionCategory(String category)
IDocument
addPositionCategory
in interface IDocument
category
- the category to be addedpublic void addPositionUpdater(IPositionUpdater updater)
IDocument
An IPositionUpdater
may call back to this method
when being inside a document notification.
addPositionUpdater
in interface IDocument
updater
- the updater to be addedpublic boolean containsPosition(String category, int offset, int length)
IDocument
containsPosition
in interface IDocument
category
- the category to checkoffset
- the offset of the position to findlength
- the length of the position to findtrue
if position is foundpublic boolean containsPositionCategory(String category)
IDocument
containsPositionCategory
in interface IDocument
category
- the category to checktrue
if category is definedprotected int computeIndexInPositionList(List positions, int offset)
computeIndexInPositionList(List, int, boolean)
positions
- the list in which the index is computedoffset
- the offset for which the index is computedIDocument.computeIndexInCategory(String, int)
protected int computeIndexInPositionList(List positions, int offset, boolean orderedByOffset)
positions
- the list in which the index is computedoffset
- the offset for which the index is computedorderedByOffset
- true
if ordered by offset, false if ordered by end positionpublic int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException
IDocument
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
chosen to be the first of all positions with the same offset.computeIndexInCategory
in interface IDocument
category
- the category in which would be addedoffset
- the position offset to be consideredBadLocationException
- if offset is invalid in this documentBadPositionCategoryException
- if category is undefined in this documentprotected void fireDocumentPartitioningChanged()
fireDocumentPartitioningChanged(IRegion)
instead.protected void fireDocumentPartitioningChanged(IRegion region)
fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent)
instead.region
- the region in which partitioning has changedIDocumentPartitioningListenerExtension
protected void fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent event)
event
- the document partitioning changed eventIDocumentPartitioningListenerExtension2
protected void fireDocumentAboutToBeChanged(DocumentEvent event)
event
- the event to be sent outprotected void updateDocumentStructures(DocumentEvent event)
event
- the document event describing the change to which structures must be adaptedprotected void doFireDocumentChanged(DocumentEvent event)
Executes all registered post notification replace operation.
event
- the event to be sent out.protected void doFireDocumentChanged(DocumentEvent event, boolean firePartitionChange, IRegion partitionChange)
doFireDocumentChanged2(DocumentEvent)
instead; this method will be removed.Executes all registered post notification replace operation.
event
- the event to be sent outfirePartitionChange
- true
if a partition change notification should be sentpartitionChange
- the region whose partitioning changedprotected void doFireDocumentChanged2(DocumentEvent event)
Executes all registered post notification replace operation.
This method will be renamed to doFireDocumentChanged
.
event
- the event to be sent outprotected void fireDocumentChanged(DocumentEvent event)
event
- the document event to be sent outpublic char getChar(int pos) throws BadLocationException
IDocument
getChar
in interface IDocument
pos
- a document offsetBadLocationException
- if the offset is invalid in this documentpublic String getContentType(int offset) throws BadLocationException
IDocument
getPartition(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);
getContentType
in interface IDocument
offset
- the document offsetBadLocationException
- if offset is invalid in this documentpublic String[] getLegalContentTypes()
IDocument
getPartitioning(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);
getLegalContentTypes
in interface IDocument
public int getLength()
IDocument
public String getLineDelimiter(int line) throws BadLocationException
IDocument
null
if the
line is not closed with a line delimiter.getLineDelimiter
in interface IDocument
line
- the line of interestnull
if line does not have a delimiterBadLocationException
- if the line number is invalid in this documentpublic String[] getLegalLineDelimiters()
IDocument
getLegalLineDelimiters
in interface IDocument
public String getDefaultLineDelimiter()
IDocumentExtension4
This default line delimiter should be used by clients who want unique delimiters (e.g. 'CR's) in the document.
getDefaultLineDelimiter
in interface IDocumentExtension4
null
if nonepublic void setInitialLineDelimiter(String lineDelimiter)
IDocumentExtension4
getDefaultLineDelimiter
if the document does not yet contain any line delimiter.setInitialLineDelimiter
in interface IDocumentExtension4
lineDelimiter
- the default line delimiterpublic int getLineLength(int line) throws BadLocationException
IDocument
getLineLength
in interface IDocument
line
- the line of interestBadLocationException
- if the line number is invalid in this documentpublic int getLineOfOffset(int pos) throws BadLocationException
IDocument
(offset == document length)
is a valid argument although there is no
corresponding character.getLineOfOffset
in interface IDocument
pos
- the document offsetBadLocationException
- if the offset is invalid in this documentpublic int getLineOffset(int line) throws BadLocationException
IDocument
getLineOffset
in interface IDocument
line
- the line of interestBadLocationException
- if the line number is invalid in this documentpublic IRegion getLineInformation(int line) throws BadLocationException
IDocument
getLineInformation
in interface IDocument
line
- the line of interestBadLocationException
- if the line number is invalid in this documentpublic IRegion getLineInformationOfOffset(int offset) throws BadLocationException
IDocument
getLineInformationOfOffset
in interface IDocument
offset
- the offset whose line should be describedBadLocationException
- if offset is invalid in this documentpublic int getNumberOfLines()
IDocument
getNumberOfLines
in interface IDocument
public int getNumberOfLines(int offset, int length) throws BadLocationException
IDocument
getNumberOfLines
in interface IDocument
offset
- the offset of the specified text rangelength
- the length of the specified text rangeBadLocationException
- if specified range is invalid in this trackerpublic int computeNumberOfLines(String text)
IDocument
set(text); getNumberOfLines()
.computeNumberOfLines
in interface IDocument
text
- the text whose number of lines should be computedpublic ITypedRegion getPartition(int offset) throws BadLocationException
IDocument
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);
getPartition
in interface IDocument
offset
- the document offsetBadLocationException
- if offset is invalid in this documentpublic ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException
IDocument
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);
computePartitioning
in interface IDocument
offset
- the document offset at which the range startslength
- the length of the document rangeBadLocationException
- if the range is invalid in this documentpublic Position[] getPositions(String category) throws BadPositionCategoryException
IDocument
getPositions
in interface IDocument
category
- the categoryBadPositionCategoryException
- if category is undefined in this documentpublic String[] getPositionCategories()
IDocument
getPositionCategories
in interface IDocument
public IPositionUpdater[] getPositionUpdaters()
IDocument
getPositionUpdaters
in interface IDocument
public String get()
IDocument
public String get(int pos, int length) throws BadLocationException
IDocument
get
in interface IDocument
pos
- the document offsetlength
- the length of the specified rangeBadLocationException
- if the range is invalid in this documentpublic void insertPositionUpdater(IPositionUpdater updater, int index)
IDocument
An IPositionUpdater
may call back to this method
when being inside a document notification.
insertPositionUpdater
in interface IDocument
updater
- the updater to be insertedindex
- the index in the document's updater listpublic void removePosition(String category, Position position) throws BadPositionCategoryException
IDocument
removePosition
in interface IDocument
category
- the category from which to deleteposition
- the position to be deletedBadPositionCategoryException
- if category is undefined in this documentpublic void removePosition(Position position)
IDocument
removePosition(DEFAULT_CATEGORY, position)
.removePosition
in interface IDocument
position
- the position to be removedpublic void removePositionCategory(String category) throws BadPositionCategoryException
IDocument
removePositionCategory
in interface IDocument
category
- the category to be removedBadPositionCategoryException
- if category is undefined in this documentpublic void removePositionUpdater(IPositionUpdater updater)
IDocument
An IPositionUpdater
may call back to this method
when being inside a document notification.
removePositionUpdater
in interface IDocument
updater
- the updater to be removedpublic long getModificationStamp()
IDocumentExtension4
The magnitude or sign of the numerical difference between two modification stamps is not significant.
getModificationStamp
in interface IDocumentExtension4
UNKNOWN_MODIFICATION_STAMP
public void replace(int pos, int length, String text, long modificationStamp) throws BadLocationException
IDocumentExtension4
DocumentEvent
to all registered IDocumentListener
.replace
in interface IDocumentExtension4
pos
- the document offsetlength
- the length of the specified rangetext
- the substitution textmodificationStamp
- of the document after replacingBadLocationException
- if the offset is invalid in this documentDocumentEvent
,
IDocumentListener
public boolean isLineInformationRepairNeeded(int offset, int length, String text) throws BadLocationException
isLineInformationRepairNeeded
in interface IRepairableDocumentExtension
offset
- the document offsetlength
- the length of the specified rangetext
- the substitution text to checktrue
if the line information must be repaired after replacingBadLocationException
- if the offset is invalid in this documentIRepairableDocument.repairLineInformation()
public void replace(int pos, int length, String text) throws BadLocationException
IDocument
DocumentEvent
to all registered IDocumentListener
.replace
in interface IDocument
pos
- the document offsetlength
- the length of the specified rangetext
- the substitution textBadLocationException
- if the offset is invalid in this documentDocumentEvent
,
IDocumentListener
public void set(String text)
IDocument
DocumentEvent
to all registered IDocumentListener
.
This method is a convenience method for replace(0, getLength(), text)
.set
in interface IDocument
text
- the new content of the documentDocumentEvent
,
IDocumentListener
public void set(String text, long modificationStamp)
IDocumentExtension4
DocumentEvent
to all registered IDocumentListener
.
This method is a convenience method for replace(0, getLength(), text)
.set
in interface IDocumentExtension4
text
- the new content of the documentmodificationStamp
- of the document after setting the contentDocumentEvent
,
IDocumentListener
protected void updatePositions(DocumentEvent event)
event
- the document event describing the change to which to adapt
the positionspublic int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException
FindReplaceDocumentAdapter
search
in interface IDocument
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.isWhiteSpaceBadLocationException
- if startOffset is an invalid document offsetpublic void acceptPostNotificationReplaces()
IDocumentExtension2
registerPostNotificationReplace
until
ignorePostNotificationReplaces
is called.acceptPostNotificationReplaces
in interface IDocumentExtension2
public void ignorePostNotificationReplaces()
IDocumentExtension2
registerPostNotificationReplace
until
acceptPostNotificationReplaces
is called.ignorePostNotificationReplaces
in interface IDocumentExtension2
public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace)
IDocumentExtension
documentChanged
to register a post notification replace operation on the document notifying them.registerPostNotificationReplace
in interface IDocumentExtension
owner
- the owner of the replace operationreplace
- the replace operation to be executedpublic void stopPostNotificationProcessing()
IDocumentExtension
resumePostNotificationProcessing
is called.stopPostNotificationProcessing
in interface IDocumentExtension
public void resumePostNotificationProcessing()
IDocumentExtension
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.resumePostNotificationProcessing
in interface IDocumentExtension
public void startSequentialRewrite(boolean normalized)
IDocumentExtension4.startRewriteSession(DocumentRewriteSessionType)
instead.normalize
flag 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
stopSequentialRewrite
has not been called.
startSequentialRewrite
in interface IDocumentExtension
normalized
- true
if performed from the start to the end of the documentpublic void stopSequentialRewrite()
IDocumentExtension4.stopRewriteSession(DocumentRewriteSession)
startSequentialRewrite
has been called before.stopSequentialRewrite
in interface IDocumentExtension
public void resumeListenerNotification()
IDocumentExtension2
stopListenerNotification
.resumeListenerNotification
in interface IDocumentExtension2
public void stopListenerNotification()
IDocumentExtension2
replace
operation. After the
replace
resumeListenerNotification
must be
called. The effect of these calls is that no document listener is notified
until resumeListenerNotification
is called. This allows clients
to update structure before any listener is informed about the change.
Listener notification can only be stopped for a single replace
operation.
Otherwise, document change notifications will be lost.
stopListenerNotification
in interface IDocumentExtension2
public ITypedRegion[] computePartitioning(String partitioning, int offset, int length, boolean includeZeroLengthPartitions) throws BadLocationException, BadPartitioningException
IDocumentExtension3
If includeZeroLengthPartitions
is true
, a
zero-length partition of an open partition type (usually the default
partition) is included between two closed partitions. If it is
false
, no zero-length partitions are included.
IDocumentPartitioner
supports it, i.e. implements IDocumentPartitionerExtension2
.
Otherwise, includeZeroLengthPartitions
is ignored.
computePartitioning
in interface IDocumentExtension3
partitioning
- the document's partitioning typeoffset
- the document offset at which the range startslength
- the length of the document rangeincludeZeroLengthPartitions
- true
if zero-length
partitions should be returned as part of the computed partitioningBadLocationException
- if the range is invalid in this document$BadPartitioningException
- if partitioning is invalid for this documentpublic String getContentType(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException
IDocumentExtension3
getPartition(partitioning, offset, boolean).getType()
.
If preferOpenPartitions
is true
,
precedence is given to an open partition ending at offset
over a delimited partition starting at offset
. If it is
false
, precedence is given to the partition that does not
end at offset
.
IDocumentPartitioner
supports it, i.e. implements IDocumentPartitionerExtension2
.
Otherwise, preferOpenPartitions
is ignored.
getContentType
in interface IDocumentExtension3
partitioning
- the partitioningoffset
- the document offsetpreferOpenPartitions
- true
if precedence should be
given to a open partition ending at offset
over a
closed partition starting at offset
BadLocationException
- if offset is invalid in this documentBadPartitioningException
- if partitioning is invalid for this documentpublic IDocumentPartitioner getDocumentPartitioner(String partitioning)
IDocumentExtension3
null
if
no partitioner is registered.getDocumentPartitioner
in interface IDocumentExtension3
partitioning
- the partitioning for which to set the partitionerpublic String[] getLegalContentTypes(String partitioning) throws BadPartitioningException
IDocumentExtension3
getPartitioning(partitioning, 0, getLength())
.getLegalContentTypes
in interface IDocumentExtension3
partitioning
- the partitioning for which to return the legal content typesBadPartitioningException
- if partitioning is invalid for this documentpublic ITypedRegion getPartition(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException
IDocumentExtension3
If preferOpenPartitions
is true
,
precedence is given to an open partition ending at offset
over a delimited partition starting at offset
. If it is
false
, precedence is given to the partition that does not
end at offset
.
IDocumentPartitioner
supports it, i.e. implements IDocumentPartitionerExtension2
.
Otherwise, preferOpenPartitions
is ignored.
getPartition
in interface IDocumentExtension3
partitioning
- the partitioningoffset
- the document offsetpreferOpenPartitions
- true
if precedence should be
given to a open partition ending at offset
over a
closed partition starting at offset
BadLocationException
- if offset is invalid in this documentBadPartitioningException
- if partitioning is invalid for this documentpublic String[] getPartitionings()
IDocumentExtension3
getPartitionings
in interface IDocumentExtension3
public void setDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner)
IDocumentExtension3
setDocumentPartitioner
in interface IDocumentExtension3
partitioning
- the partitioning for which to set the partitionerpartitioner
- the document's new partitionerIDocumentPartitioningListener
public void repairLineInformation()
IRepairableDocument
repairLineInformation
in interface IRepairableDocument
protected void fireRewriteSessionChanged(DocumentRewriteSessionEvent event)
event
- the event to be firedpublic final DocumentRewriteSession getActiveRewriteSession()
IDocumentExtension4
null
.getActiveRewriteSession
in interface IDocumentExtension4
null
public DocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType)
IDocumentExtension4
The document is considered being in rewrite mode as long as
stopRewriteSession
has not been called.
startRewriteSession
in interface IDocumentExtension4
sessionType
- the session typeprotected final void startRewriteSessionOnPartitioners(DocumentRewriteSession session)
session
- the rewrite sessionpublic void stopRewriteSession(DocumentRewriteSession session)
IDocumentExtension4
startRewriteSession
has been called before.
This method does not have any effect if the given session is not the active rewrite session.
stopRewriteSession
in interface IDocumentExtension4
session
- the session to stopprotected final void stopRewriteSessionOnPartitioners(DocumentRewriteSession session)
session
- the rewrite sessionpublic void addDocumentRewriteSessionListener(IDocumentRewriteSessionListener listener)
IDocumentExtension4
IDocumentRewriteSessionListener
is
informed about each state change of rewrite sessions performed on this
document.
If the listener is already registered nothing happens.
An IRewriteSessionDocumentListener
may call back to this
document when being inside a document notification.
addDocumentRewriteSessionListener
in interface IDocumentExtension4
listener
- the listener to be registeredpublic void removeDocumentRewriteSessionListener(IDocumentRewriteSessionListener listener)
IDocumentExtension4
An IDocumentRewriteSessionListener
may call back to this
document when being inside a document notification.
removeDocumentRewriteSessionListener
in interface IDocumentExtension4
listener
- the listener to be removedprotected final void checkStateOfPartitioner(IDocumentPartitioner partitioner, String partitioning)
partitioner
- the document partitioner to be checkedpartitioning
- the document partitioning the partitioner is registered forpublic Position[] getPositions(String category, int offset, int length, boolean canStartBefore, boolean canEndAfter) throws BadPositionCategoryException
category
- the position categoryoffset
- the start position of the region, must be >= 0length
- the length of the region, must be >= 0canStartBefore
- if true
then positions are included
which start before the region if they end at or after the regions startcanEndAfter
- if true
then positions are included
which end after the region if they start at or before the regions endBadPositionCategoryException
- if category is undefined in this document
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.