Package org.apache.poi.hssf.record.formula.eval

Examples of org.apache.poi.hssf.record.formula.eval.Eval


* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
*
*/
public class Isnontext extends LogicalFunction {
    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        Eval retval = BoolEval.TRUE;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            Eval eval = operands[0];
            if (eval instanceof StringEval) {
                retval = BoolEval.FALSE;
            }
            else if (eval instanceof RefEval) {
                Eval xlatedEval = xlateRefEval((RefEval) eval);
                if (xlatedEval instanceof StringEval) {
                    retval = BoolEval.FALSE;
                }
            }
        }
View Full Code Here


            default:
                return ErrorEval.VALUE_INVALID;
            case 1:
                 break;
        }
        Eval arg = args[0];
        if (arg instanceof RefEval) {
            RefEval re = (RefEval) arg;
            arg = re.getInnerValueEval();
        }
       
View Full Code Here

*/
public final class If implements Function {

    public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {

        Eval evalWhenFalse = BoolEval.FALSE;
        switch (args.length) {
        case 3:
            evalWhenFalse = args[2];
        case 2:
            BoolEval beval = (BoolEval) args[0]; // TODO - class cast exception
View Full Code Here

      int nArrayItems = xops.length;
    if(nArrayItems != yops.length) {
        throw new EvaluationException(ErrorEval.NA);
      }
    for (int i = 0; i < xops.length; i++) {
      Eval eval = xops[i];
      if (eval instanceof ErrorEval) {
        throw new EvaluationException((ErrorEval) eval);
      }
    }
    for (int i = 0; i < yops.length; i++) {
      Eval eval = yops[i];
      if (eval instanceof ErrorEval) {
        throw new EvaluationException((ErrorEval) eval);
      }
    }
   
        double[] xResult = new double[nArrayItems];
        double[] yResult = new double[nArrayItems];
     
        int count = 0;
       
    for (int i=0, iSize=nArrayItems; i<iSize; i++) {
        Eval xEval = xops[i];
        Eval yEval = yops[i];
       
        if (isNumberEval(xEval) && isNumberEval(yEval)) {
          xResult[count] = getDoubleValue(xEval);
          yResult[count] = getDoubleValue(yEval);
            if (Double.isNaN(xResult[count]) || Double.isNaN(xResult[count])) {
View Full Code Here

  public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
    if(args.length != 1) {
      return ErrorEval.VALUE_INVALID;
    }
    Eval arg = args[0];
   
    ValueEval singleCellValue;
    try {
      singleCellValue = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
    } catch (EvaluationException e) {
View Full Code Here

        // perhaps this should be an exception
        return ErrorEval.VALUE_INVALID;
    }
   
    AreaEval range = (AreaEval) args[0];
    Eval criteriaArg = args[1];
    if(criteriaArg instanceof RefEval) {
      // criteria is not a literal value, but a cell reference
      // for example COUNTIF(B2:D4, E1)
      RefEval re = (RefEval)criteriaArg;
      criteriaArg = re.getInnerValueEval();
View Full Code Here

      return _size;
    }
  }

  public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
    Eval arg3 = null;
    switch(args.length) {
      case 4:
        arg3 = args[3]; // important: assumed array element is never null
      case 3:
        break;
View Full Code Here

    Eval[] args = new Eval[] { text, startPos, numChars, };
    return new Mid().evaluate(args, -1, (short)-1);
  }

  private void confirmMid(Eval text, Eval startPos, Eval numChars, String expected) {
    Eval result = invokeMid(text, startPos, numChars);
    assertEquals(StringEval.class, result.getClass());
    assertEquals(expected, ((StringEval)result).getStringValue());
  }
View Full Code Here

    assertEquals(StringEval.class, result.getClass());
    assertEquals(expected, ((StringEval)result).getStringValue());
  }

  private void confirmMid(Eval text, Eval startPos, Eval numChars, ErrorEval expectedError) {
    Eval result = invokeMid(text, startPos, numChars);
    assertEquals(ErrorEval.class, result.getClass());
    assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
  }
View Full Code Here

  private static Eval invokeAverage(Eval[] args) {
    return new Average().evaluate(args, -1, (short)-1);
  }

  private void confirmAverage(Eval[] args, double expected) {
    Eval result = invokeAverage(args);
    assertEquals(NumberEval.class, result.getClass());
    assertEquals(expected, ((NumberEval)result).getNumberValue(), 0);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.eval.Eval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.