Class ConstraintSplitWriter

All Implemented Interfaces:
IConstraintTreeVisitor, ICustomDatatypeVisitor, IModelVisitor, IValueVisitor

public class ConstraintSplitWriter extends IVMLWriter
Splits the textual output at a given constraint. This writer is useful for embedded constraint editors.
Author:
Holger Eichelberger
  • Field Details

  • Constructor Details

    • ConstraintSplitWriter

      public ConstraintSplitWriter(ConstraintSplitWriter.IConstraintFilter filter)
      Creates a split writer for the given writer and splits at constraint.
      Parameters:
      filter - the constraint filter identifying the split point
  • Method Details

    • pre

      private boolean pre(IModelElement context, ConstraintSyntaxTree constraint)
      To be called before a potential split point (checking the filter).
      Parameters:
      context - the enclosing model element
      constraint - the constraint to check
      Returns:
      true if a split shall happen, false else
    • post

      private void post(boolean split)
      To be called after a potential split point (checking the filter).
      Parameters:
      split - the output of the corresponding pre call
    • emitConstraintExpression

      protected void emitConstraintExpression(IModelElement context, ConstraintSyntaxTree constraint)
      Description copied from class: AbstractVarModelWriter
      Visits the expression of a constraint (for extension).
      Overrides:
      emitConstraintExpression in class AbstractVarModelWriter
      Parameters:
      context - the visiting context
      constraint - the (specified) constraint;
    • emitDecisionVariableDeclarationDefault

      protected void emitDecisionVariableDeclarationDefault(DecisionVariableDeclaration decl, ConstraintSyntaxTree defaultValue)
      Description copied from class: IVMLWriter
      Emits the default value of a decision variable declaration (for extension).
      Overrides:
      emitDecisionVariableDeclarationDefault in class IVMLWriter
      Parameters:
      decl - the declaration
      defaultValue - the specified default value
    • getBeforeText

      public String getBeforeText()
      Returns the textual model representation before the constraint.
      Returns:
      the textual model representation before the constraint
    • getConstraintText

      public String getConstraintText()
      Returns the textual model representation of the constraint.
      Returns:
      the textual model representation of the constraint
    • getAfterText

      public String getAfterText()
      Returns the textual model representation after the constraint.
      Returns:
      the textual model representation after the constraint
    • getSplit

      public String[] getSplit(boolean trimConstraint, boolean trimParenthesis)
      Returns the split as needed for embedding xText editors.
      Parameters:
      trimConstraint - trim the constraint from leading/trailing whitespaces
      trimParenthesis - trims the constraint from a leading/trailing parenthesis moving them to prefix/suffix
      Returns:
      an array consisting of the values of getBeforeText(), getConstraintText() and getAfterText()
    • doTrim

      private static boolean doTrim(char ch)
      Returns whether ch shall be trimmed.
      Parameters:
      ch - the character to check
      Returns:
      true if ch shall be trimmed, false else