Class Line

java.lang.Object
com.github.rjeschke.txtmark.Line

class Line extends Object
This class represents a text line.

It also provides methods for processing and analyzing a line.

  • Field Details

    • 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 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.
  • 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:
      false if end of line is reached
    • readUntil

      public 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 null if 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. Sets xmlEndLine.
      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 String stripID()
      Checks if this line contains an ID at it's end and removes it from the line.
      Returns:
      The ID or null if no valid ID exists.
    • checkHTML

      private boolean checkHTML()
      Checks for a valid HTML block. Sets xmlEndLine.
      Returns:
      true if it is a valid block.