- java.lang.Object
-
- org.tentackle.model.parse.Line
-
- Direct Known Subclasses:
MultiLine,SingleLine
public abstract class Line extends java.lang.ObjectA parsed line.
May span multiple input lines.- Author:
- harald
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassertParsed()Asserts that this line is parsed.ModelExceptioncreateModelException(java.lang.String message)Creates a model exception.ModelExceptioncreateModelException(java.lang.String message, java.lang.Throwable cause)Creates a model exception.DocumentgetDocument()Gets the document this line belongs to.intgetLength()Gets the length of the parsed line.intgetLineNumber()Gets the first linenumber of this line within the document.LineTypegetLineType()Gets the line type.intgetOffset()Gets the offset within the document.SourceInfogetSourceInfo()Gets the source info for this line.java.lang.StringgetText()Gets the line's text.abstract voidparse()Parses a line.protected voidsetLength(int length)Sets the line's length.
Invoked from withinparse().java.lang.StringtoString()
-
-
-
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 ModelExceptionAsserts that this line is parsed.- Throws:
ModelException- if not parsed
-
getLength
public int getLength() throws ModelExceptionGets 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
public java.lang.String getText() throws ModelExceptionGets 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:
toStringin classjava.lang.Object
-
parse
public abstract void parse() throws ModelExceptionParses a line.- Throws:
ModelException- if parsing failed
-
createModelException
public ModelException createModelException(java.lang.String message, java.lang.Throwable cause)
Creates a model exception.- Parameters:
message- the messagecause- 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
-
-