Class BaseFile

All Implemented Interfaces:
io.github.mmm.code.api.CodeFile, io.github.mmm.code.api.CodePathElement, io.github.mmm.code.api.CodeWithContext, io.github.mmm.code.api.copy.CodeNodeItemCopyable<io.github.mmm.code.api.CodePackage, io.github.mmm.code.api.CodeFile>, io.github.mmm.code.api.element.CodeElement, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithComment, io.github.mmm.code.api.item.CodeItemWithQualifiedName, io.github.mmm.code.api.item.CodeItemWithQualifiedNameAndParentPackage, io.github.mmm.code.api.item.CodeMutableItem, io.github.mmm.code.api.item.CodeMutableItemWithComment, io.github.mmm.code.api.item.CodeMutableItemWithQualifiedName, io.github.mmm.code.api.node.CodeNode, io.github.mmm.code.api.node.CodeNodeItem, io.github.mmm.code.api.node.CodeNodeWithFileWriting, io.github.mmm.code.api.object.CodeMutable

public final class BaseFile extends BasePathElement implements io.github.mmm.code.api.CodeFile
Base implementation of CodeFile.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Constructor Details

  • Method Details

    • 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 BaseElement
    • getParent

      public BasePackage 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.CodePackage, io.github.mmm.code.api.CodeFile>
      Specified by:
      getParent in interface io.github.mmm.code.api.CodePathElement
    • isFile

      public boolean isFile()
      Specified by:
      isFile in interface io.github.mmm.code.api.CodePathElement
    • getExtension

      public String getExtension()
      Specified by:
      getExtension in interface io.github.mmm.code.api.CodeFile
    • getTypes

      public List<BaseType> getTypes()
      Specified by:
      getTypes in interface io.github.mmm.code.api.CodeFile
    • getType

      public io.github.mmm.code.api.type.CodeType getType(String simpleName)
      Parameters:
      simpleName - the simple name of the requested BaseType recursively contained in this BaseFile.
      Returns:
      the requested BaseType or null if not found.
    • getType

      public io.github.mmm.code.api.type.CodeType getType(String simpleName, boolean init)
      Parameters:
      simpleName - the simple name of the requested BaseType recursively contained in this BaseFile.
      init - - true to ensure the child types are properly initialized and the result is adequate, false otherwise (to avoid initialization e.g. for internal calls during initialization).
      Returns:
      the requested BaseType or null if not found.
    • getType

      public io.github.mmm.code.api.type.CodeType getType(String simpleName, boolean init, boolean resolve)
      Parameters:
      simpleName - the simple name of the requested BaseType to resolve in the context of this BaseFile.
      init - - true to ensure the child types are properly initialized and the result is adequate, false otherwise (to avoid initialization e.g. for internal calls during initialization).
      resolve - - true to resolve the requested BaseType in the context of this file, false otherwise (to only search for files contained in this file like getType(String, boolean)).
      Returns:
      the requested BaseType or null if not found.
    • getType

      public BaseType getType()
      Specified by:
      getType in interface io.github.mmm.code.api.CodeFile
    • getImports

      public BaseImports getImports()
      Specified by:
      getImports in interface io.github.mmm.code.api.CodeFile
    • getReflectiveObject

      public Class<?> getReflectiveObject()
      Specified by:
      getReflectiveObject in interface io.github.mmm.code.api.CodeFile
      Specified by:
      getReflectiveObject in interface io.github.mmm.code.api.item.CodeMutableItem
      Overrides:
      getReflectiveObject in class BaseMutableItem
    • getSourceCodeObject

      public BaseFile getSourceCodeObject()
      Overrides:
      getSourceCodeObject in class BaseElement
      Returns:
      the optional internal CodeItem representing the source-code (to merge). Otherwise null. This is an internal API. Do not use or rely on it from outside.
    • copy

      public BaseFile copy()
      Specified by:
      copy in interface io.github.mmm.code.api.element.CodeElement
      Specified by:
      copy in interface io.github.mmm.code.api.CodeFile
      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.CodePackage, io.github.mmm.code.api.CodeFile>
    • copy

      public BaseFile copy(io.github.mmm.code.api.copy.CodeCopyMapper mapper)
      Specified by:
      copy in interface io.github.mmm.code.api.CodeFile
      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.CodePackage, io.github.mmm.code.api.CodeFile>
    • doWrite

      protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException
      Overrides:
      doWrite in class BaseElement
      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)
    • write

      public void write(Path targetFolder)
      Specified by:
      write in interface io.github.mmm.code.api.node.CodeNodeWithFileWriting
    • write

      public void write(Path targetFolder, Charset encoding)
      Specified by:
      write in interface io.github.mmm.code.api.node.CodeNodeWithFileWriting