All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.obdobion.algebrain.function.FuncFlatRate Maven / Gradle / Ivy

The newest version!
package com.obdobion.algebrain.function;

import java.text.ParseException;

import com.obdobion.algebrain.Function;
import com.obdobion.algebrain.ValueStack;
import com.obdobion.algebrain.support.EquationSupport;
import com.obdobion.algebrain.token.TokVariable;

/**
 * 

* FuncFlatRate class. *

* * @author Chris DeGreef [email protected] * @since 1.3.9 */ public class FuncFlatRate extends Function { /** *

* Constructor for FuncFlatRate. *

*/ public FuncFlatRate() { super(); } /** *

* Constructor for FuncFlatRate. *

* * @param var a {@link com.obdobion.algebrain.token.TokVariable} object. */ public FuncFlatRate(final TokVariable var) { super(var); } /** {@inheritDoc} */ @Override public void resolve(final ValueStack values) throws Exception { if (values.size() < getParameterCount()) throw new Exception("missing operands for " + toString()); try { final String tableName = values.popString(); final String[] keys = new String[5]; for (int a = 0; a < getParameterCount() - 1; a++) keys[a] = values.popString(); final EquationSupport model = getEqu().getSupport(); double rate = 0D; rate = model.resolveRate(tableName, getEqu().getBaseDate(), keys[0], keys[1], keys[2], keys[3], keys[4]); values.push(new Double(rate)); } catch (final ParseException e) { e.fillInStackTrace(); throw new Exception(toString() + "; " + e.getMessage(), e); } } /** {@inheritDoc} */ @Override public String toString() { return "function(flatrate)"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy