Class FunctionBuilder
java.lang.Object
com.singularsys.extensions.mathml.builder.ApplyConstructor
com.singularsys.extensions.mathml.builder.FunctionBuilder
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to build a CSymbol element, with the name of the jep-function.static classDefault builder for unknown function, throws a jep exception.static classClass to build a Fn element, with the name of the jep-function. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, MathMLFragmentBuilder> protected MathMLFragmentBuilder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(Node n, Document d, MathMLDocumentBuilder db) Builds a Element for a jep Node.protected ElementbuildStandardFunction(Node node, Document doc, MathMLDocumentBuilder db) Gets the map of standard functionsGets the map of special functionsputFunction(String key, String value) Adds a standard functionputSpecialFunction(String key, MathMLFragmentBuilder value) Adds a special functionvoidsetUnknownFunctionBuilder(MathMLFragmentBuilder unknownFunctionBuilder)
-
Field Details
-
unknownFunctionBuilder
-
functions
-
specialFunctions
-
-
Constructor Details
-
FunctionBuilder
public FunctionBuilder()
-
-
Method Details
-
build
Description copied from interface:MathMLFragmentBuilderBuilds a Element for a jep Node.- Specified by:
buildin interfaceMathMLFragmentBuilder- Parameters:
n- The jep sub expression.d- The document to create the element in.db- Used create elements and attributes and child nodes.- Returns:
- element representing the node
- Throws:
JepException
-
buildStandardFunction
protected Element buildStandardFunction(Node node, Document doc, MathMLDocumentBuilder db) throws JepException - Throws:
JepException
-
putFunction
Adds a standard function- Parameters:
key- jep function namevalue- MathML element name- Returns:
- old value for function or null
-
putSpecialFunction
Adds a special function- Parameters:
key- jep function namevalue- builder to handle this type of function- Returns:
- old value for function or null
-
getFunctions
Gets the map of standard functions- Returns:
- the map
-
getSpecialFunctions
Gets the map of special functions- Returns:
- the map
-
getUnknownFunctionBuilder
-
setUnknownFunctionBuilder
-