Class IVMLWriter
java.lang.Object
net.ssehub.easy.varModel.model.AbstractVisitor
net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
net.ssehub.easy.varModel.persistency.IVMLWriter
- All Implemented Interfaces:
IConstraintTreeVisitor,ICustomDatatypeVisitor,IModelVisitor,IValueVisitor
- Direct Known Subclasses:
ConfigurableIVMLWriter,ConstraintSplitWriter
Writer for writing the variability model to an IVML output file. Please note
that this writer creates output regardless of the correctness of the semantics
of the model being visited. However, if the full IVML infrastructure including
the IVML parser is used and given interfaces of this model are used properly,
the output will be valid. In case that the classes in this model package are
directly used from external code, it is strongly advised to use the
IvmlValidationVisitor to check the validity
of the visited model before producing output.- Author:
- El-Sharkawy, Marcel Lueder, Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceControls emitting variables and their values.Nested classes/interfaces inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
AbstractVarModelWriter.DefaultSpace -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stack<OCLFeatureCall> private booleanprivate IVMLWriter.EmitFilterprivate booleanprivate booleanprivate booleanprivate DecisionVariableDeclarationprivate Stack<ConstraintSyntaxTree> private static final List<IVMLWriter> private VariableUsageFields inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
DUMMY_PARENT -
Constructor Summary
ConstructorsModifierConstructorDescriptionIVMLWriter(Writer writer) Class for writingivmloutput appropriate for the EASy-Producer tool.protectedIVMLWriter(Writer writer, boolean emitComments) Creates a writer instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDoes the formatting of an OCL feature call and allows for overwriting.protected voidbeforeNestedElement(Object element) This method is called before a nested element is emitted.private voidDuplicates the last comment on the stack for nesting.booleanReturns whether comments are emitted by this writer.protected voidemitDecisionVariableDeclarationDefault(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue) Emits the default value of a decision variable declaration (for extension).private voidemitDecisionVariableDeclarationExpression(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue) Emits the expression part of a variable declaration without the statement part.private voidEmits the type of an initializer if required.protected voidendWritingCompound(Compound compound) Method for writing a compound, second part.protected voidendWritingProject(Project project) Method for writing a project, second part.voidforceComponundTypes(boolean forceCompoundTypes) Forces the output of compound types and bypasses the automatic detection.static final IVMLWritergetInstance(Writer writer) Obtains an instance from the pool (always emitting comments).private CommentReturns the last comment from the internal comment stack.private booleanDetermines whether (on-demand) qualification of the givenvaris needed, i.e., whether its qualified name shall be printed out.private booleanneedsQualificationThroughContext(Object context, String name, AbstractVariable var, boolean exclude) Returns whether the variable namenameofvarneeds qualification within its contextcontext.private CommentRemoves the comment on top of the stack.protected voidPrints default spaces.protected voidprocessVersion(net.ssehub.easy.basics.modelManagement.Version version) Processes a version information.static final voidreleaseInstance(IVMLWriter writer) Releases an instance to the pool.voidsetEmitFilter(IVMLWriter.EmitFilter emitFilter) Defines an filter controlling emitting of individual variables/slots.voidsetEmitProjectFreezeDot(boolean emitProjectFreezeDot) Enables/disables whether a project freeze on itself shall be emitted with a ".".voidsetFormatInitializer(boolean formatInitializer) Defines whether initializers shall be formatted.private voidsetLastComment(Comment comment) Defines the next comment on top of the stack (combined pop/push).protected voidstartWritingCompound(Compound compound) Method for writing a compound, first part.protected voidstartWritingProject(Project project) Method for writing a project, first part.voidvisitAnnotationVariable(AttributeVariable variable) Visits aAttributeVariable.voidvisitAttribute(Attribute attribute) Method for visiting an attribute.voidvisitAttributeAssignment(AttributeAssignment assignment) Visits an attribute assignment.voidVisits the block.voidvisitBooleanValue(BooleanValue value) This method is used for visiting BooleanValue.voidvisitComment(Comment comment) Visits a comment.voidvisitComment(Comment comment) Method for visiting a comment.voidvisitCompound(Compound compound) Method for visiting a compound.voidvisitCompoundAccess(CompoundAccess access) Visits a compound access node.voidVisits a compound access statement (may occur in freeze blocks.private intvisitCompoundDecisionVariableContainer(IDecisionVariableContainer cont, CompoundValue value, int printed, Set<String> done) Visits a compound decision variable container for output of configuration values.voidvisitCompoundInitializer(CompoundInitializer initializer) Visits a compound initializer.private intvisitCompoundRefines(Compound comp, CompoundValue value, int count, Set<String> done) CallsvisitCompoundDecisionVariableContainer(IDecisionVariableContainer, CompoundValue, int, java.util.Set)forcompand for all its refines.voidvisitCompoundValue(CompoundValue value) This method is used for visiting CompoundValue.voidvisitConstraint(Constraint constraint) Method for visiting a constraint.voidvisitContainerInitializer(ContainerInitializer initializer) Visits a container initializer.voidVisits a container operation call (e.g.voidThis method is used for visiting ContainerValue.voidThis method is used for visiting a decision variable declaration.voidvisitDeferInitExpression(DeferInitExpression expression) Visits a default init expression.voidvisitDerivedDatatype(DerivedDatatype datatype) Method for visiting a derived datatype.voidMethod for visiting an enum.voidvisitEnumLiteral(EnumLiteral literal) Method for visiting an enum literal.voidvisitEnumValue(EnumValue value) This method is used for visiting EnumValue.voidvisitFreezeBlock(FreezeBlock freeze) Method for visiting a freeze block.voidvisitIfThen(IfThen ifThen) Visits an if-then-else expression.voidvisitIntValue(IntValue value) This method is used for visiting IntValue.voidVisits a let expression.voidvisitMetaTypeValue(MetaTypeValue value) This method is used for visiting meta type value.voidvisitMultiAndExpression(MultiAndExpression expression) Visits a multi-and expression.voidvisitNullValue(NullValue value) This method is used for visiting a null value.voidVisits an OCL feature call.voidMethod for visiting an operation definition.voidvisitParenthesis(Parenthesis parenthesis) Visits a parenthesis.voidMethod for visiting a partial evaluation block.voidvisitProject(Project project) Method for visiting a project.voidvisitProjectImport(ProjectImport pImport) This method is used for visiting a ProjectImport.voidMethod for visiting a project interface.voidvisitRealValue(RealValue value) This method is used for visiting RealValue.voidvisitReference(Reference reference) Method for visiting a reference.voidvisitReferenceValue(ReferenceValue referenceValue) This method is used for visiting referenceValue.voidVisits self.voidvisitSequence(Sequence sequence) Method for visiting a sequence.voidMethod for visiting a set.voidvisitStringValue(StringValue value) This method is used for visiting StringValue.voidvisitVariable(Variable variable) Visits a variable.voidvisitVersionValue(VersionValue value) This method is used for visiting a version value.protected booleanwriteValue(Value value) Returns whether a certain value shall be written.Methods inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
addParent, appendIndentation, appendOutput, appendOutput, considerOclCompliance, decreaseAdditionalIndentation, emitConstraintExpression, flush, getExpressionContext, getIndentation, getIvmlIndentStep, getLogger, getParent, getParent, getParent, getParentCount, getUseIvmlWhitespace, getWriter, increaseAdditionalIndentation, removeLastParent, setExpressionContext, setIndentationStep, setIndentStep, setOclCompliance, setUseIvmlWhitespace, setUseWhitespaces, setWriter, visitConstantValue, visitConstraintValue, visitOrderedEnum, visitUnresolvedExpression
-
Field Details
-
POOL
-
nestedValues
-
nestedExpressions
-
callStack
-
emitComments
private boolean emitComments -
lastComment
-
handled
-
variableUsage
-
formatInitializer
private boolean formatInitializer -
forceCompoundTypes
private boolean forceCompoundTypes -
inDecl
-
emitFilter
-
emitProjectFreezeDot
private boolean emitProjectFreezeDot
-
-
Constructor Details
-
IVMLWriter
Class for writingivmloutput appropriate for the EASy-Producer tool.- Parameters:
writer- Writer which should be used for writing the output.
-
IVMLWriter
Creates a writer instance. Due to the pooling mechanism, disabling comments can only be done by a non-pooled subclass.- Parameters:
writer- the writer which should be used for writing the outputemitComments- whether comments shall be emitted or ignored
-
-
Method Details
-
setEmitProjectFreezeDot
public void setEmitProjectFreezeDot(boolean emitProjectFreezeDot) Enables/disables whether a project freeze on itself shall be emitted with a ".".- Parameters:
emitProjectFreezeDot-truefor enable,falseelse
-
setEmitFilter
Defines an filter controlling emitting of individual variables/slots.- Parameters:
emitFilter- the emit filter
-
setFormatInitializer
public void setFormatInitializer(boolean formatInitializer) Defines whether initializers shall be formatted.- Parameters:
formatInitializer-trueif initializers shall be formatted,falseelse
-
forceComponundTypes
public void forceComponundTypes(boolean forceCompoundTypes) Forces the output of compound types and bypasses the automatic detection.- Parameters:
forceCompoundTypes- iftrue, compound types are always emitted at creation,falseelse
-
emitComments
public boolean emitComments()Description copied from class:AbstractVarModelWriterReturns whether comments are emitted by this writer.- Specified by:
emitCommentsin classAbstractVarModelWriter- Returns:
trueif comments are emitted,falseelse
-
getInstance
Obtains an instance from the pool (always emitting comments).- Parameters:
writer- the target output writer- Returns:
- the instance, to be released by
releaseInstance(IVMLWriter)
-
releaseInstance
Releases an instance to the pool.- Parameters:
writer- the instance to be released
-
printDefaultSpace
Description copied from class:AbstractVarModelWriterPrints default spaces.- Specified by:
printDefaultSpacein classAbstractVarModelWriter- Parameters:
location- the intended location of the space
-
startWritingProject
Description copied from class:AbstractVarModelWriterMethod for writing a project, first part.- Specified by:
startWritingProjectin classAbstractVarModelWriter- Parameters:
project- The project which should be saved.
-
endWritingProject
Description copied from class:AbstractVarModelWriterMethod for writing a project, second part.- Specified by:
endWritingProjectin classAbstractVarModelWriter- Parameters:
project- The project which should be saved.
-
processVersion
protected void processVersion(net.ssehub.easy.basics.modelManagement.Version version) Description copied from class:AbstractVarModelWriterProcesses a version information.- Specified by:
processVersionin classAbstractVarModelWriter- Parameters:
version- the version to be processed
-
visitProject
Description copied from interface:IModelVisitorMethod for visiting a project.- Specified by:
visitProjectin interfaceIModelVisitor- Overrides:
visitProjectin classAbstractVarModelWriter- Parameters:
project- The project which should be visited.
-
visitProjectImport
Description copied from interface:IModelVisitorThis method is used for visiting a ProjectImport.- Parameters:
pImport- One ProjectImport which should be visited.
-
startWritingCompound
Description copied from class:AbstractVarModelWriterMethod for writing a compound, first part.- Specified by:
startWritingCompoundin classAbstractVarModelWriter- Parameters:
compound- The compound which should be saved.
-
endWritingCompound
Description copied from class:AbstractVarModelWriterMethod for writing a compound, second part.- Specified by:
endWritingCompoundin classAbstractVarModelWriter- Parameters:
compound- The compound which should be saved.
-
visitEnum
Method for visiting an enum.- Specified by:
visitEnumin interfaceICustomDatatypeVisitor- Overrides:
visitEnumin classAbstractVisitor- Parameters:
eenum- The enum which should be visited.
-
visitEnumValue
Description copied from interface:IValueVisitorThis method is used for visiting EnumValue.- Parameters:
value- One EnumValue which should be visited.
-
visitDecisionVariableDeclaration
Description copied from interface:IModelVisitorThis method is used for visiting a decision variable declaration.- Parameters:
decl- One declaration which should be visited.
-
emitDecisionVariableDeclarationExpression
private void emitDecisionVariableDeclarationExpression(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue) Emits the expression part of a variable declaration without the statement part.- Parameters:
decl- the declaration to be emitteddefaultValue- an explicitly given default value that supersedes the one ofdecl(may be null to force the one given bydecl)
-
emitDecisionVariableDeclarationDefault
protected void emitDecisionVariableDeclarationDefault(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue) Emits the default value of a decision variable declaration (for extension).- Parameters:
decl- the declarationdefaultValue- the specified default value
-
visitStringValue
Description copied from interface:IValueVisitorThis method is used for visiting StringValue.- Parameters:
value- One StringValue which should be visited.
-
emitType
Emits the type of an initializer if required. ConsidersforceCompoundTypes,nestedValuesandnestedExpressions.- Parameters:
type- the actual type of the elementconsiderValues- whethernestedValuesornestedExpressionsshall be considered
-
visitCompoundValue
Description copied from interface:IValueVisitorThis method is used for visiting CompoundValue.- Parameters:
value- One CompoundValue which should be visited.
-
visitCompoundRefines
CallsvisitCompoundDecisionVariableContainer(IDecisionVariableContainer, CompoundValue, int, java.util.Set)forcompand for all its refines.- Parameters:
comp- the compoundvalue- the compound valuecount- the countdone- already processed (or null)- Returns:
- the aggregated count
-
writeValue
Returns whether a certain value shall be written.- Parameters:
value- the value to be checked- Returns:
trueif the value shall be written,falseelse
-
visitCompoundDecisionVariableContainer
private int visitCompoundDecisionVariableContainer(IDecisionVariableContainer cont, CompoundValue value, int printed, Set<String> done) Visits a compound decision variable container for output of configuration values.- Parameters:
cont- the containervalue- the container valueprinted- the number of printed elements so fardone- already processed slots (may be null if not relevant, modified as a side effect)- Returns:
- the number of printed elements
-
visitIntValue
Description copied from interface:IValueVisitorThis method is used for visiting IntValue.- Parameters:
value- One IntValue which should be visited.
-
visitRealValue
Description copied from interface:IValueVisitorThis method is used for visiting RealValue.- Parameters:
value- One RealValue which should be visited.
-
visitBooleanValue
Description copied from interface:IValueVisitorThis method is used for visiting BooleanValue.- Parameters:
value- One BooleanValue which should be visited.
-
visitContainerValue
Description copied from interface:IValueVisitorThis method is used for visiting ContainerValue.- Parameters:
value- One CompoundValue which should be visited.
-
visitCompoundInitializer
Visits a compound initializer.- Parameters:
initializer- the compound initializer node
-
visitContainerInitializer
Visits a container initializer.- Parameters:
initializer- the container initializer node
-
visitAttribute
Description copied from interface:IModelVisitorMethod for visiting an attribute.- Parameters:
attribute- The attribute which should be visited.
-
visitFreezeBlock
Description copied from interface:IModelVisitorMethod for visiting a freeze block.- Specified by:
visitFreezeBlockin interfaceIModelVisitor- Overrides:
visitFreezeBlockin classAbstractVarModelWriter- Parameters:
freeze- The freeze block which should be visited.
-
visitOperationDefinition
Description copied from interface:IModelVisitorMethod for visiting an operation definition.- Parameters:
opdef- The operation definition which should be visited.
-
visitPartialEvaluationBlock
Description copied from interface:IModelVisitorMethod for visiting a partial evaluation block.- Specified by:
visitPartialEvaluationBlockin interfaceIModelVisitor- Overrides:
visitPartialEvaluationBlockin classAbstractVarModelWriter- Parameters:
block- The partial evaluation block which should be visited.
-
visitProjectInterface
Description copied from interface:IModelVisitorMethod for visiting a project interface.- Parameters:
iface- The interface which should be visited.
-
visitDerivedDatatype
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a derived datatype.- Parameters:
datatype- The datatype which should be visited.
-
visitEnumLiteral
Description copied from interface:ICustomDatatypeVisitorMethod for visiting an enum literal.- Parameters:
literal- The literal which should be visited.
-
visitReference
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a reference.- Parameters:
reference- The reference which should be visited.
-
visitSequence
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a sequence.- Parameters:
sequence- The sequence which should be visited.
-
visitSet
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a set.- Parameters:
set- The set which should be visited.
-
visitReferenceValue
Description copied from interface:IValueVisitorThis method is used for visiting referenceValue.- Parameters:
referenceValue- One referenceValue which should be visited.
-
needsQualification
Determines whether (on-demand) qualification of the givenvaris needed, i.e., whether its qualified name shall be printed out.- Parameters:
var- the variable- Returns:
trueif it needs to be qualified,falseelse
-
needsQualificationThroughContext
private boolean needsQualificationThroughContext(Object context, String name, AbstractVariable var, boolean exclude) Returns whether the variable namenameofvarneeds qualification within its contextcontext.- Parameters:
context- the context (only considered ifIDecisionVariableContainername- the name of the variable to determine qualification need forvar- the variable itselfexclude- whether this call is intended to exclude (true) the qualification ofvaror whether it shall search for the existence ofnameincontext(false)- Returns:
- whether
varneeds qualification ifexcludeistrueor whethernamewas found incontextifexcludeisfalse
-
visitVariable
Description copied from interface:IConstraintTreeVisitorVisits a variable.- Parameters:
variable- the variable which should be visited
-
visitAnnotationVariable
Description copied from interface:IConstraintTreeVisitorVisits aAttributeVariable.- Parameters:
variable- the attribute variable which should be visited
-
visitParenthesis
Description copied from interface:IConstraintTreeVisitorVisits a parenthesis.- Parameters:
parenthesis- the parenthesis which should be visited
-
visitOclFeatureCall
Description copied from interface:IConstraintTreeVisitorVisits an OCL feature call.- Parameters:
call- the feature call which should be visited
-
appendOCLFeatureCall
Does the formatting of an OCL feature call and allows for overwriting.- Parameters:
call- the callhint- the formatting hint for the call
-
visitDeferInitExpression
Description copied from interface:IConstraintTreeVisitorVisits a default init expression.- Parameters:
expression- the expression
-
visitMultiAndExpression
Description copied from interface:IConstraintTreeVisitorVisits a multi-and expression.- Parameters:
expression- the expression to be visited
-
visitConstraint
Description copied from interface:IModelVisitorMethod for visiting a constraint.- Specified by:
visitConstraintin interfaceIModelVisitor- Overrides:
visitConstraintin classAbstractVarModelWriter- Parameters:
constraint- The constraint which should be visited.
-
visitLet
Description copied from interface:IConstraintTreeVisitorVisits a let expression.- Parameters:
let- the let expression which should be visited
-
visitIfThen
Description copied from interface:IConstraintTreeVisitorVisits an if-then-else expression.- Parameters:
ifThen- the if-then-else expression which should be visited
-
visitContainerOperationCall
Description copied from interface:IConstraintTreeVisitorVisits a container operation call (e.g. quantors, iterators).- Parameters:
call- the container operation call
-
visitCompoundAccess
Description copied from interface:IConstraintTreeVisitorVisits a compound access node.- Parameters:
access- the compound access node
-
visitMetaTypeValue
Description copied from interface:IValueVisitorThis method is used for visiting meta type value.- Parameters:
value- a value which should be visited.
-
visitNullValue
Description copied from interface:IValueVisitorThis method is used for visiting a null value.- Parameters:
value- a value which should be visited (actuallyNullValue.INSTANCE).
-
visitAttributeAssignment
Description copied from interface:IModelVisitorVisits an attribute assignment.- Specified by:
visitAttributeAssignmentin interfaceIModelVisitor- Overrides:
visitAttributeAssignmentin classAbstractVarModelWriter- Parameters:
assignment- the assignment to visit
-
visitComment
Description copied from interface:IModelVisitorMethod for visiting a comment.- Parameters:
comment- the comment to visit
-
visitComment
Description copied from interface:IConstraintTreeVisitorVisits a comment.- Parameters:
comment- the comment node which should be visited
-
beforeNestedElement
Description copied from class:AbstractVarModelWriterThis method is called before a nested element is emitted. This enables the output of comments before theelementetc.- Overrides:
beforeNestedElementin classAbstractVarModelWriter- Parameters:
element- the element (no specific type needed, seeComment
-
visitCompound
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a compound.- Specified by:
visitCompoundin interfaceICustomDatatypeVisitor- Overrides:
visitCompoundin classAbstractVarModelWriter- Parameters:
compound- The compound which should be visited.
-
getLastComment
Returns the last comment from the internal comment stack.- Returns:
- the last comment
-
dupLastComment
private void dupLastComment()Duplicates the last comment on the stack for nesting. -
popLastComment
Removes the comment on top of the stack.- Returns:
- the comment which was on the top of the stack before this operation
-
setLastComment
Defines the next comment on top of the stack (combined pop/push).- Parameters:
comment- the new comment to be on the top of the stack
-
visitCompoundAccessStatement
Description copied from interface:IModelVisitorVisits a compound access statement (may occur in freeze blocks.- Parameters:
access- the access statement
-
visitVersionValue
Description copied from interface:IValueVisitorThis method is used for visiting a version value.- Parameters:
value- a value which should be visited.
-
visitSelf
Description copied from interface:IConstraintTreeVisitorVisits self.- Parameters:
self- the self object to visit
-
visitBlockExpression
Description copied from interface:IConstraintTreeVisitorVisits the block.- Parameters:
block- the block to be visited
-