|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.jface.text.AbstractDocument
Abstract implementation of IDocument
.
Implements the complete contract of IDocument
and IDocumentExtension
.
An AbstractDocument
supports the following implementation plug-ins:
IDocument
,
ITextStore
,
ILineTracker
Nested Class Summary |
Nested classes inherited from class org.eclipse.jface.text.IDocumentExtension |
IDocumentExtension.IReplace |
Field Summary |
Fields inherited from interface org.eclipse.jface.text.IDocument |
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE |
Constructor Summary | |
protected |
AbstractDocument()
The default constructor does not perform any configuration but leaves it to the clients who must first initialize the implementation plug-ins and then call completeInitialization . |
Method Summary | |
void |
addDocumentListener(IDocumentListener listener)
Registers the document listener with the document. |
void |
addDocumentPartitioningListener(IDocumentPartitioningListener listener)
Registers the document partitioning listener with the document. |
void |
addPosition(Position position)
Adds the position to the document's default position category. |
void |
addPosition(String category,
Position position)
Adds the position to the specified position category of the document. |
void |
addPositionCategory(String category)
Adds a new position category to the document. |
void |
addPositionUpdater(IPositionUpdater updater)
Appends a new position updater to the document's list of position updaters. |
void |
addPrenotifiedDocumentListener(IDocumentListener listener)
Adds the given document listener as one which is notified before those document listeners added with addDocumentListener
are notified. |
protected void |
completeInitialization()
Initializes document listeners, positions, and position updaters. |
int |
computeIndexInCategory(String category,
int offset)
Computes the index at which a Position with the
specified offset would be inserted into the given category. |
protected int |
computeIndexInPositionList(List positions,
int offset)
Computes the index in the list of positions at which a position with the given offset would be inserted. |
int |
computeNumberOfLines(String text)
Computes the number of lines in the given text. |
ITypedRegion[] |
computePartitioning(int offset,
int length)
Computes the partitioning of the given document range using the document's partitioner. |
boolean |
containsPosition(String category,
int offset,
int length)
Determines whether a position described by the parameters is managed by this document. |
boolean |
containsPositionCategory(String category)
Checks the presence of the specified position category. |
protected void |
fireDocumentAboutToBeChanged(DocumentEvent event)
Fires the given document event to all registers document listeners informing them about the forthcoming document manipulation. |
protected void |
fireDocumentChanged(DocumentEvent event)
Updates the internal document structures and informs all document listeners. |
protected void |
fireDocumentPartitioningChanged()
Deprecated. use fireDocumentPartitioningChanged(IRegion) instead |
protected void |
fireDocumentPartitioningChanged(IRegion region)
Fires the document partitioning changed notification to all registered document partitioning listeners. |
String |
get()
Returns this document's complete text. |
String |
get(int pos,
int length)
Returns this document's text for the specified range. |
char |
getChar(int pos)
Returns the character at the given document offset in this document. |
String |
getContentType(int offset)
Returns the type of the document partition containing the given offset. |
protected List |
getDocumentListeners()
Returns the document's document listeners. |
protected Map |
getDocumentManagedPositions()
Returns all positions managed by the document grouped by category. |
IDocumentPartitioner |
getDocumentPartitioner()
Returns this document's partitioner. |
protected List |
getDocumentPartitioningListeners()
Returns the document's partitioning listeners . |
String[] |
getLegalContentTypes()
Returns the set of legal content types of document partitions. |
String[] |
getLegalLineDelimiters()
Returns the document's legal line delimiters. |
int |
getLength()
Returns the number of characters in this document. |
String |
getLineDelimiter(int line)
Returns the line delimiter of that line. |
IRegion |
getLineInformation(int line)
Returns a description of the specified line. |
IRegion |
getLineInformationOfOffset(int offset)
Returns a description of the line at the given offset. |
int |
getLineLength(int line)
Returns the length of the given line including the line's delimiter. |
int |
getLineOffset(int line)
Determines the offset of the first character of the given line. |
int |
getLineOfOffset(int pos)
Returns the number of the line at which the character of the specified position is located. |
int |
getNumberOfLines()
Returns the number of lines in this document |
int |
getNumberOfLines(int offset,
int length)
Returns the number of lines which are occupied by a given text range. |
ITypedRegion |
getPartition(int offset)
Returns the document partition in which the position is located. |
String[] |
getPositionCategories()
Returns all position categories of this document. |
Position[] |
getPositions(String category)
Returns all positions of the given position category. |
IPositionUpdater[] |
getPositionUpdaters()
Returns the list of position updaters attached to the document. |
protected ITextStore |
getStore()
Returns the document's text store. |
protected ILineTracker |
getTracker()
Returns the document's line tracker. |
void |
insertPositionUpdater(IPositionUpdater updater,
int index)
Inserts the position updater at the specified index in the document's list of position updaters. |
void |
registerPostNotificationReplace(IDocumentListener owner,
IDocumentExtension.IReplace replace)
Callback for document listeners to be used inside documentChanged
to register a post notification replace operation on the document notifying them. |
void |
removeDocumentListener(IDocumentListener listener)
Removes the listener from the document's list of document listeners. |
void |
removeDocumentPartitioningListener(IDocumentPartitioningListener listener)
Removes the listener from this document's list of document partitioning listeners. |
void |
removePosition(Position position)
Removes the given position from the document's default position category. |
void |
removePosition(String category,
Position position)
Removes the given position from the specified position category. |
void |
removePositionCategory(String category)
Deletes the position category from the document. |
void |
removePositionUpdater(IPositionUpdater updater)
Removes the position updater from the document's list of position updaters. |
void |
removePrenotifiedDocumentListener(IDocumentListener listener)
Removes the given document listener from the document's list of prenotified document listeners. |
void |
replace(int pos,
int length,
String text)
Subsitutes the given text for the specified document range. |
void |
resumePostNotificationProcessing()
Resumes the processing of post notification replace operations. |
int |
search(int startPosition,
String findString,
boolean forwardSearch,
boolean caseSensitive,
boolean wholeWord)
Returns the offset of a given search string in the document based on a set of search criteria. |
void |
set(String text)
Replaces the content of the document with the given text. |
void |
setDocumentPartitioner(IDocumentPartitioner partitioner)
Sets this document's partitioner. |
protected void |
setLineTracker(ILineTracker tracker)
Sets the document's line tracker. |
protected void |
setTextStore(ITextStore store)
Sets the document's text store. |
void |
startSequentialRewrite(boolean normalized)
Tells the document that it is about to be sequentially rewritten. |
void |
stopPostNotificationProcessing()
Stops the processing of registered post notification replace operations until resumePostNotificationProcessing is called. |
void |
stopSequentialRewrite()
Tells the document that the sequential rewrite has been finished. |
protected void |
updateDocumentStructures(DocumentEvent event)
Updates document partitioning and document positions according to the specification given by the document event. |
protected void |
updatePositions(DocumentEvent event)
Updates all positions of all categories to the change described by the document event. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected AbstractDocument()
completeInitialization
.
Results in the construction of an empty document.
Method Detail |
protected ITextStore getStore()
protected ILineTracker getTracker()
protected List getDocumentListeners()
protected List getDocumentPartitioningListeners()
protected Map getDocumentManagedPositions()
public IDocumentPartitioner getDocumentPartitioner()
IDocument
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
setDocumentPartitioner
in interface IDocument
IDocumentPartitioningListener
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, it may only be called by
implementers of IDocumentAdapter
and only if those
implementers need to implement IDocumentListener
.
addPrenotifiedDocumentListener
in interface IDocument
listener
- the listener to be added as prenotified document listenerpublic void removePrenotifiedDocumentListener(IDocumentListener listener)
IDocument
This method is not for public use, it may only be called by
implementers of IDocumentAdapter
and only if those
implementers need to implement IDocumentListener
.
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
addPosition
in interface IDocument
category
- the category to which to addposition
- the position to be added
BadPositionCategoryException
- if the category is undefined in this document
BadLocationException
- if position describes an invalid range in this documentpublic void addPosition(Position position) throws BadLocationException
IDocument
addPosition(DEFAULT_CATEGORY, position)
.
addPosition
in interface IDocument
position
- the position to be added
BadLocationException
- 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 find
true
if position is foundpublic boolean containsPositionCategory(String category)
IDocument
containsPositionCategory
in interface IDocument
category
- the category to check
true
if category is definedprotected int computeIndexInPositionList(List positions, int offset)
positions
- the list in which the index is computedoffset
- the offset for which the index is computed
IDocument.computeIndexInCategory(String, int)
public 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
choosen 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 considered
BadPositionCategoryException
- if category is undefined in this document
BadLocationException
- if offset is invalid in this documentprotected void fireDocumentPartitioningChanged()
fireDocumentPartitioningChanged(IRegion)
instead
protected void fireDocumentPartitioningChanged(IRegion region)
region
- the region in which partitioning has changedIDocumentPartitioningListenerExtension
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 fireDocumentChanged(DocumentEvent event)
Executes all registered post notification replace operation.
event
- the document event to be sent outIDocumentExtension
public char getChar(int pos) throws BadLocationException
IDocument
getChar
in interface IDocument
pos
- a document offset
BadLocationException
- if the offset is invalid in this documentpublic String getContentType(int offset) throws BadLocationException
IDocument
getPartition(offset).getType()
.
getContentType
in interface IDocument
offset
- the document offset
BadLocationException
- if offset is invalid in this documentpublic String[] getLegalContentTypes()
IDocument
getPartitioning(0, getLength())
.
getLegalContentTypes
in interface IDocument
public int getLength()
IDocument
getLength
in interface IDocument
public String getLineDelimiter(int line) throws BadLocationException
IDocument
getLineDelimiter
in interface IDocument
line
- the line of interest
BadLocationException
- if the line number is invalid in this documentpublic String[] getLegalLineDelimiters()
IDocument
getLegalLineDelimiters
in interface IDocument
public int getLineLength(int line) throws BadLocationException
IDocument
getLineLength
in interface IDocument
line
- the line of interest
BadLocationException
- if the line number is invalid in this documentpublic int getLineOfOffset(int pos) throws BadLocationException
IDocument
(pos == document length)
is a valid argument also there is no
corresponding character.
getLineOfOffset
in interface IDocument
pos
- the document offset
BadLocationException
- if the offset is invalid in this documentpublic int getLineOffset(int line) throws BadLocationException
IDocument
getLineOffset
in interface IDocument
line
- the line of interest
BadLocationException
- if the line number is invalid in this documentpublic IRegion getLineInformation(int line) throws BadLocationException
IDocument
getLineInformation
in interface IDocument
line
- the line of interest
BadLocationException
- 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 described
BadLocationException
- 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 range
BadLocationException
- 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 computed
public ITypedRegion getPartition(int offset) throws BadLocationException
IDocument
getPartition
in interface IDocument
offset
- the document offset
BadLocationException
- if offset is invalid in this documentpublic ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException
IDocument
computePartitioning
in interface IDocument
offset
- the document offset at which the range startslength
- the length of the document range
BadLocationException
- if the range is invalid in this documentpublic Position[] getPositions(String category) throws BadPositionCategoryException
IDocument
getPositions
in interface IDocument
category
- the category
BadPositionCategoryException
- 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
get
in interface IDocument
public String get(int pos, int length) throws BadLocationException
IDocument
get
in interface IDocument
pos
- the document offsetlength
- the length of the specified range
BadLocationException
- 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 deleted
BadPositionCategoryException
- 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 removed
BadPositionCategoryException
- 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 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 text
BadLocationException
- 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
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
IDocument
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.isWhiteSpace
BadLocationException
- if startOffset is an invalid document offsetpublic 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 operationpublic 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)
IDocumentExtension
normalize
flag indicates whether the rewrite is preformed from
the start of the document to its end or from an arbitrary start offset.
startSequentialRewrite
in interface IDocumentExtension
normalized
- true
if performed from the start to the end of the documentpublic void stopSequentialRewrite()
IDocumentExtension
stopSequentialRewrite
in interface IDocumentExtension
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |