Class CommentResourceVisitor
- java.lang.Object
-
- net.ssehub.easy.varModel.model.AbstractVisitor
-
- net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
-
- net.ssehub.easy.varModel.persistency.IVMLWriter
-
- net.ssehub.easy.reasoning.core.reasoner.CommentResourceVisitor
-
- All Implemented Interfaces:
IConstraintTreeVisitor,ICustomDatatypeVisitor,IModelVisitor,IValueVisitor
public class CommentResourceVisitor extends IVMLWriter
A visitor turning (partial) IVML elements into more or less explainable strings based on a givenCommentResource. IVML operations can be turned into strings through a pseudo signature of "." as operator and arguments, e.g., using "isDefined(.)" as key. Variables are read fromCommentResourceas such.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
AbstractVarModelWriter.DefaultSpace
-
-
Field Summary
Fields Modifier and Type Field Description private CommentResourcecomments-
Fields inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
DUMMY_PARENT
-
-
Constructor Summary
Constructors Modifier Constructor Description privateCommentResourceVisitor(java.io.Writer out, CommentResource comments)Creates a visitor instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanappendComment(java.lang.String key, java.lang.String[] args)Appends a comment taken from the comments resource.protected voidappendOCLFeatureCall(OCLFeatureCall call, Operation.FormattingHint hint)Does the formatting of an OCL feature call and allows for overwriting.private java.lang.StringgetComment(java.lang.String key)Returns the comment forkey.static java.lang.Stringvisit(IModelElement elt, CommentResource comments)Visits a model element and returns the translated elements as String.voidvisitCompoundAccess(CompoundAccess access)Visits a compound access node.voidvisitConstraint(Constraint constraint)Method for visiting a constraint.voidvisitVariable(Variable variable)Visits a variable.-
Methods inherited from class net.ssehub.easy.varModel.persistency.IVMLWriter
beforeNestedElement, emitComments, emitDecisionVariableDeclarationDefault, endWritingCompound, endWritingProject, forceComponundTypes, getInstance, printDefaultSpace, processVersion, releaseInstance, setFormatInitializer, startWritingCompound, startWritingProject, visitAnnotationVariable, visitAttribute, visitAttributeAssignment, visitBlockExpression, visitBooleanValue, visitComment, visitComment, visitCompound, visitCompoundAccessStatement, visitCompoundInitializer, visitCompoundValue, visitContainerInitializer, visitContainerOperationCall, visitContainerValue, visitDecisionVariableDeclaration, visitDerivedDatatype, visitEnum, visitEnumLiteral, visitEnumValue, visitFreezeBlock, visitIfThen, visitIntValue, visitLet, visitMetaTypeValue, visitMultiAndExpression, visitNullValue, visitOclFeatureCall, visitOperationDefinition, visitParenthesis, visitPartialEvaluationBlock, visitProject, visitProjectImport, visitProjectInterface, visitRealValue, visitReference, visitReferenceValue, visitSelf, visitSequence, visitSet, visitStringValue, visitVersionValue, writeValue
-
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 Detail
-
comments
private CommentResource comments
-
-
Constructor Detail
-
CommentResourceVisitor
private CommentResourceVisitor(java.io.Writer out, CommentResource comments)Creates a visitor instance.- Parameters:
out- the output writercomments- the comment resource, may be null for none
-
-
Method Detail
-
visit
public static java.lang.String visit(IModelElement elt, CommentResource comments)
Visits a model element and returns the translated elements as String. Without a properly defined comments resource, this shall lead to similar results as delivered byStringProvider.- Parameters:
elt- the element to visitcomments- the comment resource, may be null for none- Returns:
- the translated string
-
appendOCLFeatureCall
protected void appendOCLFeatureCall(OCLFeatureCall call, Operation.FormattingHint hint)
Description copied from class:IVMLWriterDoes the formatting of an OCL feature call and allows for overwriting.- Overrides:
appendOCLFeatureCallin classIVMLWriter- Parameters:
call- the callhint- the formatting hint for the call
-
visitConstraint
public void visitConstraint(Constraint constraint)
Description copied from interface:IModelVisitorMethod for visiting a constraint.- Specified by:
visitConstraintin interfaceIModelVisitor- Overrides:
visitConstraintin classIVMLWriter- Parameters:
constraint- The constraint which should be visited.
-
visitVariable
public void visitVariable(Variable variable)
Description copied from interface:IConstraintTreeVisitorVisits a variable.- Specified by:
visitVariablein interfaceIConstraintTreeVisitor- Overrides:
visitVariablein classIVMLWriter- Parameters:
variable- the variable which should be visited
-
getComment
private java.lang.String getComment(java.lang.String key)
Returns the comment forkey.- Parameters:
key- the key (may be null)- Returns:
- the comment or null for none
-
appendComment
private boolean appendComment(java.lang.String key, java.lang.String[] args)Appends a comment taken from the comments resource.- Parameters:
key- the key (may be null)args- the arguments for an operation, replacing "{i}" with i a non-negative integer denoting operand (0) and parameter (1..)- Returns:
trueif the operation was performed and something was appended to this writer,falseelse
-
visitCompoundAccess
public void visitCompoundAccess(CompoundAccess access)
Description copied from interface:IConstraintTreeVisitorVisits a compound access node.- Specified by:
visitCompoundAccessin interfaceIConstraintTreeVisitor- Overrides:
visitCompoundAccessin classIVMLWriter- Parameters:
access- the compound access node
-
-