public class LineTracker
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<Line> |
fLines
The line information
|
private int |
fTextLength
The length of the tracked text
|
Modifier | Constructor and Description |
---|---|
protected |
LineTracker()
Creates a new line tracker.
|
Modifier and Type | Method and Description |
---|---|
int |
computeNumberOfLines(java.lang.String text) |
private int |
createLines(java.lang.String text,
int insertPosition,
int offset)
Creates the line structure for the given text.
|
private int |
findLine(int offset)
Binary search for the line at a given offset.
|
java.lang.String |
getLineDelimiter(int line) |
IRegion |
getLineInformation(int line) |
IRegion |
getLineInformationOfOffset(int position) |
int |
getLineLength(int line) |
int |
getLineNumberOfOffset(int position) |
int |
getLineOffset(int line) |
(package private) java.util.List<Line> |
getLines()
Returns the internal data structure, a
List of Line s. |
int |
getNumberOfLines() |
int |
getNumberOfLines(int position,
int length) |
private int |
getNumberOfLines(int startLine,
int offset,
int length)
Returns the number of lines covered by the specified text range.
|
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.
|
void |
replace(int position,
int length,
java.lang.String text) |
void |
set(java.lang.String text) |
private final java.util.List<Line> fLines
private int fTextLength
private int findLine(int offset)
offset
- the offset whose line should be foundprivate int getNumberOfLines(int startLine, int offset, int length) throws BadLocationException
startLine
- the line where the text range startsoffset
- the start offset of the text rangelength
- the length of the text rangeBadLocationException
public final int getLineLength(int line) throws BadLocationException
BadLocationException
public final int getLineNumberOfOffset(int position) throws BadLocationException
BadLocationException
public final IRegion getLineInformationOfOffset(int position) throws BadLocationException
BadLocationException
public final IRegion getLineInformation(int line) throws BadLocationException
BadLocationException
public final int getLineOffset(int line) throws BadLocationException
BadLocationException
public final int getNumberOfLines()
public final int getNumberOfLines(int position, int length) throws BadLocationException
BadLocationException
public final int computeNumberOfLines(java.lang.String text)
public final java.lang.String getLineDelimiter(int line) throws BadLocationException
BadLocationException
protected Document.DelimiterInfo nextDelimiterInfo(java.lang.String text, int offset)
text
- the text to be searchedoffset
- the offset in the given textnull
private int createLines(java.lang.String text, int insertPosition, int offset)
text
- the text for which to create a line structureinsertPosition
- the position at which the newly created lines are
inserted into the tracker's line structureoffset
- the offset of all newly created linespublic final void replace(int position, int length, java.lang.String text) throws BadLocationException
BadLocationException
public final void set(java.lang.String text)