Class AbstractVarModelWriter

    • Field Detail

      • DUMMY_PARENT

        protected static final ModelElement DUMMY_PARENT
        Defines a dummy model element for additional formatting.
      • indentStep

        private static java.lang.String indentStep
        The number of whitespaces per indentation (if useWhitespace is enabled), otherwise one tab is inserted. Currently we assume that one central configuration for the indentation is sufficient and that it will not be changed during the output of this or subclasses.
      • useWhitespace

        private static boolean useWhitespace
        Use whitespaces or tabs. Currently we assume that one central configuration for the indentation is sufficient and that it will not be changed during the output of this or subclasses.
      • oclCompliance

        private static boolean oclCompliance
        Detect, warn, report about and write to avoid OCL compliance problems.
      • myIndentStep

        private java.lang.String myIndentStep
      • myUseWhitespace

        private boolean myUseWhitespace
      • additionalIndentation

        private int additionalIndentation
      • parents

        private java.util.List<IModelElement> parents
        Stores the all parents of the currently visited element.
        Can be an empty list in case of root elements.
      • out

        private java.io.Writer out
        This attribute should be used for storing the output.
    • Constructor Detail

      • AbstractVarModelWriter

        protected AbstractVarModelWriter​(java.io.Writer writer)
        Sole constructor for this class.
        Parameters:
        writer - Writer which should be used for writing the output.
    • Method Detail

      • setExpressionContext

        protected void setExpressionContext​(IModelElement expressionContext)
        Changes the expression context.
        Parameters:
        expressionContext - the expression context
      • getExpressionContext

        protected IModelElement getExpressionContext()
        Returns the expression context.
        Returns:
        the expression context
      • setIndentStep

        public static void setIndentStep​(int count)
        Defines the number of spaces used in one indentation step if useWhitespace.
        Parameters:
        count - the number of spaces (negative values are ignored)
      • setIndentationStep

        public void setIndentationStep​(int count)
        Defines the number of spaces used in one indentation step if useWhitespace for this writer.
        Parameters:
        count - the number of spaces (negative values are ignored)
      • setOclCompliance

        public static void setOclCompliance​(boolean compliance)
        Changes the OCL compliance setting.
        Parameters:
        compliance - operate with OCL compliance (true), allow both IVML + OCL (false
      • considerOclCompliance

        public static boolean considerOclCompliance()
        Returns whether OCL compliance shall be considered.
        Returns:
        true for OCL compliance, false else
      • setUseWhitespaces

        public void setUseWhitespaces​(boolean useWhitespaces)
        Defines whether whitespaces or tabs shall be used for indentation in this editor.
        Parameters:
        useWhitespaces - if true whitespaces, tabs if false
      • deriveIndentStep

        private static java.lang.String deriveIndentStep​(int count)
        Creates the indentation step in terms of numbers of spaces to be used.
        Parameters:
        count - the number of spaces (negative values are ignored)
        Returns:
        the indentation step
      • getIvmlIndentStep

        public static java.lang.String getIvmlIndentStep()
        Return the indent-step for ivml.
        Returns:
        indent step.
      • setUseIvmlWhitespace

        public static void setUseIvmlWhitespace​(boolean use)
        Defines whether whitespaces or tabs shall be used for indentation.
        Parameters:
        use - if true whitespaces, tabs if false
      • getUseIvmlWhitespace

        public static boolean getUseIvmlWhitespace()
        Defines whether whitespaces or tabs shall be used for indentation.
        Returns:
        useWhitespace if true whitespaces, tabs if false
      • setWriter

        public void setWriter​(java.io.Writer writer)
        Changes the writer. (for reuse)
        Parameters:
        writer - the new writer
      • getWriter

        public java.io.Writer getWriter()
        Returns the actual writer.
        Returns:
        the actual writer
      • appendOutput

        protected final void appendOutput​(java.lang.String appendableOutput)
        Method to append the output.
        Parameters:
        appendableOutput - String containing the output, which should be added.
      • appendOutput

        protected final void appendOutput​(char appendableOutput)
        Method to append the output.
        Parameters:
        appendableOutput - char containing the output, which should be added.
      • appendIndentation

        protected final void appendIndentation()
        Method to append the current indentation.
      • flush

        public final void flush()
                         throws java.io.IOException
        Flushes the writer. Should be used if there aren't any more elements to read.
        Throws:
        java.io.IOException - If an I/O error occurs
      • getIndentation

        protected java.lang.StringBuffer getIndentation()
        Returns the current indentation for (nested) elements.
        Returns:
        The correct indentation for nested elements or an empty StringBuffer in case of an top level element.
      • getParent

        protected IModelElement getParent()
        Returns the direct parent of the current visited object. Ignors DUMMY_PARENT.
        Returns:
        The direct parent or null in case of an element from the top layer.
      • getParent

        protected <T extends IModelElement> T getParent​(java.lang.Class<T> type)
        Returns the latest parent with the given type.
        Type Parameters:
        T - the actual type of the parent to be returned
        Parameters:
        type - the type to search for
        Returns:
        the latest parent with given type or getParent() if type==null
      • removeLastParent

        protected void removeLastParent()
        Removes the last parent from the list of all parents. This method should be used inside the after visit methods.
      • addParent

        protected void addParent​(IModelElement parent)
        Adds the given element to the list of all parents.
        Parameters:
        parent - the parent to be added
      • emitComments

        public abstract boolean emitComments()
        Returns whether comments are emitted by this writer.
        Returns:
        true if comments are emitted, false else
      • printDefaultSpace

        protected abstract void printDefaultSpace​(AbstractVarModelWriter.DefaultSpace location)
        Prints default spaces.
        Parameters:
        location - the intended location of the space
      • processVersion

        protected abstract void processVersion​(Version version)
        Processes a version information.
        Parameters:
        version - the version to be processed
      • startWritingCompound

        protected abstract void startWritingCompound​(Compound compound)
        Method for writing a compound, first part.
        Parameters:
        compound - The compound which should be saved.
      • endWritingCompound

        protected abstract void endWritingCompound​(Compound compound)
        Method for writing a compound, second part.
        Parameters:
        compound - The compound which should be saved.
      • startWritingProject

        protected abstract void startWritingProject​(Project project)
        Method for writing a project, first part.
        Parameters:
        project - The project which should be saved.
      • endWritingProject

        protected abstract void endWritingProject​(Project project)
        Method for writing a project, second part.
        Parameters:
        project - The project which should be saved.
      • visitConstraintValue

        public void visitConstraintValue​(ConstraintValue value)
        Description copied from interface: IValueVisitor
        This method is used for visiting ConstraintValue.
        Specified by:
        visitConstraintValue in interface IValueVisitor
        Parameters:
        value - One ConstraintValue which should be visited.
      • visitConstraint

        public void visitConstraint​(Constraint constraint)
        Description copied from interface: IModelVisitor
        Method for visiting a constraint.
        Specified by:
        visitConstraint in interface IModelVisitor
        Parameters:
        constraint - The constraint which should be visited.
      • emitConstraintExpression

        protected void emitConstraintExpression​(IModelElement context,
                                                ConstraintSyntaxTree constraint)
        Visits the expression of a constraint (for extension).
        Parameters:
        context - the visiting context
        constraint - the (specified) constraint;
      • visitFreezeBlock

        public void visitFreezeBlock​(FreezeBlock freeze)
        Description copied from interface: IModelVisitor
        Method for visiting a freeze block.
        Specified by:
        visitFreezeBlock in interface IModelVisitor
        Parameters:
        freeze - The freeze block which should be visited.
      • beforeNestedElement

        protected void beforeNestedElement​(java.lang.Object element)
        This method is called before a nested element is emitted. This enables the output of comments before the element etc.
        Parameters:
        element - the element (no specific type needed, see Comment
      • getParentCount

        protected int getParentCount()
        Returns the number of hierarchically visited parents.
        Returns:
        the number of hierarchically visited parents
      • getParent

        protected IModelElement getParent​(int index)
        Returns the specified hierarchically visited parent.
        Parameters:
        index - the 0-based index of the visited parent
        Returns:
        the specified visited parent
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= getParentCount()
      • increaseAdditionalIndentation

        protected void increaseAdditionalIndentation()
        Increases the additional indentation.
      • decreaseAdditionalIndentation

        protected void decreaseAdditionalIndentation()
        Decreases the additional indentation.