Class BuildlangWriter
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.AbstractWriter
-
- net.ssehub.easy.instantiation.core.model.expressions.ExpressionWriter
-
- net.ssehub.easy.instantiation.core.model.common.WriterVisitor<VariableDeclaration>
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.BuildlangWriter
-
- All Implemented Interfaces:
IBuildlangVisitor,IVisitor,IMatchVisitor,IVisitor,IExpressionVisitor
public class BuildlangWriter extends WriterVisitor<VariableDeclaration> implements IBuildlangVisitor
For writing a buildlanguage model to a print stream. Needed for persisting the model after external creation / modification. Does currently not consider Comments.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Constructor Description BuildlangWriter(java.io.Writer out)Creates a build language writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanendsWithSemicolon(ExpressionStatement statement)Returns whether the given statement ends with a semicolon.protected java.lang.StringgetScriptElementName()Returns the language element name for a "script".protected booleanhasContainedElements(Script script)Returns whetherscripthas contained elements.protected voidprintBlock(IRuleBlock block)Prints an entire block including braces.protected voidprintBlockContents(IRuleBlock block)Prints the actual block contents.private voidprintImports(Script script)Prints the imports ofscript.protected voidprintRuleConditions(Rule rule, Rule.Side side)Prints the rule conditions on the specified side.protected voidprintScript(Script script)Prints an entire script.protected voidprintScriptContents(Script script)Prints the script contents.protected voidprintScriptContentsBeforeRules(Script script)Prints the script contents before rules.protected voidprintScriptHeader(Script script)Prints the header ofscript.private voidprintString(java.lang.String string)Prints a string in quotes.private voidprintVtlRestrictions(Script script)Prints the VTL restrictions.java.lang.ObjectvisitAlternativeExpression(AlternativeExpression alt)Visits an alternative.java.lang.ObjectvisitArtifactMatchExpression(ArtifactMatchExpression expression)Visits an artifact match expression.java.lang.ObjectvisitBooleanMatchExpression(BooleanMatchExpression expression)Visits a boolean match expression.java.lang.ObjectvisitCollectionMatchExpression(CollectionMatchExpression expression)Visits a collection match expression.java.lang.ObjectvisitCompoundMatchExpression(CompoundMatchExpression expression)Visits a compound match expression.java.lang.ObjectvisitForStatement(ForStatement stmt)Visits a for statement.java.lang.ObjectvisitInstantiateExpression(InstantiateExpression inst)Visits an instantiate expression.java.lang.ObjectvisitJoinExpression(JoinExpression ex)Visits a join expression.java.lang.ObjectvisitJoinVariableDeclaration(JoinVariableDeclaration decl)Visits a join variable declaration.java.lang.ObjectvisitLoadProperties(LoadProperties properties)Visits a load properties directive.private java.lang.ObjectvisitLoop(IEnumeratingLoop loop)Visits a loop.java.lang.ObjectvisitMapExpression(MapExpression map)Visits a map expression.java.lang.ObjectvisitPathMatchExpression(PathMatchExpression expression)Visits a path match expression.java.lang.ObjectvisitRule(Rule rule)Visits a rule.java.lang.ObjectvisitRule(VtlRule rule)Visits a VTL mapping rule.java.lang.ObjectvisitRuleCallExpression(RuleCallExpression ex)Visits a rule call expression.java.lang.ObjectvisitScript(Script script)Visits a script.java.lang.ObjectvisitStrategyCallExpression(StrategyCallExpression call)Visits a strategy call node.java.lang.ObjectvisitStringMatchExpression(StringMatchExpression expression)Visits a string match expression.java.lang.ObjectvisitWhileStatement(WhileStatement stmt)Visits a while statement.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.common.WriterVisitor
isPrintExpressionStatementIndentation, isPrintExpressionStatementNewLine, o2i, printCompounds, printModifiers, printParameterList, printTypedefs, printVersion, printVersionRestrictions, setPrintExpressionStatementIndentation, setPrintExpressionStatementNewLine, visitAdvice, visitCompound, visitExpressionStatement, visitTypedef, visitVariableDeclaration
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.ExpressionWriter
considerOclCompliance, isInComposite, isInContent, printArgumentList, printArguments, printContentExpressions, printType, quoteExpression, setInContent, setOclCompliance, visitCallExpression, visitCompositeExpression, visitConstantExpression, visitContainerInitializerExpression, visitExpression, visitExpressionEvaluator, visitFieldAccessExpression, visitMultiAndExpression, visitParenthesisExpression, visitResolvableOperationCallExpression, visitResolvableOperationExpression, visitStringExpression, visitValueAssignmentExpression, visitVariableExpression, visitVarModelIdentifierExpression, visitVilTypeExpression
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.AbstractWriter
decreaseIndentation, flush, getOut, increaseIndentation, print, print, print, print, printIndentation, printJavaEscaped, println, println, println, println, println, printWhitespace, setIndentation
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.expressions.IExpressionVisitor
visitCallExpression, visitCompositeExpression, visitConstantExpression, visitContainerInitializerExpression, visitExpression, visitExpressionEvaluator, visitFieldAccessExpression, visitMultiAndExpression, visitParenthesisExpression, visitResolvableOperationCallExpression, visitResolvableOperationExpression, visitStringExpression, visitValueAssignmentExpression, visitVariableExpression, visitVarModelIdentifierExpression, visitVilTypeExpression
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.common.IVisitor
visitAdvice, visitCompound, visitExpressionStatement, visitTypedef, visitVariableDeclaration
-
-
-
-
Method Detail
-
endsWithSemicolon
protected boolean endsWithSemicolon(ExpressionStatement statement)
Returns whether the given statement ends with a semicolon.- Overrides:
endsWithSemicolonin classWriterVisitor<VariableDeclaration>- Parameters:
statement- the statement to check- Returns:
trueif it ends with a semicolon,falseelse
-
printString
private void printString(java.lang.String string)
Prints a string in quotes.- Parameters:
string- the string to be printed
-
visitStrategyCallExpression
public java.lang.Object visitStrategyCallExpression(StrategyCallExpression call) throws VilException
Description copied from interface:IVisitorVisits a strategy call node.- Specified by:
visitStrategyCallExpressionin interfaceIVisitor- Parameters:
call- the node- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitRuleCallExpression
public java.lang.Object visitRuleCallExpression(RuleCallExpression ex) throws VilException
Description copied from interface:IVisitorVisits a rule call expression.- Specified by:
visitRuleCallExpressionin interfaceIVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
getScriptElementName
protected java.lang.String getScriptElementName()
Returns the language element name for a "script". [extensibility]- Returns:
- the language element name ("vilScript")
-
printScriptHeader
protected void printScriptHeader(Script script) throws VilException
Prints the header ofscript. [extensibility]- Parameters:
script- the script to be printed- Throws:
VilException- in case that printing the script header fails- See Also:
getScriptElementName()
-
hasContainedElements
protected boolean hasContainedElements(Script script)
Returns whetherscripthas contained elements. [extensibility]- Parameters:
script- the script to consider- Returns:
trueifscripthas contained elements,falseifscriptis empty
-
printScriptContents
protected void printScriptContents(Script script) throws VilException
Prints the script contents. [extensibility]- Parameters:
script- the script to be printed- Throws:
VilException- in case that printing the script contents fails- See Also:
printScriptContentsBeforeRules(Script)
-
printScriptContentsBeforeRules
protected void printScriptContentsBeforeRules(Script script) throws VilException
Prints the script contents before rules. [extensibility]- Parameters:
script- the script to be printed- Throws:
VilException- in case that printing the script contents fails
-
printScript
protected void printScript(Script script) throws VilException
Prints an entire script. [extensibility]- Parameters:
script- the script to be printed- Throws:
VilExceptionVilException- in case that printing the script fails- See Also:
printScriptHeader(Script),hasContainedElements(Script),printScriptContents(Script)
-
visitScript
public java.lang.Object visitScript(Script script) throws VilException
Description copied from interface:IVisitorVisits a script.- Specified by:
visitScriptin interfaceIVisitor- Parameters:
script- the project instance- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
printImports
private void printImports(Script script) throws VilException
Prints the imports ofscript.- Parameters:
script- the script the versions shall be printed for- Throws:
VilException- in case of problems while printing the version restrictions
-
printVtlRestrictions
private void printVtlRestrictions(Script script) throws VilException
Prints the VTL restrictions.- Parameters:
script- the script the versions shall be printed for- Throws:
VilException- in case of problems while printing the version restrictions
-
visitLoadProperties
public java.lang.Object visitLoadProperties(LoadProperties properties) throws VilException
Description copied from interface:IVisitorVisits a load properties directive.- Specified by:
visitLoadPropertiesin interfaceIVisitor- Parameters:
properties- the load properties representation- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitRule
public java.lang.Object visitRule(VtlRule rule) throws VilException
Description copied from interface:IVisitorVisits a VTL mapping rule.- Specified by:
visitRulein interfaceIVisitor- Parameters:
rule- the rule- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitRule
public java.lang.Object visitRule(Rule rule) throws VilException
Description copied from interface:IVisitorVisits a rule.- Specified by:
visitRulein interfaceIVisitor- Parameters:
rule- the rule- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
printRuleConditions
protected void printRuleConditions(Rule rule, Rule.Side side) throws VilException
Prints the rule conditions on the specified side.- Parameters:
rule- the rule to print the conditions forside- the side (LHS = postconditions, RHS = preconditions)- Throws:
VilException- in case that visiting fails
-
printBlockContents
protected void printBlockContents(IRuleBlock block) throws VilException
Prints the actual block contents.- Parameters:
block- the block to be printed- Throws:
VilException- in case of visiting problems
-
printBlock
protected void printBlock(IRuleBlock block) throws VilException
Prints an entire block including braces.- Parameters:
block- the block to be printed- Throws:
VilException- in case of visiting problems- See Also:
printBlockContents(IRuleBlock)
-
visitStringMatchExpression
public java.lang.Object visitStringMatchExpression(StringMatchExpression expression) throws VilException
Description copied from interface:IMatchVisitorVisits a string match expression.- Specified by:
visitStringMatchExpressionin interfaceIMatchVisitor- Parameters:
expression- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitPathMatchExpression
public java.lang.Object visitPathMatchExpression(PathMatchExpression expression) throws VilException
Description copied from interface:IMatchVisitorVisits a path match expression.- Specified by:
visitPathMatchExpressionin interfaceIMatchVisitor- Parameters:
expression- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitBooleanMatchExpression
public java.lang.Object visitBooleanMatchExpression(BooleanMatchExpression expression) throws VilException
Description copied from interface:IMatchVisitorVisits a boolean match expression.- Specified by:
visitBooleanMatchExpressionin interfaceIMatchVisitor- Parameters:
expression- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitArtifactMatchExpression
public java.lang.Object visitArtifactMatchExpression(ArtifactMatchExpression expression) throws VilException
Description copied from interface:IMatchVisitorVisits an artifact match expression.- Specified by:
visitArtifactMatchExpressionin interfaceIMatchVisitor- Parameters:
expression- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitCollectionMatchExpression
public java.lang.Object visitCollectionMatchExpression(CollectionMatchExpression expression) throws VilException
Description copied from interface:IMatchVisitorVisits a collection match expression.- Specified by:
visitCollectionMatchExpressionin interfaceIMatchVisitor- Parameters:
expression- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitJoinExpression
public java.lang.Object visitJoinExpression(JoinExpression ex) throws VilException
Description copied from interface:IVisitorVisits a join expression.- Specified by:
visitJoinExpressionin interfaceIVisitor- Parameters:
ex- the join expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitJoinVariableDeclaration
public java.lang.Object visitJoinVariableDeclaration(JoinVariableDeclaration decl) throws VilException
Description copied from interface:IVisitorVisits a join variable declaration.- Specified by:
visitJoinVariableDeclarationin interfaceIVisitor- Parameters:
decl- the declaration- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitMapExpression
public java.lang.Object visitMapExpression(MapExpression map) throws VilException
Description copied from interface:IVisitorVisits a map expression.- Specified by:
visitMapExpressionin interfaceIVisitor- Parameters:
map- the expression to be visited- Returns:
- the result of visiting the given expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitLoop
private java.lang.Object visitLoop(IEnumeratingLoop loop) throws VilException
Visits a loop.- Parameters:
loop- the loop to be visited- Returns:
- null
- Throws:
VilException- in case of visiting problems
-
visitInstantiateExpression
public java.lang.Object visitInstantiateExpression(InstantiateExpression inst) throws VilException
Description copied from interface:IVisitorVisits an instantiate expression.- Specified by:
visitInstantiateExpressionin interfaceIVisitor- Parameters:
inst- the instantiation expression- Returns:
- the result of visiting the given expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitAlternativeExpression
public java.lang.Object visitAlternativeExpression(AlternativeExpression alt) throws VilException
Description copied from interface:IVisitorVisits an alternative.- Specified by:
visitAlternativeExpressionin interfaceIVisitor- Parameters:
alt- the alternative- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitCompoundMatchExpression
public java.lang.Object visitCompoundMatchExpression(CompoundMatchExpression expression) throws VilException
Description copied from interface:IMatchVisitorVisits a compound match expression.- Specified by:
visitCompoundMatchExpressionin interfaceIMatchVisitor- Parameters:
expression- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitWhileStatement
public java.lang.Object visitWhileStatement(WhileStatement stmt) throws VilException
Description copied from interface:IVisitorVisits a while statement.- Specified by:
visitWhileStatementin interfaceIVisitor- Parameters:
stmt- the statement to be visited- Returns:
- the result of visiting the given expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitForStatement
public java.lang.Object visitForStatement(ForStatement stmt) throws VilException
Description copied from interface:IVisitorVisits a for statement.- Specified by:
visitForStatementin interfaceIVisitor- Parameters:
stmt- the statement to be visited- Returns:
- the result of visiting the given expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
-