Class NumberBuilder

  • All Implemented Interfaces:
    MathMLFragmentBuilder

    public class NumberBuilder
    extends java.lang.Object
    implements MathMLFragmentBuilder
    Converts numeric-constants to CN nodes. Can produce
    • <cn type="integer">value</cn> if is an Integer, Long or Short
    • <cn type="e-notation">mantissa<sep/>exponant</cn> if Double.toString(val) produces scientific notation.
    • <cn type="complex-cartesian">real<sep/>imaginary</cn> if the value is complex
    • <notanumber/> for Doubles representing NaN's
    • <infinity/> for Doubles representing +Infinity
    • <apply><minus><infinity/><apply/> for Doubles representing -Infinity
    • <cn type="integer">value</cn> for all other types
    • <cn>value</cn> for all other types
    The format of Double values with integral values depends on the doubleBehaviour flag
    • ALLWAYS_DOUBLE <cn>2.0</cn>
    • NO_DECIMALPOINT <cn>2.0</cn>
    • TYPE_INTEGER <cn type="integer">2</cn>
    Author:
    Richard Morris
    • Constructor Detail

      • NumberBuilder

        public NumberBuilder()
    • Method Detail

      • buildAsInteger

        public org.w3c.dom.Element buildAsInteger​(long val,
                                                  org.w3c.dom.Document d,
                                                  MathMLDocumentBuilder db)
      • buildAsDouble

        public org.w3c.dom.Element buildAsDouble​(double val,
                                                 org.w3c.dom.Document d,
                                                 MathMLDocumentBuilder db)
      • isInteger

        protected boolean isInteger​(java.lang.Object val)
        Test if a number is an integer.
        Parameters:
        val - the value to test, typically a Number
        Returns:
        true if val is an Integer, Short or Long or if the Math.rint(val) == val, false otherwise