- java.lang.Object
-
- org.tentackle.model.parse.Document
-
public class Document extends Object
The input document.- Author:
- harald
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetLineNumber(int offsetInDocument)Gets the line number for a given offset within the document.List<Line>getLines()Gets the parsed lines.SourceInfogetSourceInfo()Gets the source info.StringgetText()Gets the document text.protected LinenextLine(Line currentLine)Gets the next line.protected List<Line>parse()Parses the document and returns a list of lines.
-
-
-
Constructor Detail
-
Document
public Document(String text)
Creates a document.- Parameters:
text- the model specification source
-
-
Method Detail
-
getText
public String getText()
Gets the document text.- Returns:
- the document text
-
getSourceInfo
public SourceInfo getSourceInfo()
Gets the source info.- Returns:
- the info, null if unknown
-
getLines
public List<Line> getLines() throws ModelException
Gets the parsed lines.- Returns:
- the lines, never null
- Throws:
ModelException- if parsing failed
-
getLineNumber
public int getLineNumber(int offsetInDocument)
Gets the line number for a given offset within the document.- Parameters:
offsetInDocument- the offset- Returns:
- the linenumber starting at 1
-
parse
protected List<Line> parse() throws ModelException
Parses the document and returns a list of lines.- Returns:
- the list of lines, never null
- Throws:
ModelException- if parsing failed
-
nextLine
protected Line nextLine(Line currentLine) throws ModelException
Gets the next line.- Parameters:
currentLine- the current line, null if start of document- Returns:
- the line, null if reached end of document
- Throws:
ModelException- if parsing failed
-
-