java.lang.Object
org.tentackle.model.parse.Line
- Direct Known Subclasses:
MultiLine,SingleLine
A parsed line.
May span multiple input lines.
May span multiple input lines.
- Author:
- harald
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAsserts that this line is parsed.createModelException(String message) Creates a model exception.createModelException(String message, Throwable cause) Creates a model exception.Gets the document this line belongs to.intGets the length of the parsed line.intGets the first linenumber of this line within the document.Gets the line type.intGets the offset within the document.Gets the source info for this line.getText()Gets the line's text.abstract voidparse()Parses a line.protected voidsetLength(int length) Sets the line's length.
Invoked from withinparse().toString()
-
Constructor Details
-
Line
Creates a line.- Parameters:
document- the whole documentoffset- offset to first character within documentlineType- the line type
-
-
Method Details
-
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
Gets the line type.- Returns:
- the line type
-
assertParsed
Asserts that this line is parsed.- Throws:
ModelException- if not parsed
-
getLength
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 withinparse().- Parameters:
length- the lines length, -1 means to end of file
-
getText
Gets the line's text.- Returns:
- the text within the document
- Throws:
ModelException- if line has not been parsed yet
-
getSourceInfo
Gets the source info for this line.- Returns:
- the source info
-
toString
-
parse
Parses a line.- Throws:
ModelException- if parsing failed
-
createModelException
Creates a model exception.- Parameters:
message- the messagecause- the optional chained cause- Returns:
- the exception
-
createModelException
Creates a model exception.- Parameters:
message- the message- Returns:
- the exception
-