Class BaseDoc

All Implemented Interfaces:
io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.doc.CodeDoc>, io.github.mmm.code.api.doc.CodeDoc, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.merge.CodeMergeableItem<io.github.mmm.code.api.doc.CodeDoc>, io.github.mmm.code.api.merge.CodeSimpleMergeableItem<io.github.mmm.code.api.doc.CodeDoc>, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.object.CodeMutable

public class BaseDoc extends BaseNodeItem implements io.github.mmm.code.api.doc.CodeDoc
Base implementation of CodeDoc.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Constructor Details

    • BaseDoc

      public BaseDoc(BaseElement parent)
      The constructor.
      Parameters:
      parent - the parent element.
    • BaseDoc

      public BaseDoc(BaseDoc template, io.github.mmm.code.api.copy.CodeCopyMapper mapper)
      The copy-constructor.
      Parameters:
      template - the BaseDoc to copy.
      mapper - the CodeCopyMapper.
  • Method Details

    • getParent

      public BaseElement getParent()
      Specified by:
      getParent in interface io.github.mmm.code.api.node.CodeNode
      Specified by:
      getParent in interface io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.doc.CodeDoc>
    • doInitialize

      protected void doInitialize()
      Description copied from class: BaseNodeItem
      Called from BaseMutableItem.initialize() on first invocation. May be overridden but never be called from anywhere else.
      Overrides:
      doInitialize in class BaseNodeItem
    • doSetImmutable

      protected void doSetImmutable()
      Description copied from class: BaseMutableItem
      Called on the first call of BaseMutableItem.setImmutable(). Has to be overridden to update Collections, make child items immutable, etc.
      Overrides:
      doSetImmutable in class BaseMutableItem
    • isSystemImmutable

      protected boolean isSystemImmutable()
      Overrides:
      isSystemImmutable in class BaseMutableItem
      Returns:
      true if this is a system internal node item that is considered to be immutable but is technically set to immutable during (lazy) initialization. Otherwise false.
    • getLines

      public List<String> getLines()
      Specified by:
      getLines in interface io.github.mmm.code.api.doc.CodeDoc
    • add

      public void add(Collection<String> textLines)
      Specified by:
      add in interface io.github.mmm.code.api.doc.CodeDoc
    • add

      public void add(String... textLines)
      Specified by:
      add in interface io.github.mmm.code.api.doc.CodeDoc
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface io.github.mmm.code.api.doc.CodeDoc
    • getFormatted

      public String getFormatted(io.github.mmm.code.api.doc.CodeDocFormat format, String newline)
      Specified by:
      getFormatted in interface io.github.mmm.code.api.doc.CodeDoc
    • getInlineTagPattern

      protected Pattern getInlineTagPattern()
      Returns:
      the Pattern to detect an inline documentation tag.
    • resolveLinkValue

      protected Object resolveLinkValue(io.github.mmm.code.api.doc.CodeDocLink link)
      Parameters:
      link - the BaseDocLink to resolve as value (e.g. to resolve "@{value Foo#BAR}" or "@{value}").
      Returns:
      the resolved value.
    • resolveLinkUrl

      protected String resolveLinkUrl(io.github.mmm.code.api.doc.CodeDocLink link)
      Parameters:
      link - the BaseDocLink to resolve.
      Returns:
      the BaseDocLink resolved as URL.
    • resolveLinkQualifiedName

      protected String resolveLinkQualifiedName(io.github.mmm.code.api.doc.CodeDocLink link)
      Parameters:
      link - the BaseDocLink to resolve.
      Returns:
      the qualified name of the BaseDocLink. In case it is null the resolved qualified name from the simple name.
    • resolveLinkUrl

      protected String resolveLinkUrl(String url, io.github.mmm.code.api.doc.CodeDocLink link, boolean absolute)
      Parameters:
      url - the base URL or relative path.
      link - the BaseDocLink.
      absolute - - true if the qualified name should be appended as path to the URL, false otherwise.
      Returns:
      the resolved URL.
    • resolveLinkRelative

      protected String resolveLinkRelative(io.github.mmm.code.api.doc.CodeDocLink link)
      Parameters:
      link - the BaseDocLink to resolve.
      Returns:
      the path relative to this context.
    • merge

      public io.github.mmm.code.api.doc.CodeDoc merge(io.github.mmm.code.api.doc.CodeDoc other, io.github.mmm.code.api.merge.CodeMergeStrategy strategy)
      Specified by:
      merge in interface io.github.mmm.code.api.merge.CodeSimpleMergeableItem<io.github.mmm.code.api.doc.CodeDoc>
    • copy

      public BaseDoc copy()
      Specified by:
      copy in interface io.github.mmm.code.api.item.CodeMutableItem
      Specified by:
      copy in interface io.github.mmm.code.api.node.CodeNodeItem
      Specified by:
      copy in interface io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.doc.CodeDoc>
    • copy

      public BaseDoc copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper)
      Specified by:
      copy in interface io.github.mmm.code.api.item.CodeMutableItem
      Specified by:
      copy in interface io.github.mmm.code.api.node.CodeNodeItem
      Specified by:
      copy in interface io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.doc.CodeDoc>
    • doWrite

      protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException
      Specified by:
      doWrite in class BaseItem
      Parameters:
      sink - the Appendable where to append the code from this CodeItem.
      newline - the newline String.
      defaultIndent - the String used for indentation (e.g. a number of spaces to insert per indent level).
      currentIndent - the current indent (number of spaces). Initially the empty string (""). Before a recursion the defaultIndent will be appended.
      language - the CodeLanguage to use.
      Throws:
      IOException - if thrown by Appendable.
      See Also:
      • CodeItem.write(Appendable, String, String)