java.lang.Object
de.iip_ecosphere.platform.configuration.aas.IvmlWriter

public class IvmlWriter extends Object
Stores the AAS representation as IVML and also produces the related text file.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • IvmlWriter

      public IvmlWriter()
      Creates a writer to sysout.
    • IvmlWriter

      public IvmlWriter(String fileName) throws IOException
      Creates a writer to the given file.
      Parameters:
      fileName - the file to write to, may be null for none/sysout
      Throws:
      IOException
  • Method Details

    • setNamePrefix

      public IvmlWriter setNamePrefix(String namePrefix)
      Sets an optional prefix for differing type values (usually same as "name").
      Parameters:
      namePrefix - the prefix, may be null for none
      Returns:
      this (builder style)
    • increaseIndent

      private void increaseIndent()
      Increases output indent.
    • decreaseIndent

      private void decreaseIndent()
      Decreases output indent.
    • println

      private void println()
      Writes an empty line.
    • println

      private void println(String text)
      Writes text after indentation.
      Parameters:
      text - the text
    • printlnField

      private void printlnField(String fieldName, Object value, boolean comma)
      Writes a field/value.
      Parameters:
      fieldName - the field name
      value - the field value
      comma - shall a comma be appended
    • printlnField

      private void printlnField(String fieldName, Object value, boolean comma, Object dflt)
      Writes a field/value.
      Parameters:
      fieldName - the field name
      value - the field value
      comma - shall a comma be appended
      dflt - the default value of field skipping the output if value is the same
    • printlnCardinalityField

      private void printlnCardinalityField(String fieldName, int value, boolean comma)
      Writes a cardinality field, only if value is different from integer min value and -1.
      Parameters:
      fieldName - the field name
      value - the field value
      comma - shall a comma be appended
    • printlnStringField

      private void printlnStringField(String fieldName, String value, boolean comma)
      Writes a string-valued field.
      Parameters:
      fieldName - the field name
      value - the field value
      comma - shall a comma be appended
    • quoteIvmlString

      private String quoteIvmlString(String value)
      Quotes a string for IVML.
      Parameters:
      value - the string value
      Returns:
      the quoted/escaped string
    • printEnums

      private void printEnums(AasSpecSummary aasResult)
      Writes the enums in AAS result.
      Parameters:
      aasResult - the AAS result
    • emit

      private boolean emit(AbstractAasElement elem)
      Returns whether elem shall be emitted.
      Parameters:
      elem - the element
      Returns:
      true for emit, false else
    • printTypes

      private void printTypes(AasSpecSummary aasResult)
      Writes the types in AAS result.
      Parameters:
      aasResult - the AAS result
    • getIvmlType

      private String getIvmlType(AasType type)
      Returns the IVML type of type.
      Parameters:
      type - the type
      Returns:
      the IVML type, may be null
    • getIvmlType

      private String getIvmlType(AasField field)
      Returns the IVML type of field. Adjusts multi-valued field type to comply with the oktoflow metamodel and the generation.
      Parameters:
      field - the field
      Returns:
      the IVML type
    • printField

      private void printField(AasField field, AasType type)
      Prints field of type.
      Parameters:
      field - the field
      type - the type
    • printImports

      private void printImports(AasSpecSummary aasResult, String projectName)
      Prints the imports.
      Parameters:
      aasResult - the AAS result
      projectName - the own project name
    • addImport

      private void addImport(AasImports.Import imp, Set<AasImports.Import> imports, String projectName)
      Adds an import. May modify selfImports as a side effect.
      Parameters:
      imp - the import (may be null)
      imports - the set of imports to be filled as a side effect
      projectName - the own project name
      See Also:
    • toIvml

      public void toIvml(AasSpecSummary aasResult)
      Writes IVML for the given aasResult.
      Parameters:
      aasResult - the AAS result
    • getProjectName

      public String getProjectName(AasSpecSummary aasResult)
      Returns the IVML project name for aasResult.
      Parameters:
      aasResult - the AAS result
      Returns:
      the project name
    • toIvmlText

      public void toIvmlText(AasSpecSummary aasResult) throws IOException
      Writes IVML for the given aasResult. Only applied if this writer was created with a file name IvmlWriter(String).
      Parameters:
      aasResult - the AAS result
      Throws:
      IOException
    • validateName

      private String validateName(String idShort)
      Validates an idShort before output.
      Parameters:
      idShort - the idshort
      Returns:
      the idshort
    • validateVariableName

      private String validateVariableName(String idShort)
      Validates an idShort before output.
      Parameters:
      idShort - the idshort
      Returns:
      the idshort
    • isNoIdShort

      private boolean isNoIdShort(String idShort)
      Returns whether idShort indicates that there shall be none.
      Parameters:
      idShort - the idshort to test
      Returns:
      true for no idShort, false else
    • getLogger

      private static de.iip_ecosphere.platform.support.logging.Logger getLogger()
      Returns the logger instance for this class.
      Returns:
      the logger instance