Class AbstractCodeGenerator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected adams.flow.core.Actor m_FlowContext
      the flow context.
      protected boolean m_NoVariableExpansion
      whether to not expand variables.
      protected boolean m_Skip
      whether to skip the transformation and just forward the token.
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Field Detail

      • m_FlowContext

        protected adams.flow.core.Actor m_FlowContext
        the flow context.
      • m_Skip

        protected boolean m_Skip
        whether to skip the transformation and just forward the token.
      • m_NoVariableExpansion

        protected boolean m_NoVariableExpansion
        whether to not expand variables.
    • Constructor Detail

      • AbstractCodeGenerator

        public AbstractCodeGenerator()
    • Method Detail

      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • setSkip

        public void setSkip​(boolean value)
        Sets whether the generator is skipped.
        Specified by:
        setSkip in interface CodeGenerator
        Parameters:
        value - true if generation is to be skipped
      • getSkip

        public boolean getSkip()
        Returns whether the generator is skipped.
        Specified by:
        getSkip in interface CodeGenerator
        Returns:
        true if generation is skipped
      • skipTipText

        public String skipTipText()
        Returns the tip text for this property.
        Specified by:
        skipTipText in interface CodeGenerator
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setNoVariableExpansion

        public void setNoVariableExpansion​(boolean value)
        Sets whether to skip variable expansion.
        Specified by:
        setNoVariableExpansion in interface CodeGenerator
        Parameters:
        value - true if to skip
      • getNoVariableExpansion

        public boolean getNoVariableExpansion()
        Returns whether to skip variable expansion.
        Specified by:
        getNoVariableExpansion in interface CodeGenerator
        Returns:
        true if to skip
      • noVariableExpansionTipText

        public String noVariableExpansionTipText()
        Returns the tip text for this property.
        Specified by:
        noVariableExpansionTipText in interface CodeGenerator
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setFlowContext

        public void setFlowContext​(adams.flow.core.Actor value)
        Sets the flow context.
        Specified by:
        setFlowContext in interface CodeGenerator
        Specified by:
        setFlowContext in interface adams.flow.core.FlowContextHandler
        Parameters:
        value - the actor
      • getFlowContext

        public adams.flow.core.Actor getFlowContext()
        Returns the flow context, if any.
        Specified by:
        getFlowContext in interface CodeGenerator
        Specified by:
        getFlowContext in interface adams.flow.core.FlowContextHandler
        Returns:
        the actor, null if none available
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the object, which can be displayed in the GUI.
        Default implementation returns null.
        Specified by:
        getQuickInfo in interface CodeGenerator
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Returns:
        null if no info available, otherwise short string
      • getRequiredPackages

        public abstract String[] getRequiredPackages()
        Returns the list of required LaTeX packages for this code generator.
        Specified by:
        getRequiredPackages in interface CodeGenerator
        Returns:
        the packages
      • getAdditionalInformation

        public String getAdditionalInformation()
        Returns the additional information.
        Specified by:
        getAdditionalInformation in interface adams.core.AdditionalInformationHandler
        Specified by:
        getAdditionalInformation in interface CodeGenerator
        Returns:
        the additional information, null or 0-length string for no information
      • check

        protected void check()
        Hook method for performing checks.
        Will raise an IllegalStateException if check fails.
      • escape

        protected String escape​(String s)
        Escapes all characters.
        Parameters:
        s - the string to escape
        Returns:
        the escaped string
      • expand

        protected String expand​(String s)
        Expands the variables in the string, unless it is skipped.
        Parameters:
        s - the string to expand
        Returns:
        the (potentially) expanded string
        See Also:
        getNoVariableExpansion()
      • expandEscape

        protected String expandEscape​(String s)
        Expands and then escapes the string.
        Parameters:
        s - the string to expand/escaped
        Returns:
        the modified string
      • ensureTrailingNewLine

        protected String ensureTrailingNewLine​(String s)
        Ensures that a trailing newline is present.
        Parameters:
        s - the string to check/modify
        Returns:
        the (potentially) appended string
      • ensureTrailingNewLine

        protected void ensureTrailingNewLine​(StringBuilder s)
        Ensures that a trailing newline is present.
        Parameters:
        s - the StringBuilder to check/modify
      • doGenerate

        protected abstract String doGenerate()
        Generates the actual code.
        Returns:
        the generated code
      • generate

        public String generate()
        Generates the code.
        Specified by:
        generate in interface CodeGenerator
        Returns:
        the generated code