Package com.github.rjeschke.txtmark
Class Line
- java.lang.Object
-
- com.github.rjeschke.txtmark.Line
-
class Line extends java.lang.ObjectThis class represents a text line.It also provides methods for processing and analyzing a line.
-
-
Field Summary
Fields Modifier and Type Field Description booleanisEmptyIs this line empty?intleadingLeading and trailing spaces.LinenextPrevious and next line.booleannextEmptyIs previous/next line empty?intposCurrent cursor position.booleanprevEmptyIs previous/next line empty?LinepreviousPrevious and next line.inttrailingLeading and trailing spaces.java.lang.StringvalueThis line's value.LinexmlEndLineFinal line of a XML block.
-
Constructor Summary
Constructors Constructor Description Line()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancheckHTML()Checks 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.LineTypegetLineType(Configuration configuration)Gets this line's type.voidinit()Calculates leading and trailing spaces.voidinitLeading()Recalculate leading spaces.java.lang.StringreadUntil(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.booleanskipSpaces()Skips spaces.java.lang.StringstripID()Checks if this line contains an ID at it's end and removes it from the line.
-
-
-
Field Detail
-
pos
public int pos
Current cursor position.
-
leading
public int leading
Leading and trailing spaces.
-
trailing
public int trailing
Leading and trailing spaces.
-
isEmpty
public boolean isEmpty
Is this line empty?
-
value
public java.lang.String value
This line's value.
-
previous
public Line previous
Previous and next line.
-
next
public Line next
Previous and next line.
-
prevEmpty
public boolean prevEmpty
Is previous/next line empty?
-
nextEmpty
public boolean nextEmpty
Is previous/next line empty?
-
xmlEndLine
public Line xmlEndLine
Final line of a XML block.
-
-
Method Detail
-
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
public java.lang.String readUntil(char... end)
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
public LineType getLineType(Configuration configuration)
Gets this line's type.- Parameters:
configuration- txtmark configuration- Returns:
- The LineType.
-
readXMLComment
private int readXMLComment(Line firstLine, int start)
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
public java.lang.String 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.
-
-