FileDocCategorySizeDatePackage
MultiplyEval.javaAPI DocApache Poi 3.0.13467Sun Mar 11 12:59:28 GMT 2007org.apache.poi.hssf.record.formula.eval

MultiplyEval

public class MultiplyEval extends NumericOperationEval
author
Amol S. Deshmukh < amolweb at ya hoo dot com >

Fields Summary
private MultiplyPtg
delegate
private static final ValueEvalToNumericXlator
NUM_XLATOR
Constructors Summary
public MultiplyEval(Ptg ptg)


       
        delegate = (MultiplyPtg) ptg;
    
Methods Summary
public Evalevaluate(Eval[] operands, int srcRow, short srcCol)

        Eval retval = null;
        double d0 = 0;
        double d1 = 0;
        switch (operands.length) {
        default: // will rarely happen. currently the parser itself fails.
            retval = ErrorEval.UNKNOWN_ERROR;
            break;
        case 2:
            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
            if (ve instanceof NumericValueEval) {
                d0 = ((NumericValueEval) ve).getNumberValue();
            }
            else if (ve instanceof BlankEval) {
                // do nothing
            }
            else {
                retval = ErrorEval.VALUE_INVALID;
            }
            
            if (retval == null) { // no error yet
                ve = singleOperandEvaluate(operands[1], srcRow, srcCol);
                if (ve instanceof NumericValueEval) {
                    d1 = ((NumericValueEval) ve).getNumberValue();
                }
                else if (ve instanceof BlankEval) {
                    // do nothing
                }
                else {
                    retval = ErrorEval.VALUE_INVALID;
                }
            }
        } // end switch

        if (retval == null) {
            retval = (Double.isNaN(d0) || Double.isNaN(d1)) 
                    ? (ValueEval) ErrorEval.VALUE_INVALID 
                    : new NumberEval(d0 * d1);
        }
        return retval;
    
public intgetNumberOfOperands()

        return delegate.getNumberOfOperands();
    
public intgetType()

        return delegate.getType();
    
protected ValueEvalToNumericXlatorgetXlator()

        return NUM_XLATOR;