Class Line
java.lang.Object
com.github.rjeschke.txtmark.Line
This class represents a text line.
It also provides methods for processing and analyzing a line.
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanIs this line empty?intLeading and trailing spaces.Previous and next line.booleanIs previous/next line empty?intCurrent cursor position.booleanIs previous/next line empty?Previous and next line.intLeading and trailing spaces.This line's value.Final line of a XML block. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanChecks for a valid HTML block.private intcountChars(char ch) Counts the amount of 'ch' in this line.private intcountCharsStart(char ch, boolean allowSpaces) Counts the amount of 'ch' at the start of this line optionally ignoring spaces.getLineType(Configuration configuration) Gets this line's type.voidinit()Calculates leading and trailing spaces.voidRecalculate leading spaces.readUntil(char... end) Reads chars from this line until any 'end' char is reached.private intreadXMLComment(Line firstLine, int start) Reads an XML comment.voidsetEmpty()Marks this line empty.booleanSkips spaces.stripID()Checks if this line contains an ID at it's end and removes it from the line.
-
Field Details
-
pos
public int posCurrent cursor position. -
leading
public int leadingLeading and trailing spaces. -
trailing
public int trailingLeading and trailing spaces. -
isEmpty
public boolean isEmptyIs this line empty? -
value
This line's value. -
previous
Previous and next line. -
next
Previous and next line. -
prevEmpty
public boolean prevEmptyIs previous/next line empty? -
nextEmpty
public boolean nextEmptyIs previous/next line empty? -
xmlEndLine
Final line of a XML block.
-
-
Constructor Details
-
Line
public Line()Constructor.
-
-
Method Details
-
init
public void init()Calculates leading and trailing spaces. Also sets empty if needed. -
initLeading
public void initLeading()Recalculate leading spaces. -
skipSpaces
public boolean skipSpaces()Skips spaces.- Returns:
falseif end of line is reached
-
readUntil
Reads chars from this line until any 'end' char is reached.- Parameters:
end- Delimiting character(s)- Returns:
- The read String or
nullif no 'end' char was reached.
-
setEmpty
public void setEmpty()Marks this line empty. Also sets previous/next line's empty attributes. -
countChars
private int countChars(char ch) Counts the amount of 'ch' in this line.- Parameters:
ch- The char to count.- Returns:
- A value > 0 if this line only consists of 'ch' end spaces.
-
countCharsStart
private int countCharsStart(char ch, boolean allowSpaces) Counts the amount of 'ch' at the start of this line optionally ignoring spaces.- Parameters:
ch- The char to count.allowSpaces- Whether to allow spaces or not- Returns:
- Number of characters found.
- Since:
- 0.12
-
getLineType
Gets this line's type.- Parameters:
configuration- txtmark configuration- Returns:
- The LineType.
-
readXMLComment
Reads an XML comment. SetsxmlEndLine.- Parameters:
firstLine- The Line to start reading from.start- The starting position.- Returns:
- The new position or -1 if it is no valid comment.
-
stripID
Checks if this line contains an ID at it's end and removes it from the line.- Returns:
- The ID or
nullif no valid ID exists.
-
checkHTML
private boolean checkHTML()Checks for a valid HTML block. SetsxmlEndLine.- Returns:
trueif it is a valid block.
-