Class PythonCodeArtifact

java.lang.Object
net.ssehub.easy.instantiation.core.model.artifactModel.CompositeArtifact
net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact
net.ssehub.easy.instantiation.python.codeArtifacts.PythonCodeArtifact
All Implemented Interfaces:
net.ssehub.easy.instantiation.core.model.artifactModel.IArtifact, net.ssehub.easy.instantiation.core.model.artifactModel.IArtifactChangedListener, net.ssehub.easy.instantiation.core.model.artifactModel.IFileSystemArtifact, net.ssehub.easy.instantiation.core.model.vilTypes.IActualValueProvider, net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider, net.ssehub.easy.instantiation.core.model.vilTypes.IVilType, IPythonCodeArtifact, Storable

public class PythonCodeArtifact extends net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact implements IPythonCodeArtifact, net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider, Storable
Represents the Python code artifact in VTL.
Author:
Kevin Schaperjahn
  • Field Details

  • Constructor Details

    • PythonCodeArtifact

      public PythonCodeArtifact(File file, net.ssehub.easy.instantiation.core.model.artifactModel.ArtifactModel model)
    • PythonCodeArtifact

      public PythonCodeArtifact(String moduleName)
  • Method Details

    • create

      public static PythonCodeArtifact create(String moduleName)
    • enableAutoStore

      public boolean enableAutoStore()
      Specified by:
      enableAutoStore in interface net.ssehub.easy.instantiation.core.model.artifactModel.IArtifact
    • enableContentStore

      public boolean enableContentStore()
      Specified by:
      enableContentStore in interface net.ssehub.easy.instantiation.core.model.artifactModel.IArtifact
    • disable

      public PythonCodeArtifact disable()
    • enable

      public PythonCodeArtifact enable()
    • convert

      public static net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact convert(String val) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException
    • convert

      public static PythonCodeArtifact convert(net.ssehub.easy.instantiation.core.model.artifactModel.IFileSystemArtifact val)
    • convert

      public static PythonCodeArtifact convert(net.ssehub.easy.instantiation.core.model.artifactModel.Path path) throws net.ssehub.easy.instantiation.core.model.common.VilException
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException
    • determineActualValue

      public Object determineActualValue(Object object)
      Specified by:
      determineActualValue in interface net.ssehub.easy.instantiation.core.model.vilTypes.IActualValueProvider
      Overrides:
      determineActualValue in class net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact
    • getModule

      public String getModule()
    • getElementCount

      public int getElementCount()
      Specified by:
      getElementCount in interface Storable
    • toImports

      public String toImports()
    • toHeader

      public String toHeader()
    • storeImports

      protected void storeImports(net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out)
    • storeHeader

      protected void storeHeader(net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out)
    • store

      public void store() throws net.ssehub.easy.instantiation.core.model.common.VilException
      Specified by:
      store in interface net.ssehub.easy.instantiation.core.model.artifactModel.IArtifact
      Overrides:
      store in class net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException
    • store

      public void store(net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out)
      Specified by:
      store in interface Storable
    • delete

      public void delete() throws net.ssehub.easy.instantiation.core.model.common.VilException
      Specified by:
      delete in interface net.ssehub.easy.instantiation.core.model.artifactModel.IArtifact
      Overrides:
      delete in class net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException
    • setComment

      public PythonCodeArtifact setComment(String comment)
    • add

      public void add(String text)
    • addRaw

      public void addRaw(String text, boolean indent)
    • addClass

      public PythonCodeClass addClass(String name)
      Adds a class without comment.
      Parameters:
      name - the name of the class
      Returns:
      the class for chaining
    • addClass

      public PythonCodeClass addClass(String name, String comment)
      Adds a class with comment.
      Parameters:
      name - the name of the class
      comment - the comment for the class
      Returns:
      the class for chaining
    • addEnum

      public PythonCodeEnum addEnum(String name)
      Adds an enum without comment.
      Parameters:
      name - the name of the enum
      Returns:
      the enum for chaining
    • addEnum

      public PythonCodeEnum addEnum(String name, String comment)
      Adds an enum with comment.
      Parameters:
      name - the name of the enum
      comment - the comment for the enum
      Returns:
      the enum for chaining
    • addAssign

      public PythonCodeAssign addAssign(String varName, String expr)
    • addAssign

      public PythonCodeAssign addAssign(String varName, String type, String expr)
    • addMatch

      public PythonCodeMatch addMatch(String expr)
    • addFunc

      public PythonCodeFunction addFunc(String name)
      Description copied from interface: IPythonCodeArtifact
      Adds a function.
      Specified by:
      addFunc in interface IPythonCodeArtifact
      Parameters:
      name - the name of the function
      Returns:
      the function (for chaining)
    • addFunc

      public PythonCodeFunction addFunc(String name, String comment)
      Description copied from interface: IPythonCodeArtifact
      Adds a function.
      Specified by:
      addFunc in interface IPythonCodeArtifact
      Parameters:
      name - the name of the function
      comment - the documentation comment of the function
      Returns:
      the function (for chaining)
    • addSysPathInsert

      public PythonCodeFnCall addSysPathInsert(int position, String path)
      Adds a call to sys.path.insert with given position adding path to the system path.
      Parameters:
      position - the position where to add the path
      path - the path to add
      Returns:
      the function call for chaining
    • addTypeAlias

      public PythonCodeTypeAlias addTypeAlias(String name, String expr)
    • addCall

      public PythonCodeFnCall addCall(String name)
    • addCall

      public PythonCodeFnCall addCall(String name, PythonCodeImportScope scope)
    • addComment

      public PythonCodeBlock addComment(String comment)
    • addSLComment

      public PythonCodeBlock addSLComment(String comment)
    • addSLComment

      public PythonCodeBlock addSLComment(String comment, boolean enclosed)
    • addEmptyLine

      public void addEmptyLine()
    • addFor

      public PythonCodeForLoop addFor(String element, String array)
    • addFor

      public PythonCodeForLoop addFor(String element, String rangeStart, String rangeEnd)
    • addFor

      public PythonCodeForLoop addFor(String element, String rangeStart, String rangeEnd, String rangeStep)
    • addIf

      public PythonCodeAlternative addIf(String condition)
    • addWhile

      public PythonCodeWhileLoop addWhile(String condition)
    • addTry

      public PythonCodeTryBlock addTry()
    • addRaise

      public PythonCodeRaise addRaise(String expr)
    • addWith

      public PythonCodeWith addWith(String expr)
    • addWith

      public PythonCodeWith addWith(String expr, String varName)
    • addDelete

      public PythonCodeDelete addDelete(String varName)
    • addAssert

      public PythonCodeAssert addAssert(String expr)
    • addAssert

      public PythonCodeAssert addAssert(String expr, String msg)
    • addImport

      public PythonCodeImport addImport(String imp)
      Description copied from interface: IPythonCodeArtifact
      Adds a simple import.
      Specified by:
      addImport in interface IPythonCodeArtifact
      Parameters:
      imp - the import
      Returns:
      the import (for chaining)
    • addImport

      public PythonCodeImport addImport(String from, String imp)
      Description copied from interface: IPythonCodeArtifact
      Adds a module-based import.
      Specified by:
      addImport in interface IPythonCodeArtifact
      Parameters:
      from - the owning module
      imp - the import
      Returns:
      the import (for chaining)
    • findMatchingImport

      private IPythonCodeImport findMatchingImport(String imp)
    • validateType

      public void validateType(IPythonCodeTypeSpec type)
      Specified by:
      validateType in interface IPythonCodeArtifact
    • validateFuncCall

      public String validateFuncCall(String name, PythonCodeImportScope scope)
      Specified by:
      validateFuncCall in interface IPythonCodeArtifact
    • registerImport

      public void registerImport(IPythonCodeImport imp, boolean explicit)
      Specified by:
      registerImport in interface IPythonCodeArtifact
    • moveToImports

      public void moveToImports(IPythonCodeImport imp)
      Description copied from interface: IPythonCodeArtifact
      Moves the given import after the last import at the beginning of (this) artifact, or, if there are no imports, to the front.
      Specified by:
      moveToImports in interface IPythonCodeArtifact
      Parameters:
      imp - the import to move