Class Document


  • public class Document
    extends java.lang.Object
    The input document.
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      Document​(java.lang.String text)
      Creates a document.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLineNumber​(int offsetInDocument)
      Gets the line number for a given offset within the document.
      java.util.List<Line> getLines()
      Gets the parsed lines.
      SourceInfo getSourceInfo()
      Gets the source info.
      java.lang.String getText()
      Gets the document text.
      protected Line nextLine​(Line currentLine)
      Gets the next line.
      protected java.util.List<Line> parse()
      Parses the document and returns a list of lines.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Document

        public Document​(java.lang.String text)
        Creates a document.
        Parameters:
        text - the model specification source
    • Method Detail

      • getText

        public java.lang.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 java.util.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 java.util.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