com.singularsys.jep.bigdecimal.functions
Class BigDecAdd

java.lang.Object
  extended by com.singularsys.jep.functions.PostfixMathCommand
      extended by com.singularsys.jep.functions.NaryBinaryFunction
          extended by com.singularsys.jep.bigdecimal.functions.BigDecAdd
All Implemented Interfaces:
PostfixMathCommandI, java.io.Serializable

public class BigDecAdd
extends NaryBinaryFunction

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
BigDecAdd(java.math.MathContext mc)
          Constructor.
 
Method Summary
 java.lang.Object eval(java.lang.Object l, java.lang.Object r)
           
 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, run
 
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BigDecAdd

public BigDecAdd(java.math.MathContext mc)
Constructor. Initialises the math context.

Parameters:
mc -
Method Detail

setMathContext

public void setMathContext(java.math.MathContext mc)

getMathContext

public java.math.MathContext getMathContext()

eval

public java.lang.Object eval(java.lang.Object l,
                             java.lang.Object r)
                      throws EvaluationException
Specified by:
eval in class NaryBinaryFunction
Throws:
EvaluationException

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


Copyright © 2010 Singular Systems http://www.singularsys.com/jep