Class Macro


  • public class Macro
    extends java.lang.Object
    A text substitution macro Macros can be called as name or name(arg1, arg2, ...) The ( ) in a macro call can be replaced by [ ] or { } or < > Macro calls are replaced by the macro body, with substitution for the macro parameters. A macro substitution also swallows a single blank preceding the macro name if the macro name starts with an alphanumeric character and if the call is not at the beginning of the string) and a single blank following the macro call if the macro call has no ( ), [ ], { }, or < >.
    • Constructor Summary

      Constructors 
      Constructor Description
      Macro​(java.lang.String name0, java.lang.String body0)
      Create a new macro with zero parameters.
      Macro​(java.lang.String name0, java.util.List<java.lang.String> params, java.lang.String body0)
      Create a new macro.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String apply​(java.lang.String target0)
      Apply the macro to a string .
      java.lang.String getBody()  
      java.util.List<java.lang.String> getFormalParams()  
      java.lang.String getName()  
      void setBody​(java.lang.String body0)  
      void setFormalParams​(java.util.List<java.lang.String> formalParams0)  
      void setName​(java.lang.String name0)  
      java.lang.String toString()
      Render the macro as a string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Macro

        public Macro​(java.lang.String name0,
                     java.util.List<java.lang.String> params,
                     java.lang.String body0)
        Create a new macro.
        Parameters:
        name0 - name of the macro - can be any string of visible characters
        params - list of formal parameter names. Names should be limited to alphanumerics and - _
        body0 - body in which to replace params as a replacement for the macro call
      • Macro

        public Macro​(java.lang.String name0,
                     java.lang.String body0)
        Create a new macro with zero parameters.
        Parameters:
        name0 - name of the macro - can be any string of visible characters
        body0 - body to use as a replacement for the macro call
    • Method Detail

      • apply

        public final java.lang.String apply​(java.lang.String target0)
        Apply the macro to a string .
        Parameters:
        target0 - string to be processed via this macro.
        Returns:
        target0 with macro substitutions, unchanged if macro call could not be matched
      • toString

        public final java.lang.String toString()
        Render the macro as a string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a readable version of the macro
      • getName

        public final java.lang.String getName()
        Returns:
        the name
      • setName

        public final void setName​(java.lang.String name0)
        Parameters:
        name0 - the name to set
      • getFormalParams

        public final java.util.List<java.lang.String> getFormalParams()
        Returns:
        the formalParams
      • setFormalParams

        public final void setFormalParams​(java.util.List<java.lang.String> formalParams0)
        Parameters:
        formalParams0 - the formalParams to set
      • getBody

        public final java.lang.String getBody()
        Returns:
        the body
      • setBody

        public final void setBody​(java.lang.String body0)
        Parameters:
        body0 - the body to set