Class CommentResourceVisitor

  • All Implemented Interfaces:
    IConstraintTreeVisitor, ICustomDatatypeVisitor, IModelVisitor, IValueVisitor

    public class CommentResourceVisitor
    extends IVMLWriter
    A visitor turning (partial) IVML elements into more or less explainable strings based on a given CommentResource. IVML operations can be turned into strings through a pseudo signature of "." as operator and arguments, e.g., using "isDefined(.)" as key. Variables are read from CommentResource as such.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • CommentResourceVisitor

        private CommentResourceVisitor​(java.io.Writer out,
                                       CommentResource comments)
        Creates a visitor instance.
        Parameters:
        out - the output writer
        comments - the comment resource, may be null for none
    • Method Detail

      • visit

        public static java.lang.String visit​(IModelElement elt,
                                             CommentResource comments)
        Visits a model element and returns the translated elements as String. Without a properly defined comments resource, this shall lead to similar results as delivered by StringProvider.
        Parameters:
        elt - the element to visit
        comments - the comment resource, may be null for none
        Returns:
        the translated string
      • getComment

        private java.lang.String getComment​(java.lang.String key)
        Returns the comment for key.
        Parameters:
        key - the key (may be null)
        Returns:
        the comment or null for none
      • appendComment

        private boolean appendComment​(java.lang.String key,
                                      java.lang.String[] args)
        Appends a comment taken from the comments resource.
        Parameters:
        key - the key (may be null)
        args - the arguments for an operation, replacing "{i}" with i a non-negative integer denoting operand (0) and parameter (1..)
        Returns:
        true if the operation was performed and something was appended to this writer, false else