Class Line

  • Direct Known Subclasses:
    MultiLine, SingleLine

    public abstract class Line
    extends java.lang.Object
    A parsed line.
    May span multiple input lines.
    Author:
    harald
    • Constructor Detail

      • Line

        public Line​(Document document,
                    int offset,
                    LineType lineType)
        Creates a line.
        Parameters:
        document - the whole document
        offset - offset to first character within document
        lineType - the line type
    • Method Detail

      • getDocument

        public Document getDocument()
        Gets the document this line belongs to.
        Returns:
        the document
      • getOffset

        public int getOffset()
        Gets the offset within the document.
        Returns:
        the start of this line
      • getLineNumber

        public int getLineNumber()
        Gets the first linenumber of this line within the document.
        Returns:
        the linenumber, starting at 1
      • getLineType

        public LineType getLineType()
        Gets the line type.
        Returns:
        the line type
      • assertParsed

        protected void assertParsed()
                             throws ModelException
        Asserts that this line is parsed.
        Throws:
        ModelException - if not parsed
      • getLength

        public int getLength()
                      throws ModelException
        Gets the length of the parsed line.
        Returns:
        the length
        Throws:
        ModelException - if line has not been parsed yet
      • setLength

        protected void setLength​(int length)
        Sets the line's length.
        Invoked from within parse().
        Parameters:
        length - the lines length, -1 means to end of file
      • getText

        public java.lang.String getText()
                                 throws ModelException
        Gets the line's text.
        Returns:
        the text within the document
        Throws:
        ModelException - if line has not been parsed yet
      • getSourceInfo

        public SourceInfo getSourceInfo()
        Gets the source info for this line.
        Returns:
        the source info
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • createModelException

        public ModelException createModelException​(java.lang.String message,
                                                   java.lang.Throwable cause)
        Creates a model exception.
        Parameters:
        message - the message
        cause - the optional chained cause
        Returns:
        the exception
      • createModelException

        public ModelException createModelException​(java.lang.String message)
        Creates a model exception.
        Parameters:
        message - the message
        Returns:
        the exception