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

UnaryPlusEval

public class UnaryPlusEval extends Object implements OperationEval
author
Amol S. Deshmukh < amolweb at ya hoo dot com >

Fields Summary
private UnaryPlusPtg
delegate
Constructors Summary
public UnaryPlusEval(Ptg ptg)

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

        ValueEval retval = null;
        
        switch (operands.length) {
        default:
            retval = ErrorEval.UNKNOWN_ERROR;
            break;
        case 1:

//            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
//            if (ve instanceof NumericValueEval) {
//                d = ((NumericValueEval) ve).getNumberValue();
//            }
//            else if (ve instanceof BlankEval) {
//                // do nothing
//            }
//            else if (ve instanceof ErrorEval) {
//                retval = ve;
//            }
            if (operands[0] instanceof RefEval) {
                RefEval re = (RefEval) operands[0];
                retval = re.getInnerValueEval();
            }
            else if (operands[0] instanceof AreaEval) {
                AreaEval ae = (AreaEval) operands[0];
                if (ae.contains(srcRow, srcCol)) { // circular ref!
                    retval = ErrorEval.CIRCULAR_REF_ERROR;
                }
                else if (ae.isRow()) {
                    if (ae.containsColumn(srcCol)) {
                        ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
                        if (ve instanceof RefEval) {
                            ve = ((RefEval) ve).getInnerValueEval();
                        }
                        retval = ve;
                    }
                    else {
                        retval = ErrorEval.VALUE_INVALID;
                    }
                }
                else if (ae.isColumn()) {
                    if (ae.containsRow(srcRow)) {
                        ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
                        if (ve instanceof RefEval) {
                            ve = ((RefEval) ve).getInnerValueEval();
                        }
                        retval = ve;
                    }
                    else {
                        retval = ErrorEval.VALUE_INVALID;
                    }
                }
                else {
                    retval = ErrorEval.VALUE_INVALID;
                }
            }
            else {
                retval = (ValueEval) operands[0];
            }
        }
        
        if (retval instanceof BlankEval) {
            retval = new NumberEval(0);
        }

        return retval;
    
public intgetNumberOfOperands()

        return delegate.getNumberOfOperands();
    
public intgetType()

        return delegate.getType();