Class IvmlWriter
java.lang.Object
de.iip_ecosphere.platform.configuration.easyProducer.aas.IvmlWriter
Stores the AAS representation as IVML and also produces the related text file.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate Consumer<PrintStream> private Stringprivate intprivate Stringprivate Stringprivate PrintStreamprivate Set<AasImports.Import> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a writer to sysout.IvmlWriter(String fileName) Creates a writer to the given file. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddImport(AasImports.Import imp, Set<AasImports.Import> imports, String projectName) Adds an import.private voidDecreases output indent.private booleanemit(AbstractAasElement elem) Returns whetherelemshall be emitted.private StringgetIvmlType(AasField field) Returns the IVML type offield.private StringgetIvmlType(AasType type) Returns the IVML type oftype.private static de.iip_ecosphere.platform.support.logging.LoggerReturns the logger instance for this class.getProjectName(AasSpecSummary aasResult) Returns the IVML project name foraasResult.private voidIncreases output indent.private booleanisNoIdShort(String idShort) Returns whetheridShortindicates that there shall be none.private voidprintEnums(AasSpecSummary aasResult) Writes the enums in AAS result.private voidprintField(AasField field, AasType type) Printsfieldoftype.private voidprintImports(AasSpecSummary aasResult, String projectName) Prints the imports.private voidprintln()Writes an empty line.private voidWritestextafter indentation.private voidprintlnCardinalityField(String fieldName, int value, boolean comma) Writes a cardinality field, only ifvalueis different from integer min value and-1.private voidprintlnField(String fieldName, Object value, boolean comma) Writes a field/value.private voidprintlnField(String fieldName, Object value, boolean comma, Object dflt) Writes a field/value.private voidprintlnStringField(String fieldName, String value, boolean comma) Writes a string-valued field.private voidprintTypes(AasSpecSummary aasResult) Writes the types in AAS result.private StringquoteIvmlString(String value) Quotes a string for IVML.setNamePrefix(String namePrefix) Sets an optional prefix for differing type values (usually same as "name").voidtoIvml(AasSpecSummary aasResult) Writes IVML for the givenaasResult.voidtoIvmlText(AasSpecSummary aasResult) Writes IVML for the givenaasResult.private StringvalidateName(String idShort) Validates an idShort before output.private StringvalidateVariableName(String idShort) Validates an idShort before output.
-
Field Details
-
BASIC_IVML_NAME
-
out
-
indent
-
closer
-
selfImports
-
idCounter
private int idCounter -
fileName
-
namePrefix
-
-
Constructor Details
-
IvmlWriter
public IvmlWriter()Creates a writer to sysout. -
IvmlWriter
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
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
Writestextafter indentation.- Parameters:
text- the text
-
printlnField
Writes a field/value.- Parameters:
fieldName- the field namevalue- the field valuecomma- shall a comma be appended
-
printlnField
Writes a field/value.- Parameters:
fieldName- the field namevalue- the field valuecomma- shall a comma be appendeddflt- the default value of field skipping the output if value is the same
-
printlnCardinalityField
Writes a cardinality field, only ifvalueis different from integer min value and-1.- Parameters:
fieldName- the field namevalue- the field valuecomma- shall a comma be appended
-
printlnStringField
Writes a string-valued field.- Parameters:
fieldName- the field namevalue- the field valuecomma- shall a comma be appended
-
quoteIvmlString
Quotes a string for IVML.- Parameters:
value- the string value- Returns:
- the quoted/escaped string
-
printEnums
Writes the enums in AAS result.- Parameters:
aasResult- the AAS result
-
emit
Returns whetherelemshall be emitted.- Parameters:
elem- the element- Returns:
truefor emit,falseelse
-
printTypes
Writes the types in AAS result.- Parameters:
aasResult- the AAS result
-
getIvmlType
Returns the IVML type oftype.- Parameters:
type- the type- Returns:
- the IVML type, may be null
-
getIvmlType
Returns the IVML type offield. Adjusts multi-valued field type to comply with the oktoflow metamodel and the generation.- Parameters:
field- the field- Returns:
- the IVML type
-
printField
Printsfieldoftype.- Parameters:
field- the fieldtype- the type
-
printImports
Prints the imports.- Parameters:
aasResult- the AAS resultprojectName- the own project name
-
addImport
Adds an import. May modifyselfImportsas a side effect.- Parameters:
imp- the import (may be null)imports- the set of imports to be filled as a side effectprojectName- the own project name- See Also:
-
toIvml
Writes IVML for the givenaasResult.- Parameters:
aasResult- the AAS result
-
getProjectName
Returns the IVML project name foraasResult.- Parameters:
aasResult- the AAS result- Returns:
- the project name
-
toIvmlText
Writes IVML for the givenaasResult. Only applied if this writer was created with a file nameIvmlWriter(String).- Parameters:
aasResult- the AAS result- Throws:
IOException
-
validateName
Validates an idShort before output.- Parameters:
idShort- the idshort- Returns:
- the idshort
-
validateVariableName
Validates an idShort before output.- Parameters:
idShort- the idshort- Returns:
- the idshort
-
isNoIdShort
Returns whetheridShortindicates that there shall be none.- Parameters:
idShort- the idshort to test- Returns:
truefor no idShort,falseelse
-
getLogger
private static de.iip_ecosphere.platform.support.logging.Logger getLogger()Returns the logger instance for this class.- Returns:
- the logger instance
-