Class AbstractDocument

    • Constructor Detail

      • AbstractDocument

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

      • getStore

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

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

        protected List<IDocumentListener> getDocumentListeners()
        Returns the document's document listeners.
        Returns:
        the document's document listeners
      • getDocumentPartitioningListeners

        protected List<IDocumentPartitioningListener> getDocumentPartitioningListeners()
        Returns the document's partitioning listeners.
        Returns:
        the document's partitioning listeners
      • getDocumentManagedPositions

        protected Map<String,​List<Position>> getDocumentManagedPositions()
        Returns all positions managed by the document grouped by category.
        Returns:
        the document's positions
      • getDocumentPartitioner

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

        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:
        getDocumentPartitioner in interface IDocument
        Returns:
        this document's partitioner
      • setTextStore

        protected void setTextStore​(ITextStore store)
        Sets the document's text store. Must be called at the beginning of the constructor.
        Parameters:
        store - the document's text store
      • setLineTracker

        protected void setLineTracker​(ILineTracker tracker)
        Sets the document's line tracker. Must be called at the beginning of the constructor.
        Parameters:
        tracker - the document's line tracker
      • setDocumentPartitioner

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

        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:
        setDocumentPartitioner in interface IDocument
        Parameters:
        partitioner - the document's new partitioner
        See Also:
        IDocumentPartitioningListener
      • completeInitialization

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

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

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

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

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

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

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

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

        This method is not for public use.

        Specified by:
        addPrenotifiedDocumentListener in interface IDocument
        Parameters:
        listener - the listener to be added as pre-notified document listener
        See Also:
        IDocument.removePrenotifiedDocumentListener(IDocumentListener)
      • addDocumentPartitioningListener

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

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

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

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

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

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

        public void addPosition​(String category,
                                Position position)
                         throws BadLocationException,
                                BadPositionCategoryException
        Description copied from interface: IDocument
        Adds the position to the specified position category of the document. 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 IPositionUpdater has been registered that handles the given category.

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

        public void addPosition​(Position position)
                         throws BadLocationException
        Description copied from interface: IDocument
        Adds the position to the document's default position category. This is a convenience method for addPosition(DEFAULT_CATEGORY, position).
        Specified by:
        addPosition in interface IDocument
        Parameters:
        position - the position to be added
        Throws:
        BadLocationException - if position describes an invalid range in this document
      • addPositionCategory

        public void addPositionCategory​(String category)
        Description copied from interface: IDocument
        Adds a new position category to the document. If the position category already exists nothing happens.
        Specified by:
        addPositionCategory in interface IDocument
        Parameters:
        category - the category to be added
      • addPositionUpdater

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

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

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

        public boolean containsPosition​(String category,
                                        int offset,
                                        int length)
        Description copied from interface: IDocument
        Determines whether a position described by the parameters is managed by this document.
        Specified by:
        containsPosition in interface IDocument
        Parameters:
        category - the category to check
        offset - the offset of the position to find
        length - the length of the position to find
        Returns:
        true if position is found
      • containsPositionCategory

        public boolean containsPositionCategory​(String category)
        Description copied from interface: IDocument
        Checks the presence of the specified position category.
        Specified by:
        containsPositionCategory in interface IDocument
        Parameters:
        category - the category to check
        Returns:
        true if category is defined
      • computeIndexInPositionList

        @Deprecated
        protected int computeIndexInPositionList​(List<? extends Position> positions,
                                                 int offset)
        Deprecated.
        Computes the index in the list of positions at which a position with the given offset would be inserted. The position is supposed to become the first in this list of all positions with the same offset.
        Parameters:
        positions - the list in which the index is computed
        offset - the offset for which the index is computed
        Returns:
        the computed index
        See Also:
        IDocument.computeIndexInCategory(String, int)
      • 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 computed
        offset - the offset for which the index is computed
        orderedByOffset - true if 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: IDocument
        Computes the index at which a Position with the specified offset would be inserted into the given category. As the ordering inside a category only depends on the offset, the index must be chosen to be the first of all positions with the same offset.
        Specified by:
        computeIndexInCategory in interface IDocument
        Parameters:
        category - the category in which would be added
        offset - the position offset to be considered
        Returns:
        the index into the category
        Throws:
        BadLocationException - if offset is invalid in this document
        BadPositionCategoryException - if category is undefined in this document
      • fireDocumentPartitioningChanged

        @Deprecated
        protected void fireDocumentPartitioningChanged()
        Deprecated.
        as of 2.0. Use fireDocumentPartitioningChanged(IRegion) instead.
        Fires the document partitioning changed notification to all registered document partitioning listeners. Uses a robust iterator.
      • fireDocumentPartitioningChanged

        @Deprecated
        protected void fireDocumentPartitioningChanged​(IRegion region)
        Deprecated.
        as of 3.0. Use fireDocumentPartitioningChanged(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:
        IDocumentPartitioningListenerExtension
      • fireDocumentPartitioningChanged

        protected void fireDocumentPartitioningChanged​(DocumentPartitioningChangedEvent event)
        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:
        IDocumentPartitioningListenerExtension2
      • fireDocumentAboutToBeChanged

        protected void fireDocumentAboutToBeChanged​(DocumentEvent event)
        Fires the given document event to all registers document listeners informing them about the forthcoming document manipulation. Uses a robust iterator.
        Parameters:
        event - the event to be sent out
      • updateDocumentStructures

        protected void updateDocumentStructures​(DocumentEvent event)
        Updates document partitioning and document positions according to the specification given by the document event.
        Parameters:
        event - the document event describing the change to which structures must be adapted
      • doFireDocumentChanged

        protected void doFireDocumentChanged​(DocumentEvent event)
        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. Use doFireDocumentChanged2(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 out
        firePartitionChange - true if a partition change notification should be sent
        partitionChange - the region whose partitioning changed
        Since:
        2.0
      • doFireDocumentChanged2

        protected void doFireDocumentChanged2​(DocumentEvent event)
        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

        protected void fireDocumentChanged​(DocumentEvent event)
        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

        public char getChar​(int pos)
                     throws BadLocationException
        Description copied from interface: IDocument
        Returns the character at the given document offset in this document.
        Specified by:
        getChar in interface IDocument
        Parameters:
        pos - a document offset
        Returns:
        the character at the offset
        Throws:
        BadLocationException - if the offset is invalid in this document
      • getContentType

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

        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:
        getContentType in interface IDocument
        Parameters:
        offset - the document offset
        Returns:
        the partition type
        Throws:
        BadLocationException - if offset is invalid in this document
      • getLegalContentTypes

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

        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:
        getLegalContentTypes in interface IDocument
        Returns:
        the set of legal content types
      • getLength

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

        public String getLineDelimiter​(int line)
                                throws BadLocationException
        Description copied from interface: IDocument
        Returns the line delimiter of that line or null if the line is not closed with a line delimiter.
        Specified by:
        getLineDelimiter in interface IDocument
        Parameters:
        line - the line of interest
        Returns:
        the line's delimiter or null if line does not have a delimiter
        Throws:
        BadLocationException - if the line number is invalid in this document
      • getLegalLineDelimiters

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

        public String getDefaultLineDelimiter()
        Description copied from interface: IDocumentExtension4
        Returns 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:
        getDefaultLineDelimiter in interface IDocumentExtension4
        Returns:
        the default line delimiter or null if none
      • setInitialLineDelimiter

        public void setInitialLineDelimiter​(String lineDelimiter)
        Description copied from interface: IDocumentExtension4
        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.
        Specified by:
        setInitialLineDelimiter in interface IDocumentExtension4
        Parameters:
        lineDelimiter - the default line delimiter
      • getLineLength

        public int getLineLength​(int line)
                          throws BadLocationException
        Description copied from interface: IDocument
        Returns the length of the given line including the line's delimiter.
        Specified by:
        getLineLength in interface IDocument
        Parameters:
        line - the line of interest
        Returns:
        the length of the line
        Throws:
        BadLocationException - if the line number is invalid in this document
      • getLineOfOffset

        public int getLineOfOffset​(int pos)
                            throws BadLocationException
        Description copied from interface: IDocument
        Returns the number of the line at which the character of the specified position is located. The first line has the line number 0. A new line starts directly after a line delimiter. (offset == document length) is a valid argument although there is no corresponding character.
        Specified by:
        getLineOfOffset in interface IDocument
        Parameters:
        pos - the document offset
        Returns:
        the number of the line
        Throws:
        BadLocationException - if the offset is invalid in this document
      • getLineOffset

        public int getLineOffset​(int line)
                          throws BadLocationException
        Description copied from interface: IDocument
        Determines the offset of the first character of the given line.
        Specified by:
        getLineOffset in interface IDocument
        Parameters:
        line - the line of interest
        Returns:
        the document offset
        Throws:
        BadLocationException - if the line number is invalid in this document
      • getLineInformation

        public IRegion getLineInformation​(int line)
                                   throws BadLocationException
        Description copied from interface: IDocument
        Returns a description of the specified line. The line is described by its offset and its length excluding the line's delimiter.
        Specified by:
        getLineInformation in interface IDocument
        Parameters:
        line - the line of interest
        Returns:
        a line description
        Throws:
        BadLocationException - if the line number is invalid in this document
      • getLineInformationOfOffset

        public IRegion getLineInformationOfOffset​(int offset)
                                           throws BadLocationException
        Description copied from interface: IDocument
        Returns a description of the line at the given offset. The description contains the offset and the length of the line excluding the line's delimiter.
        Specified by:
        getLineInformationOfOffset in interface IDocument
        Parameters:
        offset - the offset whose line should be described
        Returns:
        a region describing the line
        Throws:
        BadLocationException - if offset is invalid in this document
      • getNumberOfLines

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

        Note that a document always has at least one line.

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

        public int getNumberOfLines​(int offset,
                                    int length)
                             throws BadLocationException
        Description copied from interface: IDocument
        Returns the number of lines which are occupied by a given text range.
        Specified by:
        getNumberOfLines in interface IDocument
        Parameters:
        offset - the offset of the specified text range
        length - the length of the specified text range
        Returns:
        the number of lines occupied by the specified range
        Throws:
        BadLocationException - if specified range is invalid in this tracker
      • computeNumberOfLines

        public int computeNumberOfLines​(String text)
        Description copied from interface: IDocument
        Computes the number of lines in the given text. For a given implementer of this interface this method returns the same result as set(text); getNumberOfLines().
        Specified by:
        computeNumberOfLines in interface IDocument
        Parameters:
        text - the text whose number of lines should be computed
        Returns:
        the number of lines in the given text
      • getPartition

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

        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:
        getPartition in interface IDocument
        Parameters:
        offset - the document offset
        Returns:
        a specification of the partition
        Throws:
        BadLocationException - if offset is invalid in this document
      • computePartitioning

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

        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:
        computePartitioning in interface IDocument
        Parameters:
        offset - the document offset at which the range starts
        length - the length of the document range
        Returns:
        a specification of the range's partitioning
        Throws:
        BadLocationException - if the range is invalid in this document
      • getPositions

        public Position[] getPositions​(String category)
                                throws BadPositionCategoryException
        Description copied from interface: IDocument
        Returns all positions of the given position category. The positions are ordered according to the category's order. Manipulating this list does not affect the document, but manipulating the position does affect the document.
        Specified by:
        getPositions in interface IDocument
        Parameters:
        category - the category
        Returns:
        the list of all positions
        Throws:
        BadPositionCategoryException - if category is undefined in this document
      • getPositionCategories

        public String[] getPositionCategories()
        Description copied from interface: IDocument
        Returns all position categories of this document. This includes the default position category.
        Specified by:
        getPositionCategories in interface IDocument
        Returns:
        the document's position categories
      • getPositionUpdaters

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

        public String get()
        Description copied from interface: IDocument
        Returns this document's complete text.
        Specified by:
        get in interface IDocument
        Returns:
        the document's complete text
      • get

        public String get​(int pos,
                          int length)
                   throws BadLocationException
        Description copied from interface: IDocument
        Returns this document's text for the specified range.
        Specified by:
        get in interface IDocument
        Parameters:
        pos - the document offset
        length - the length of the specified range
        Returns:
        the document's text for the specified range
        Throws:
        BadLocationException - if the range is invalid in this document
      • insertPositionUpdater

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

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

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

        public void removePosition​(String category,
                                   Position position)
                            throws BadPositionCategoryException
        Description copied from interface: IDocument
        Removes the given position from the specified position category. If the position is not part of the specified category nothing happens. If the position has been added multiple times, only the first occurrence is deleted.
        Specified by:
        removePosition in interface IDocument
        Parameters:
        category - the category from which to delete
        position - the position to be deleted
        Throws:
        BadPositionCategoryException - if category is undefined in this document
      • removePosition

        public void removePosition​(Position position)
        Description copied from interface: IDocument
        Removes the given position from the document's default position category. This is a convenience method for removePosition(DEFAULT_CATEGORY, position).
        Specified by:
        removePosition in interface IDocument
        Parameters:
        position - the position to be removed
      • removePositionUpdater

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

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

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

        public long getModificationStamp()
        Description copied from interface: IDocumentExtension4
        Returns 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:
        getModificationStamp in interface IDocumentExtension4
        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: IDocumentExtension4
        Substitutes the given text for the specified document range. Sends a DocumentEvent to all registered IDocumentListener.
        Specified by:
        replace in interface IDocumentExtension4
        Parameters:
        pos - the document offset
        length - the length of the specified range
        text - the substitution text
        modificationStamp - of the document after replacing
        Throws:
        BadLocationException - if the offset is invalid in this document
        See Also:
        DocumentEvent, IDocumentListener
      • replace

        public void replace​(int pos,
                            int length,
                            String text)
                     throws BadLocationException
        Description copied from interface: IDocument
        Substitutes the given text for the specified document range. Sends a DocumentEvent to all registered IDocumentListener.
        Specified by:
        replace in interface IDocument
        Parameters:
        pos - the document offset
        length - the length of the specified range
        text - the substitution text
        Throws:
        BadLocationException - if the offset is invalid in this document
        See Also:
        DocumentEvent, IDocumentListener
      • set

        public void set​(String text)
        Description copied from interface: IDocument
        Replaces the content of the document with the given text. Sends a DocumentEvent to all registered IDocumentListener. This method is a convenience method for replace(0, getLength(), text).
        Specified by:
        set in interface IDocument
        Parameters:
        text - the new content of the document
        See Also:
        DocumentEvent, IDocumentListener
      • set

        public void set​(String text,
                        long modificationStamp)
        Description copied from interface: IDocumentExtension4
        Replaces the content of the document with the given text. Sends a DocumentEvent to all registered IDocumentListener. This method is a convenience method for replace(0, getLength(), text).
        Specified by:
        set in interface IDocumentExtension4
        Parameters:
        text - the new content of the document
        modificationStamp - of the document after setting the content
        See Also:
        DocumentEvent, IDocumentListener
      • updatePositions

        protected void updatePositions​(DocumentEvent event)
        Updates all positions of all categories to the change described by the document event. All registered document updaters are called in the sequence they have been arranged. Uses a robust iterator.
        Parameters:
        event - the document event describing the change to which to adapt the positions
      • search

        @Deprecated
        public int search​(int startPosition,
                          String findString,
                          boolean forwardSearch,
                          boolean caseSensitive,
                          boolean wholeWord)
                   throws BadLocationException
        Deprecated.
        as of 3.0 search is provided by FindReplaceDocumentAdapter
        Returns the offset of a given search string in the document based on a set of search criteria.
        Specified by:
        search in interface IDocument
        Parameters:
        startPosition - document offset at which search starts
        findString - the string to find
        forwardSearch - the search direction
        caseSensitive - indicates whether lower and upper case should be distinguished
        wholeWord - indicates whether the findString should be limited by white spaces as defined by Character.isWhiteSpace
        Returns:
        the offset of the first occurrence of findString based on the parameters or -1 if no match is found
        Throws:
        BadLocationException - if startOffset is an invalid document offset
      • stopPostNotificationProcessing

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

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

        @Deprecated
        public void startSequentialRewrite​(boolean normalized)
        Tells the document that it is about to be sequentially rewritten. That is a sequence of non-overlapping replace operations will be performed on it. The normalize flag indicates whether the rewrite is 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.

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

        public void resumeListenerNotification()
        Description copied from interface: IDocumentExtension2
        Resumes the notification of document listeners which must previously have been stopped by a call to stopListenerNotification.
        Specified by:
        resumeListenerNotification in interface IDocumentExtension2
      • stopListenerNotification

        public void stopListenerNotification()
        Description copied from interface: IDocumentExtension2
        Can be called prior to a 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.

        Specified by:
        stopListenerNotification in interface IDocumentExtension2
      • computePartitioning

        public ITypedRegion[] computePartitioning​(String partitioning,
                                                  int offset,
                                                  int length,
                                                  boolean includeZeroLengthPartitions)
                                           throws BadLocationException,
                                                  BadPartitioningException
        Description copied from interface: IDocumentExtension3
        Computes the partitioning of the given document range based on the given partitioning type.

        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.

        This is only supported if the connected IDocumentPartitioner supports it, i.e. implements IDocumentPartitionerExtension2. Otherwise, includeZeroLengthPartitions is ignored.

        Specified by:
        computePartitioning in interface IDocumentExtension3
        Parameters:
        partitioning - the document's partitioning type
        offset - the document offset at which the range starts
        length - the length of the document range
        includeZeroLengthPartitions - true if 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: IDocumentExtension3
        Returns the type of the document partition containing the given offset for the given partitioning. This is a convenience method for 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.

        This is only supported if the connected IDocumentPartitioner supports it, i.e. implements IDocumentPartitionerExtension2. Otherwise, preferOpenPartitions is ignored.

        Specified by:
        getContentType in interface IDocumentExtension3
        Parameters:
        partitioning - the partitioning
        offset - the document offset
        preferOpenPartitions - true if precedence should be given to a open partition ending at offset over a closed partition starting at offset
        Returns:
        the partition type
        Throws:
        BadLocationException - if offset is invalid in this document
        BadPartitioningException - if partitioning is invalid for this document
      • getDocumentPartitioner

        public IDocumentPartitioner getDocumentPartitioner​(String partitioning)
        Description copied from interface: IDocumentExtension3
        Returns the partitioner for the given partitioning or null if no partitioner is registered.
        Specified by:
        getDocumentPartitioner in interface IDocumentExtension3
        Parameters:
        partitioning - the partitioning for which to set the partitioner
        Returns:
        the partitioner for the given partitioning
      • getLegalContentTypes

        public String[] getLegalContentTypes​(String partitioning)
                                      throws BadPartitioningException
        Description copied from interface: IDocumentExtension3
        Returns 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 of getPartitioning(partitioning, 0, getLength()).
        Specified by:
        getLegalContentTypes in interface IDocumentExtension3
        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: IDocumentExtension3
        Returns the document partition of the given partitioning in which the given offset is located.

        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.

        This is only supported if the connected IDocumentPartitioner supports it, i.e. implements IDocumentPartitionerExtension2. Otherwise, preferOpenPartitions is ignored.

        Specified by:
        getPartition in interface IDocumentExtension3
        Parameters:
        partitioning - the partitioning
        offset - the document offset
        preferOpenPartitions - true if precedence should be given to a open partition ending at offset over a closed partition starting at offset
        Returns:
        a specification of the partition
        Throws:
        BadLocationException - if offset is invalid in this document
        BadPartitioningException - if partitioning is invalid for this document
      • getPartitionings

        public String[] getPartitionings()
        Description copied from interface: IDocumentExtension3
        Returns the existing partitionings for this document. This includes the default partitioning.
        Specified by:
        getPartitionings in interface IDocumentExtension3
        Returns:
        the existing partitionings for this document
      • setDocumentPartitioner

        public void setDocumentPartitioner​(String partitioning,
                                           IDocumentPartitioner partitioner)
        Description copied from interface: IDocumentExtension3
        Sets this document's partitioner. The caller of this method is responsible for disconnecting the document's old partitioner from the document and to connect the new partitioner to the document. Informs all document partitioning listeners about this change.
        Specified by:
        setDocumentPartitioner in interface IDocumentExtension3
        Parameters:
        partitioning - the partitioning for which to set the partitioner
        partitioner - the document's new partitioner
        See Also:
        IDocumentPartitioningListener
      • fireRewriteSessionChanged

        protected void fireRewriteSessionChanged​(DocumentRewriteSessionEvent event)
        Fires the given event to all registered rewrite session listeners. Uses robust iterators.
        Parameters:
        event - the event to be fired
        Since:
        3.1
      • startRewriteSession

        public DocumentRewriteSession startRewriteSession​(DocumentRewriteSessionType sessionType)
        Description copied from interface: IDocumentExtension4
        Tells 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 stopRewriteSession has not been called.

        Specified by:
        startRewriteSession in interface IDocumentExtension4
        Parameters:
        sessionType - the session type
        Returns:
        the started rewrite session
      • startRewriteSessionOnPartitioners

        protected final void startRewriteSessionOnPartitioners​(DocumentRewriteSession session)
        Starts the given rewrite session.
        Parameters:
        session - the rewrite session
        Since:
        3.1
      • stopRewriteSession

        public void stopRewriteSession​(DocumentRewriteSession session)
        Description copied from interface: IDocumentExtension4
        Tells the document to stop the rewrite session. This method has only any effect if startRewriteSession has been called before.

        This method does not have any effect if the given session is not the active rewrite session.

        Specified by:
        stopRewriteSession in interface IDocumentExtension4
        Parameters:
        session - the session to stop
      • stopRewriteSessionOnPartitioners

        protected final void stopRewriteSessionOnPartitioners​(DocumentRewriteSession session)
        Stops the given rewrite session.
        Parameters:
        session - the rewrite session
        Since:
        3.1
      • addDocumentRewriteSessionListener

        public void addDocumentRewriteSessionListener​(IDocumentRewriteSessionListener listener)
        Description copied from interface: IDocumentExtension4
        Registers the document rewrite session listener with the document. After registration the 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.

        Specified by:
        addDocumentRewriteSessionListener in interface IDocumentExtension4
        Parameters:
        listener - the listener to be registered
      • removeDocumentRewriteSessionListener

        public void removeDocumentRewriteSessionListener​(IDocumentRewriteSessionListener listener)
        Description copied from interface: IDocumentExtension4
        Removes the listener from the document's list of document rewrite session listeners. If the listener is not registered with the document nothing happens.

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

        Specified by:
        removeDocumentRewriteSessionListener in interface IDocumentExtension4
        Parameters:
        listener - the listener to be removed
      • checkStateOfPartitioner

        protected final void checkStateOfPartitioner​(IDocumentPartitioner partitioner,
                                                     String partitioning)
        Checks the state for the given partitioner and stops the active rewrite session.
        Parameters:
        partitioner - the document partitioner to be checked
        partitioning - 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 category
        offset - the start position of the region, must be >= 0
        length - the length of the region, must be >= 0
        canStartBefore - if true then positions are included which start before the region if they end at or after the regions start
        canEndAfter - if true then 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