Examples of Eval


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

* @author Josh Micich
*/
public final class Hlookup implements Function {

  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

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

    int maxN = args.length;

    if(maxN < 1) {
      return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];
    try {
      if(firstArg instanceof NumericValueEval) {
        return evaluateSingleProduct(args);
      }
      if(firstArg instanceof RefEval) {
        return evaluateSingleProduct(args);
      }
      if(firstArg instanceof AreaEval) {
        AreaEval ae = (AreaEval) firstArg;
        if(ae.isRow() && ae.isColumn()) {
          return evaluateSingleProduct(args);
        }
        return evaluateAreaSumProduct(args);
      }
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
    throw new RuntimeException("Invalid arg type for SUMPRODUCT: ("
        + firstArg.getClass().getName() + ")");
  }
View Full Code Here

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

    return new NumberEval(term);
  }

  private static double getScalarValue(Eval arg) throws EvaluationException {

    Eval eval;
    if (arg instanceof RefEval) {
      RefEval re = (RefEval) arg;
      eval = re.getInnerValueEval();
    } else {
      eval = arg;
    }

    if (eval == null) {
      throw new RuntimeException("parameter may not be null");
    }
    if (eval instanceof AreaEval) {
      AreaEval ae = (AreaEval) eval;
      // an area ref can work as a scalar value if it is 1x1
      if(!ae.isColumn() || !ae.isRow()) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      eval = ae.getRelativeValue(0, 0);
    }

    if (!(eval instanceof ValueEval)) {
      throw new RuntimeException("Unexpected value eval class ("
          + eval.getClass().getName() + ")");
    }

    return getProductTerm((ValueEval) eval, true);
  }
View Full Code Here

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

*
*/
public final class Islogical extends LogicalFunction {

    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        Eval retval = BoolEval.FALSE;

        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            Eval eval = operands[0];
            if (eval instanceof BoolEval) {
                retval = BoolEval.TRUE;
            }
            else if (eval instanceof RefEval) {
                Eval xlatedEval = xlateRefEval((RefEval) eval);
                if (xlatedEval instanceof BoolEval) {
                    retval = BoolEval.TRUE;
                }
            }
        }
View Full Code Here

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

        return ErrorEval.VALUE_INVALID;
      default:
        // too many arguments
        return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];

    int result;
    if (firstArg instanceof AreaEval) {
      AreaEval ae = (AreaEval) firstArg;
      result = ae.getLastColumn() - ae.getFirstColumn() + 1;
View Full Code Here

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

   * Creates a criteria predicate object for the supplied criteria arg
   * @return <code>null</code> if the arg evaluates to blank.
   */
  /* package */ static I_MatchPredicate createCriteriaPredicate(Eval arg, int srcRowIndex, int srcColumnIndex) {

    Eval evaluatedCriteriaArg = evaluateCriteriaArg(arg, srcRowIndex, srcColumnIndex);

    if(evaluatedCriteriaArg instanceof NumberEval) {
      return new NumberMatcher(((NumberEval)evaluatedCriteriaArg).getNumberValue(), CmpOp.OP_NONE);
    }
    if(evaluatedCriteriaArg instanceof BoolEval) {
      return new BooleanMatcher(((BoolEval)evaluatedCriteriaArg).getBooleanValue(), CmpOp.OP_NONE);
    }

    if(evaluatedCriteriaArg instanceof StringEval) {
      return createGeneralMatchPredicate((StringEval)evaluatedCriteriaArg);
    }
    if(evaluatedCriteriaArg instanceof ErrorEval) {
      return new ErrorMatcher(((ErrorEval)evaluatedCriteriaArg).getErrorCode(), CmpOp.OP_NONE);
    }
    if(evaluatedCriteriaArg == BlankEval.INSTANCE) {
      return null;
    }
    throw new RuntimeException("Unexpected type for criteria ("
        + evaluatedCriteriaArg.getClass().getName() + ")");
  }
View Full Code Here

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

* @author Josh Micich
*/
public final class Vlookup implements Function {

  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

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

* @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
*
*/
public final 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

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

            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

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

        return ErrorEval.VALUE_INVALID;
      default:
        // too many arguments
        return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];

    int result;
    if (firstArg instanceof AreaEval) {
      AreaEval ae = (AreaEval) firstArg;
      result = ae.getLastRow() - ae.getFirstRow() + 1;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.