Package aQute.bnd.properties
Class LineTracker
- java.lang.Object
-
- aQute.bnd.properties.LineTracker
-
public class LineTracker extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Line>
fLines
The line informationprivate int
fTextLength
The length of the tracked text
-
Constructor Summary
Constructors Modifier Constructor Description protected
LineTracker()
Creates a new line tracker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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, aList
ofLine
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)
-
-
-
Field Detail
-
fLines
private final java.util.List<Line> fLines
The line information
-
fTextLength
private int fTextLength
The length of the tracked text
-
-
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 startsoffset
- the start offset of the text rangelength
- 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
-
getLineLength
public final int getLineLength(int line) throws BadLocationException
- Throws:
BadLocationException
-
getLineNumberOfOffset
public final int getLineNumberOfOffset(int position) throws BadLocationException
- Throws:
BadLocationException
-
getLineInformationOfOffset
public final IRegion getLineInformationOfOffset(int position) throws BadLocationException
- Throws:
BadLocationException
-
getLineInformation
public final IRegion getLineInformation(int line) throws BadLocationException
- Throws:
BadLocationException
-
getLineOffset
public final int getLineOffset(int line) throws BadLocationException
- Throws:
BadLocationException
-
getNumberOfLines
public final int getNumberOfLines()
-
getNumberOfLines
public final int getNumberOfLines(int position, int length) throws BadLocationException
- Throws:
BadLocationException
-
computeNumberOfLines
public final int computeNumberOfLines(java.lang.String text)
-
getLineDelimiter
public final java.lang.String getLineDelimiter(int line) throws BadLocationException
- Throws:
BadLocationException
-
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 searchedoffset
- 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 structureinsertPosition
- the position at which the newly created lines are inserted into the tracker's line structureoffset
- the offset of all newly created lines- Returns:
- the number of newly created lines
-
replace
public final void replace(int position, int length, java.lang.String text) throws BadLocationException
- Throws:
BadLocationException
-
set
public final void set(java.lang.String text)
-
-