Class BaseItem

java.lang.Object
io.github.mmm.code.base.item.BaseItem
All Implemented Interfaces:
io.github.mmm.code.api.item.CodeItem
Direct Known Subclasses:
BaseComment, BaseExpression, BaseImport, BaseImportItem, BaseMutableItem, BaseOperator, BaseStatement

public abstract class BaseItem extends Object implements io.github.mmm.code.api.item.CodeItem
Base implementation of CodeItem.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Field Summary

    Fields inherited from interface io.github.mmm.code.api.item.CodeItem

    DEFAULT_INDENT, DEFAULT_NEWLINE
  • Constructor Summary

    Constructors
    Constructor
    Description
    The constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language)
     
    protected static io.github.mmm.code.api.type.CodeType
    getOwningType(io.github.mmm.code.api.item.CodeItem element)
     
     
    protected static String
    getSpaces(int length)
     
     
    final void
    write(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.github.mmm.code.api.item.CodeItem

    getLanguage, write, write, write, write, write
  • Constructor Details

    • BaseItem

      public BaseItem()
      The constructor.
  • Method Details

    • write

      public final void write(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language)
      Specified by:
      write in interface io.github.mmm.code.api.item.CodeItem
    • doWrite

      protected abstract void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException
      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)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSourceCode

      public String getSourceCode()
      Specified by:
      getSourceCode in interface io.github.mmm.code.api.item.CodeItem
    • getOwningType

      protected static io.github.mmm.code.api.type.CodeType getOwningType(io.github.mmm.code.api.item.CodeItem element)
      Parameters:
      element - the CodeItem.
      Returns:
      the owning CodeType.
    • getSpaces

      protected static String getSpaces(int length)
      Parameters:
      length - the number of spaces requested.
      Returns:
      a String of the given length only containing whitespaces.