Class BigDecAdd
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.NaryBinaryFunction
-
- com.singularsys.jep.functions.Add
-
- com.singularsys.jep.bigdecimal.functions.BigDecAdd
-
- All Implemented Interfaces:
PostfixMathCommandI
,RealBinaryFunction
,java.io.Serializable
public class BigDecAdd extends Add
Function class for the addition operator. It can operate on multiple BigDecimals whose values are added or on Strings which are concatenated together. Inheriting from NaryBinaryFunction creates a n-ary function which is applied repeatedly if more than two arguments are provided.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Constructor Summary
Constructors Constructor Description BigDecAdd(java.math.MathContext mc)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
add(java.lang.Object l, java.lang.Object r)
Adds two numbers together.boolean
getAllowStrings()
Whether adding strings is allowed.java.math.MathContext
getMathContext()
void
setAllowStrings(boolean allowStrings)
Sets whether strings should be allowed with this operator or not.void
setMathContext(java.math.MathContext mc)
-
Methods inherited from class com.singularsys.jep.functions.NaryBinaryFunction
checkNumberOfParameters, eval, instanceOf, instanceOf, run
-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
-
-
-
Method Detail
-
setMathContext
public void setMathContext(java.math.MathContext mc)
-
getMathContext
public java.math.MathContext getMathContext()
-
add
public java.lang.Object add(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from class:Add
Adds two numbers together. The parameters can be of type Number, Complex, or String. If a certain combination of types is not supported, a EvaluationException is thrown.- Overrides:
add
in classAdd
- Parameters:
l
- The first parameter to be added.r
- The second parameter to be added.- Returns:
- The sum of param1 and param2, or concatenation of the two if they are Strings.
- Throws:
EvaluationException
- if the calculation cannot be performed
-
getAllowStrings
public boolean getAllowStrings()
Whether adding strings is allowed. (Treated as concatenation ).- Returns:
- true if allowed
- Since:
- 3.4.0
-
setAllowStrings
public void setAllowStrings(boolean allowStrings)
Sets whether strings should be allowed with this operator or not.- Parameters:
allowStrings
- When true, strings are allowed. When false an IllegalParameterException is thrown during evaluation.- Since:
- 3.4.0
-
-