Class LineTracker


  • public class LineTracker
    extends java.lang.Object
    • Field Detail

      • fLines

        private final java.util.List<Line> fLines
        The line information
      • fTextLength

        private int fTextLength
        The length of the tracked text
    • Constructor Detail

      • LineTracker

        protected LineTracker()
        Creates a new line tracker.
    • Method Detail

      • findLine

        private int findLine​(int offset)
        Binary search for the line at a given offset.
        Parameters:
        offset - the offset whose line should be found
        Returns:
        the line of the offset
      • getNumberOfLines

        private int getNumberOfLines​(int startLine,
                                     int offset,
                                     int length)
                              throws BadLocationException
        Returns the number of lines covered by the specified text range.
        Parameters:
        startLine - the line where the text range starts
        offset - the start offset of the text range
        length - the length of the text range
        Returns:
        the number of lines covered by this text range @exception BadLocationException if range is undefined in this tracker
        Throws:
        BadLocationException
      • getNumberOfLines

        public final int getNumberOfLines()
      • computeNumberOfLines

        public final int computeNumberOfLines​(java.lang.String text)
      • nextDelimiterInfo

        protected Document.DelimiterInfo nextDelimiterInfo​(java.lang.String text,
                                                           int offset)
        Returns the information about the first delimiter found in the given text starting at the given offset.
        Parameters:
        text - the text to be searched
        offset - the offset in the given text
        Returns:
        the information of the first found delimiter or null
      • createLines

        private int createLines​(java.lang.String text,
                                int insertPosition,
                                int offset)
        Creates the line structure for the given text. Newly created lines are inserted into the line structure starting at the given position. Returns the number of newly created lines.
        Parameters:
        text - the text for which to create a line structure
        insertPosition - the position at which the newly created lines are inserted into the tracker's line structure
        offset - the offset of all newly created lines
        Returns:
        the number of newly created lines
      • set

        public final void set​(java.lang.String text)
      • getLines

        final java.util.List<Line> getLines()
        Returns the internal data structure, a List of Lines. Used only by TreeLineTracker#TreeLineTracker(ListLineTracker) .
        Returns:
        the internal list of lines.