Class MathMLContentBuilder

java.lang.Object
com.singularsys.extensions.mathml.MathMLContentBuilder
All Implemented Interfaces:
MathMLDocumentBuilder

public class MathMLContentBuilder extends Object implements MathMLDocumentBuilder
Main class for the Content MathML builder.
Author:
Richard Morris
  • Constructor Details

  • Method Details

    • newDocument

      public Document newDocument()
      Create an empty document.
      Returns:
      a new empty document
    • newDocumentMathMLDTD

      public Document newDocumentMathMLDTD()
      Create a document with the MathML DTD and a <math> tag as the root element. Use
      Document jepDoc = db.newDocumentMathMLDTD();
              Element e = db.buildChild(jepNode, jepDoc);
              jepDoc.getDocumentElement().appendChild(e);
       
      to add contents.
      Returns:
      a new document
    • newDocumentMathMLDTD

      public Document newDocumentMathMLDTD(String systemID)
      Create a document with the MathML DTD with the specified systemID and a <math> tag as the root element. Use
      Document jepDoc = db.newDocumentMathMLDTD();
              Element e = db.buildChild(jepNode, jepDoc);
              jepDoc.getDocumentElement().appendChild(e);
       
      to add contents.
      Parameters:
      systemID - the systemID to use
      Returns:
      a new document
    • buildDocument

      public Document buildDocument(Node node) throws JepException
      Create a document containing a single math tag with a single child, no namespace is used.
      Parameters:
      node - jep node for expression
      Returns:
      a new document
      Throws:
      JepException
    • buildDocument

      public Document buildDocument(Node node, boolean useNamespace) throws JepException
      Create a document containing a single math tag with a single child, no namespace is used.
      Parameters:
      node - jep node for expression
      useNamespace -
      Returns:
      a new document
      Throws:
      JepException
    • buildDocument

      public Document buildDocument(Node node, boolean useNamespace, DocumentBuilder docb) throws JepException
      Create a document containing a single math tag with a single child, if useNamespace is set then the standard MathML namespace is used.
      Parameters:
      node -
      useNamespace -
      docb -
      Returns:
      a new document
      Throws:
      JepException
    • buildDocument

      public Document buildDocument(Node node, String prefix) throws JepException
      Builds a document using a given namespace prefix
      Parameters:
      node -
      prefix -
      Returns:
      a new document
      Throws:
      JepException
    • buildDocument

      public Document buildDocument(Node node, String prefix, DocumentBuilder docb) throws JepException
      Throws:
      JepException
    • buildMathElement

      public Element buildMathElement(Node node, Document d, boolean useNamespace) throws JepException
      Builds a <math> element with a single child element, with content mark up for the Jep expression.
      Parameters:
      node - Jep expression
      d - the document
      useNamespace - use the standard MathML namespace
      Returns:
      a new element representing the Jep expression
      Throws:
      JepException
    • buildMathElement

      public Element buildMathElement(Node[] nodes, Document d, boolean useNamespace) throws JepException
      Builds a <math> element with one child element per node.
      Parameters:
      nodes - an array of Jep expressions
      d - the document
      useNamespace - whether to use the standard MathML namespace.
      Returns:
      a new element representing the Jep expression
      Throws:
      JepException
    • buildMathElement

      public Element buildMathElement(Node node, Document d, String prefix) throws JepException
      Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefix
      Parameters:
      node - Jep expression
      d - the document to create elements in
      prefix - the namespace-prefix to use the prefix will be attached to all MathML elements and attributes
      Returns:
      DOM element for the math tag
      Throws:
      JepException
    • buildMathElement

      public Element buildMathElement(Node[] nodes, Document d, String prefix) throws JepException
      Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefix
      Parameters:
      nodes - an array of Jep expressions
      d - the document to create elements in
      prefix - the namespace-prefix to use the prefix will be attached to all MathML elements and attributes
      Returns:
      DOM element for the math tag
      Throws:
      JepException
    • buildChild

      public Element buildChild(Node n, Document d) throws JepException
      Builds an Element representing a Jep sub-expression.
      Specified by:
      buildChild in interface MathMLDocumentBuilder
      Parameters:
      n - the jep node
      d - the document to create the element in.
      Returns:
      element representing the node
      Throws:
      JepException
    • createElement

      public Element createElement(String name, Document doc)
      Create an element using the MAthML namespaces if needed. If namespacePrefix is set then MathML namespace will be used and Document.createElementNS is called.
      Specified by:
      createElement in interface MathMLDocumentBuilder
      Parameters:
      name - local name of element without prefix.
      doc - document to create an element in.
      Returns:
      a new Element
    • setAttribute

      public void setAttribute(Element e, String name, String value)
      Sets an element attribute using namespaces if required. If namespacePrefix is set then MathML namespace will be used and Element.setAttributeNS is called.
      Specified by:
      setAttribute in interface MathMLDocumentBuilder
      Parameters:
      e - element to set an attribute of
      name - name of attribute
      value - value of attribute
    • getNumberBuilder

      public NumberBuilder getNumberBuilder()
    • setNumberBuilder

      public void setNumberBuilder(NumberBuilder numberBuilder)
    • getVariableBuilder

      public VariableBuilder getVariableBuilder()
    • setVariableBuilder

      public void setVariableBuilder(VariableBuilder variableBuilder)
    • putConstant

      public String putConstant(String key, String value)
    • putEntity

      public String putEntity(String key, String value)
    • putOperator

      public MathMLFragmentBuilder putOperator(Operator key, MathMLFragmentBuilder value)
    • putOperator

      public String putOperator(Operator key, String value)
    • putFunction

      public MathMLFragmentBuilder putFunction(String key, MathMLFragmentBuilder value)
    • putFunction

      public String putFunction(String key, String value)
    • getDocumentBuilderFactory

      public DocumentBuilderFactory getDocumentBuilderFactory()
    • setDocumentBuilderFactory

      public void setDocumentBuilderFactory(DocumentBuilderFactory dbf)
    • getNamespacePrefix

      public String getNamespacePrefix()
    • setNamespacePrefix

      public void setNamespacePrefix(String namespacePrefix)
    • getFunctionBuilder

      public FunctionBuilder getFunctionBuilder()
    • setFunctionBuilder

      public void setFunctionBuilder(FunctionBuilder functionBuilder)
    • getOperatorBuilder

      public OperatorBuilder getOperatorBuilder()
    • setOperatorBuilder

      public void setOperatorBuilder(OperatorBuilder operatorBuilder)
    • getDoubleBehaviour

      public NumberBuilder.DoubleBehaviour getDoubleBehaviour()
    • setDoubleBehaviour

      public void setDoubleBehaviour(NumberBuilder.DoubleBehaviour doubleBehaviour)
      Sets how double values with integral values are represented.
      • ALLWAYS_DOUBLE <cn>2.0</cn>
      • NO_DECIMALPOINT <cn>2.0</cn>
      • TYPE_INTEGER <cn type="integer">2</cn>
      Parameters:
      doubleBehaviour -