Class JavaTemplateParser


  • public class JavaTemplateParser
    extends ProceduralTemplateParser
    A class that allows to parse macros of templates in a code generator perspective.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Bert Rodiers
    Pt.AcceptedRating:
    Red (rodiers)
    Pt.ProposedRating:
    Red (rodiers)
    • Constructor Detail

      • JavaTemplateParser

        public JavaTemplateParser()
        Construct the JavaTemplateParser associated with the given component and the given adapter.
    • Method Detail

      • getFunctionInvocation

        public java.lang.String getFunctionInvocation​(java.lang.String functionString,
                                                      boolean isStatic)
                                               throws IllegalActionException
        Return the translated token instance function invocation string.
        Overrides:
        getFunctionInvocation in class TemplateParser
        Parameters:
        functionString - The string within the $tokenFunc() macro.
        isStatic - True if the method is static.
        Returns:
        The translated type function invocation string.
        Throws:
        IllegalActionException - The given function string is not well-formed.
      • getNewInvocation

        public java.lang.String getNewInvocation​(java.lang.String constructorString)
                                          throws IllegalActionException
        Return the translated new constructor invocation string. Keep the types referenced in the info table of this adapter. The kernel will retrieve this information to determine the total number of referenced types in the model.
        Overrides:
        getNewInvocation in class TemplateParser
        Parameters:
        constructorString - The string within the $new() macro.
        Returns:
        The translated new constructor invocation string.
        Throws:
        IllegalActionException - The given constructor string is not well-formed.
      • _replaceMacro

        protected java.lang.String _replaceMacro​(java.lang.String macro,
                                                 java.lang.String parameter)
                                          throws IllegalActionException
        Return the replacement string of the given macro. Subclass of GenericCodeGenerator may overriding this method to extend or support a different set of macros.
        Overrides:
        _replaceMacro in class TemplateParser
        Parameters:
        macro - The given macro.
        parameter - The given parameter to the macro.
        Returns:
        The replacement string of the given macro.
        Throws:
        IllegalActionException - Thrown if the given macro or parameter is not valid.