Class NumberBuilder
- java.lang.Object
-
- com.singularsys.extensions.mathml.builder.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
- ALLWAYS_DOUBLE <cn>2.0</cn>
- NO_DECIMALPOINT <cn>2.0</cn>
- TYPE_INTEGER <cn type="integer">2</cn>
- Author:
- Richard Morris
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NumberBuilder.DoubleBehaviour
-
Constructor Summary
Constructors Constructor Description NumberBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.Element
build(Node n, org.w3c.dom.Document d, MathMLDocumentBuilder db)
Builds a Element for a jep Node.org.w3c.dom.Element
buildAsComplex(Complex val, org.w3c.dom.Document d, MathMLDocumentBuilder db)
org.w3c.dom.Element
buildAsDouble(double val, org.w3c.dom.Document d, MathMLDocumentBuilder db)
org.w3c.dom.Element
buildAsInteger(long val, org.w3c.dom.Document d, MathMLDocumentBuilder db)
NumberBuilder.DoubleBehaviour
getDoubleBehaviour()
protected boolean
isInteger(java.lang.Object val)
Test if a number is an integer.void
setDoubleBehaviour(NumberBuilder.DoubleBehaviour doubleBehaviour)
-
-
-
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)
-
buildAsComplex
public org.w3c.dom.Element buildAsComplex(Complex val, org.w3c.dom.Document d, MathMLDocumentBuilder db)
-
build
public org.w3c.dom.Element build(Node n, org.w3c.dom.Document d, MathMLDocumentBuilder db) throws JepException
Description copied from interface:MathMLFragmentBuilder
Builds a Element for a jep Node.- Specified by:
build
in 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
-
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
-
getDoubleBehaviour
public NumberBuilder.DoubleBehaviour getDoubleBehaviour()
-
setDoubleBehaviour
public void setDoubleBehaviour(NumberBuilder.DoubleBehaviour doubleBehaviour)
-
-