Class FunctionBuilder

  • All Implemented Interfaces:
    MathMLFragmentBuilder

    public class FunctionBuilder
    extends ApplyConstructor
    implements MathMLFragmentBuilder
    Builds xml-fragments for jep functions. Most functions are converted to use the <apply> tag with the first child a specific mathml function element. For example sin(x) becomes <apply><sin/><ci>x</ci></apply> The functions map translate jep function name to MathML element names, and elements can be added using putFunction. Some functions like lg (base-2 log) have special behaviour implement by individual MathMLFragmentBuilder, special functions can be added using putSpecialFunction. Unknown functions are handled by the unknownFunctionBuilder, by default this throws an exception, but it can be configured to produce <csymbol> or <fn> elements.
    Author:
    Richard Morris
    • Field Detail

      • functions

        protected java.util.Map<java.lang.String,​java.lang.String> functions
    • Constructor Detail

      • FunctionBuilder

        public FunctionBuilder()
    • Method Detail

      • putFunction

        public java.lang.String putFunction​(java.lang.String key,
                                            java.lang.String value)
        Adds a standard function
        Parameters:
        key - jep function name
        value - MathML element name
        Returns:
        old value for function or null
      • putSpecialFunction

        public MathMLFragmentBuilder putSpecialFunction​(java.lang.String key,
                                                        MathMLFragmentBuilder value)
        Adds a special function
        Parameters:
        key - jep function name
        value - builder to handle this type of function
        Returns:
        old value for function or null
      • getFunctions

        public java.util.Map<java.lang.String,​java.lang.String> getFunctions()
        Gets the map of standard functions
        Returns:
        the map
      • getSpecialFunctions

        public java.util.Map<java.lang.String,​MathMLFragmentBuilder> getSpecialFunctions()
        Gets the map of special functions
        Returns:
        the map
      • setUnknownFunctionBuilder

        public void setUnknownFunctionBuilder​(MathMLFragmentBuilder unknownFunctionBuilder)