Class TemplateLangWriter
- 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.templateModel.TemplateLangWriter
-
- All Implemented Interfaces:
IVisitor,IExpressionVisitor,ITemplateLangVisitor,IVisitor
public class TemplateLangWriter extends WriterVisitor<VariableDeclaration> implements ITemplateLangVisitor
For writing a template language 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 TemplateLangWriter(java.io.Writer out)Creates a build language writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intgetNonDefaultJavaExtensionCount(Template template)Returns the number of non-default Java extensions intemplate.private voidprintFormattingHint(FormattingConfiguration config)Prints the formatting hint related to the givenconfig.private voidprintFormattingHintEntry(java.lang.String name, java.lang.String value)Prints the an formatting hint entry.private voidprintIndenationHint(IndentationConfiguration config)Prints the indentation hint related to the givenconfig.private voidprintIndentationHintEntry(java.lang.String name, int value)Prints the an indentation hint entry.private voidprintSeparatorExpression(Expression expression)Prints a separator expression.protected booleanquoteExpression(Expression expression)Returns if visitingexpressioninExpressionWriter.printContentExpressions(IExpressionIterator)shall lead to quote constant expressions or unquoted constant expressionsisInExpression.java.lang.ObjectvisitAlternative(AlternativeStatement alternative)Visits an alternative statement.java.lang.ObjectvisitContentAlternativeExpression(ContentAlternativeExpression ex)Visits a content alternative expression.java.lang.ObjectvisitContentImportExpression(ContentImportExpression ex)Visits a content import expression.java.lang.ObjectvisitContentLoopExpression(ContentLoopExpression ex)Visits a content loop expression.java.lang.ObjectvisitContentStatement(ContentStatement cnt)Visits a content statement.java.lang.ObjectvisitContentVarDeclExpression(ContentVarDeclExpression ex)Visits a content variable declaration expression.java.lang.ObjectvisitDef(Def def)Visits a sub-template definition.java.lang.ObjectvisitFlush(FlushStatement stmt)Visits a flush statement.java.lang.ObjectvisitJavaExtension(JavaExtension ext)Visits a java extension.java.lang.ObjectvisitLoop(LoopStatement loop)Visits a loop statement.java.lang.ObjectvisitSwitch(SwitchStatement swtch)Visits a switch statement.java.lang.ObjectvisitTemplate(Template template)Visits a template.java.lang.ObjectvisitTemplateBlock(TemplateBlock block)Visits a template block.java.lang.ObjectvisitTemplateCallExpression(TemplateCallExpression call)Visits a template call expression.java.lang.ObjectvisitWhile(WhileStatement stmt)Visits a while statement.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.common.WriterVisitor
endsWithSemicolon, isPrintExpressionStatementIndentation, isPrintExpressionStatementNewLine, o2i, printCompounds, printImportLeadin, 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, 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
-
getNonDefaultJavaExtensionCount
private int getNonDefaultJavaExtensionCount(Template template)
Returns the number of non-default Java extensions intemplate.- Parameters:
template- the template to consider- Returns:
- the number of non-default Java extensions
-
visitTemplate
public java.lang.Object visitTemplate(Template template) throws VilException
Description copied from interface:IVisitorVisits a template.- Specified by:
visitTemplatein interfaceIVisitor- Parameters:
template- the template to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
printIndenationHint
private void printIndenationHint(IndentationConfiguration config)
Prints the indentation hint related to the givenconfig.- Parameters:
config- the configuration to be printed
-
printFormattingHint
private void printFormattingHint(FormattingConfiguration config)
Prints the formatting hint related to the givenconfig.- Parameters:
config- the configuration to be printed
-
printIndentationHintEntry
private void printIndentationHintEntry(java.lang.String name, int value)Prints the an indentation hint entry.- Parameters:
name- the name of the entryvalue- the actual value
-
printFormattingHintEntry
private void printFormattingHintEntry(java.lang.String name, java.lang.String value)Prints the an formatting hint entry.- Parameters:
name- the name of the entryvalue- the actual value
-
visitJavaExtension
public java.lang.Object visitJavaExtension(JavaExtension ext) throws VilException
Description copied from interface:IVisitorVisits a java extension.- Specified by:
visitJavaExtensionin interfaceIVisitor- Parameters:
ext- the java extension- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitDef
public java.lang.Object visitDef(Def def) throws VilException
Description copied from interface:IVisitorVisits a sub-template definition.- Specified by:
visitDefin interfaceIVisitor- Parameters:
def- the sub-template definition to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitTemplateBlock
public java.lang.Object visitTemplateBlock(TemplateBlock block) throws VilException
Description copied from interface:IVisitorVisits a template block.- Specified by:
visitTemplateBlockin interfaceIVisitor- Parameters:
block- the template block to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitAlternative
public java.lang.Object visitAlternative(AlternativeStatement alternative) throws VilException
Description copied from interface:IVisitorVisits an alternative statement.- Specified by:
visitAlternativein interfaceIVisitor- Parameters:
alternative- the alternative to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
printSeparatorExpression
private void printSeparatorExpression(Expression expression) throws VilException
Prints a separator expression.- Parameters:
expression- the expression to be printed- Throws:
VilException- in case of evaluation problems
-
visitLoop
public java.lang.Object visitLoop(LoopStatement loop) throws VilException
Description copied from interface:IVisitorVisits a loop statement.- Specified by:
visitLoopin interfaceIVisitor- Parameters:
loop- the loop statement to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitSwitch
public java.lang.Object visitSwitch(SwitchStatement swtch) throws VilException
Description copied from interface:IVisitorVisits a switch statement.- Specified by:
visitSwitchin interfaceIVisitor- Parameters:
swtch- the switch statement to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitContentStatement
public java.lang.Object visitContentStatement(ContentStatement cnt) throws VilException
Description copied from interface:IVisitorVisits a content statement.- Specified by:
visitContentStatementin interfaceIVisitor- Parameters:
cnt- the content statement- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitTemplateCallExpression
public java.lang.Object visitTemplateCallExpression(TemplateCallExpression call) throws VilException
Description copied from interface:IVisitorVisits a template call expression.- Specified by:
visitTemplateCallExpressionin interfaceIVisitor- Parameters:
call- the call expression- Returns:
- the result of visiting the given expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitWhile
public java.lang.Object visitWhile(WhileStatement stmt) throws VilException
Description copied from interface:IVisitorVisits a while statement.- Specified by:
visitWhilein interfaceIVisitor- Parameters:
stmt- the while statement to visit- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitFlush
public java.lang.Object visitFlush(FlushStatement stmt) throws VilException
Description copied from interface:IVisitorVisits a flush statement.- Specified by:
visitFlushin interfaceIVisitor- Parameters:
stmt- the flush statement- Returns:
- the result visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitContentAlternativeExpression
public java.lang.Object visitContentAlternativeExpression(ContentAlternativeExpression ex) throws VilException
Description copied from interface:IVisitorVisits a content alternative expression.- Specified by:
visitContentAlternativeExpressionin interfaceIVisitor- Parameters:
ex- the expression- Returns:
- the result visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitContentLoopExpression
public java.lang.Object visitContentLoopExpression(ContentLoopExpression ex) throws VilException
Description copied from interface:IVisitorVisits a content loop expression.- Specified by:
visitContentLoopExpressionin interfaceIVisitor- Parameters:
ex- the expression- Returns:
- the result visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
quoteExpression
protected boolean quoteExpression(Expression expression)
Description copied from class:ExpressionWriterReturns if visitingexpressioninExpressionWriter.printContentExpressions(IExpressionIterator)shall lead to quote constant expressions or unquoted constant expressionsisInExpression.- Overrides:
quoteExpressionin classExpressionWriter- Parameters:
expression- the expression to visit- Returns:
truefor quoting,falseelse
-
visitContentVarDeclExpression
public java.lang.Object visitContentVarDeclExpression(ContentVarDeclExpression ex) throws VilException
Description copied from interface:IVisitorVisits a content variable declaration expression.- Specified by:
visitContentVarDeclExpressionin interfaceIVisitor- Parameters:
ex- the expression- Returns:
- the result visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitContentImportExpression
public java.lang.Object visitContentImportExpression(ContentImportExpression ex) throws VilException
Description copied from interface:IVisitorVisits a content import expression.- Specified by:
visitContentImportExpressionin interfaceIVisitor- Parameters:
ex- the expression- Returns:
- the result visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
-