Class Line


  • class Line
    extends java.lang.Object
    This class represents a text line.

    It also provides methods for processing and analyzing a line.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean isEmpty
      Is this line empty?
      int leading
      Leading and trailing spaces.
      Line next
      Previous and next line.
      boolean nextEmpty
      Is previous/next line empty?
      int pos
      Current cursor position.
      boolean prevEmpty
      Is previous/next line empty?
      Line previous
      Previous and next line.
      int trailing
      Leading and trailing spaces.
      java.lang.String value
      This line's value.
      Line xmlEndLine
      Final 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 boolean checkHTML()
      Checks for a valid HTML block.
      private int countChars​(char ch)
      Counts the amount of 'ch' in this line.
      private int countCharsStart​(char ch, boolean allowSpaces)
      Counts the amount of 'ch' at the start of this line optionally ignoring spaces.
      LineType getLineType​(Configuration configuration)
      Gets this line's type.
      void init()
      Calculates leading and trailing spaces.
      void initLeading()
      Recalculate leading spaces.
      java.lang.String readUntil​(char... end)
      Reads chars from this line until any 'end' char is reached.
      private int readXMLComment​(Line firstLine, int start)
      Reads an XML comment.
      void setEmpty()
      Marks this line empty.
      boolean skipSpaces()
      Skips spaces.
      java.lang.String stripID()
      Checks if this line contains an ID at it's end and removes it from the line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
    • Constructor Detail

      • Line

        public Line()
        Constructor.
    • 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:
        false if 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 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 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 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.