Class Document

java.lang.Object
org.tentackle.model.parse.Document

public class Document extends Object
The input document describing the model of an entity.
Author:
harald
  • Field Details

    • ORIGIN_INFO_LEAD

      public static final String ORIGIN_INFO_LEAD
      The model source may start with this lead followed by the source info.
      Same as in org.wurbelizer.misc.Constants.
      See Also:
    • DEFAULTS_INFO_LEAD

      public static final String DEFAULTS_INFO_LEAD
      If the model source is stored in a jar, the source info lead doesn't make sense.
      Instead, the model defaults used to parse the model in the project become necessary, since we have no access to the original project's poms.
      See Also:
  • Constructor Details

    • Document

      public Document(String text) throws ModelException
      Creates a document.
      Parameters:
      text - the model specification source
      Throws:
      ModelException - if parsing the model defaults failed
  • Method Details

    • 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 not defined within the document
      See Also:
    • getModelDefaults

      public ModelDefaults getModelDefaults()
      Gets the optional model defaults.
      Returns:
      the defaults, null if not defined within the document
      See Also:
    • 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