Class BaseBlockInitializer

All Implemented Interfaces:
io.github.mmm.code.api.block.CodeBlock, io.github.mmm.code.api.block.CodeBlockInitializer, io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.type.CodeType, io.github.mmm.code.api.block.CodeBlockInitializer>, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithVariables, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.object.CodeMutable

public class BaseBlockInitializer extends BaseBlock implements io.github.mmm.code.api.block.CodeBlockInitializer
Base implementation of CodeBlockBody.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Constructor Details

    • BaseBlockInitializer

      public BaseBlockInitializer(BaseType parent)
      The constructor.
      Parameters:
      parent - the parent.
    • BaseBlockInitializer

      public BaseBlockInitializer(BaseType parent, io.github.mmm.code.api.statement.CodeStatement... statements)
      The constructor.
      Parameters:
      parent - the parent.
      statements - the statements.
    • BaseBlockInitializer

      public BaseBlockInitializer(BaseType parent, List<io.github.mmm.code.api.statement.CodeStatement> statements)
      The constructor.
      Parameters:
      parent - the parent.
      statements - the statements.
    • BaseBlockInitializer

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

    • getParent

      public BaseType getParent()
      Specified by:
      getParent in interface io.github.mmm.code.api.block.CodeBlockInitializer
      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.type.CodeType, io.github.mmm.code.api.block.CodeBlockInitializer>
    • setParent

      public void setParent(BaseType parent)
      Parameters:
      parent - the new value of getParent().
    • isStatic

      public boolean isStatic()
      Specified by:
      isStatic in interface io.github.mmm.code.api.block.CodeBlockInitializer
    • setStatic

      public void setStatic(boolean isStatic)
      Specified by:
      setStatic in interface io.github.mmm.code.api.block.CodeBlockInitializer
    • getVariableFromParent

      protected io.github.mmm.code.api.expression.CodeVariable getVariableFromParent(String name)
      Specified by:
      getVariableFromParent in class BaseBlock
      Parameters:
      name - the name of the requested CodeVariable.
      Returns:
      the CodeVariable declared by the parent node with the given name or null if not found.
    • copy

      public BaseBlockInitializer copy()
      Specified by:
      copy in interface io.github.mmm.code.api.block.CodeBlock
      Specified by:
      copy in interface io.github.mmm.code.api.block.CodeBlockInitializer
      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.type.CodeType, io.github.mmm.code.api.block.CodeBlockInitializer>
    • copy

      public BaseBlockInitializer 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.type.CodeType, io.github.mmm.code.api.block.CodeBlockInitializer>
    • writePrefix

      protected void writePrefix(Appendable sink, String newline, String defaultIndent, String currentIndent) throws IOException
      Description copied from class: BaseBlock
      Writes a prefix e.g. for loops.
      Overrides:
      writePrefix in class BaseBlock
      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 indent will be appended.
      Throws:
      IOException - if thrown by Appendable.