Class Line

java.lang.Object
org.tentackle.model.parse.Line
Direct Known Subclasses:
MultiLine, SingleLine

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

    • 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 Details

    • 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 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 String toString()
      Overrides:
      toString in class Object
    • parse

      public abstract void parse() throws ModelException
      Parses a line.
      Throws:
      ModelException - if parsing failed
    • createModelException

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

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