Class ConstraintSplitWriter
- java.lang.Object
-
- net.ssehub.easy.varModel.model.AbstractVisitor
-
- net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
-
- net.ssehub.easy.varModel.persistency.IVMLWriter
-
- net.ssehub.easy.varModel.persistency.ConstraintSplitWriter
-
- All Implemented Interfaces:
IConstraintTreeVisitor,ICustomDatatypeVisitor,IModelVisitor,IValueVisitor
public class ConstraintSplitWriter extends IVMLWriter
Splits the textual output at a givenconstraint. This writer is useful for embedded constraint editors.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceConstraintSplitWriter.IConstraintFilterIdentifies the constraint where to split at.static classConstraintSplitWriter.IdentityConstraintFilterAn identity constraint filter.-
Nested classes/interfaces inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
AbstractVarModelWriter.DefaultSpace
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.StringWriterafterprivate java.io.StringWriterbeforeprivate java.io.StringWriterconstraintprivate ConstraintSplitWriter.IConstraintFilterfilter-
Fields inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
DUMMY_PARENT
-
-
Constructor Summary
Constructors Constructor Description ConstraintSplitWriter(ConstraintSplitWriter.IConstraintFilter filter)Creates a split writer for the given writer and splits atconstraint.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static booleandoTrim(char ch)Returns whetherchshall be trimmed.protected voidemitConstraintExpression(IModelElement context, ConstraintSyntaxTree constraint)Visits the expression of a constraint (for extension).protected voidemitDecisionVariableDeclarationDefault(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue)Emits the default value of a decision variable declaration (for extension).java.lang.StringgetAfterText()Returns the textual model representation after the constraint.java.lang.StringgetBeforeText()Returns the textual model representation before the constraint.java.lang.StringgetConstraintText()Returns the textual model representation of the constraint.java.lang.String[]getSplit(boolean trimConstraint, boolean trimParenthesis)Returns the split as needed for embedding xText editors.private voidpost(boolean split)To be called after a potential split point (checking the filter).private booleanpre(IModelElement context, ConstraintSyntaxTree constraint)To be called before a potential split point (checking the filter).-
Methods inherited from class net.ssehub.easy.varModel.persistency.IVMLWriter
appendOCLFeatureCall, beforeNestedElement, emitComments, endWritingCompound, endWritingProject, forceComponundTypes, getInstance, printDefaultSpace, processVersion, releaseInstance, setFormatInitializer, startWritingCompound, startWritingProject, visitAnnotationVariable, visitAttribute, visitAttributeAssignment, visitBlockExpression, visitBooleanValue, visitComment, visitComment, visitCompound, visitCompoundAccess, visitCompoundAccessStatement, visitCompoundInitializer, visitCompoundValue, visitConstraint, visitContainerInitializer, visitContainerOperationCall, visitContainerValue, visitDecisionVariableDeclaration, visitDeferInitExpression, 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, visitVariable, visitVersionValue, writeValue
-
Methods inherited from class net.ssehub.easy.varModel.persistency.AbstractVarModelWriter
addParent, appendIndentation, appendOutput, appendOutput, considerOclCompliance, decreaseAdditionalIndentation, 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
-
before
private java.io.StringWriter before
-
constraint
private java.io.StringWriter constraint
-
after
private java.io.StringWriter after
-
filter
private ConstraintSplitWriter.IConstraintFilter filter
-
-
Constructor Detail
-
ConstraintSplitWriter
public ConstraintSplitWriter(ConstraintSplitWriter.IConstraintFilter filter)
Creates a split writer for the given writer and splits atconstraint.- Parameters:
filter- the constraint filter identifying the split point
-
-
Method Detail
-
pre
private boolean pre(IModelElement context, ConstraintSyntaxTree constraint)
To be called before a potential split point (checking the filter).- Parameters:
context- the enclosing model elementconstraint- the constraint to check- Returns:
trueif a split shall happen,falseelse
-
post
private void post(boolean split)
To be called after a potential split point (checking the filter).- Parameters:
split- the output of the correspondingprecall
-
emitConstraintExpression
protected void emitConstraintExpression(IModelElement context, ConstraintSyntaxTree constraint)
Description copied from class:AbstractVarModelWriterVisits the expression of a constraint (for extension).- Overrides:
emitConstraintExpressionin classAbstractVarModelWriter- Parameters:
context- the visiting contextconstraint- the (specified) constraint;
-
emitDecisionVariableDeclarationDefault
protected void emitDecisionVariableDeclarationDefault(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue)
Description copied from class:IVMLWriterEmits the default value of a decision variable declaration (for extension).- Overrides:
emitDecisionVariableDeclarationDefaultin classIVMLWriter- Parameters:
decl- the declarationdefaultValue- the specified default value
-
getBeforeText
public java.lang.String getBeforeText()
Returns the textual model representation before the constraint.- Returns:
- the textual model representation before the constraint
-
getConstraintText
public java.lang.String getConstraintText()
Returns the textual model representation of the constraint.- Returns:
- the textual model representation of the constraint
-
getAfterText
public java.lang.String getAfterText()
Returns the textual model representation after the constraint.- Returns:
- the textual model representation after the constraint
-
getSplit
public java.lang.String[] getSplit(boolean trimConstraint, boolean trimParenthesis)Returns the split as needed for embedding xText editors.- Parameters:
trimConstraint- trim the constraint from leading/trailing whitespacestrimParenthesis- trims the constraint from a leading/trailing parenthesis moving them to prefix/suffix- Returns:
- an array consisting of the values of
getBeforeText(),getConstraintText()andgetAfterText()
-
doTrim
private static boolean doTrim(char ch)
Returns whetherchshall be trimmed.- Parameters:
ch- the character to check- Returns:
trueifchshall be trimmed,falseelse
-
-