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

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


* @author Josh Micich
*/
public final class TestValue extends TestCase {

  private static Eval invokeValue(String strText) {
    Eval[] args = new Eval[] { new StringEval(strText), };
    return new Value().evaluate(args, -1, (short) -1);
  }
View Full Code Here


                BoolEval be = (BoolEval) eval;
                retval = new CellValue(HSSFCell.CELL_TYPE_BOOLEAN);
                retval.setBooleanValue(be.getBooleanValue());
            }
            else if (eval instanceof StringEval) {
                StringEval ne = (StringEval) eval;
                retval = new CellValue(HSSFCell.CELL_TYPE_STRING);
                retval.setStringValue(ne.getStringValue());
            }
            else if (eval instanceof BlankEval) {
                retval = new CellValue(HSSFCell.CELL_TYPE_BLANK);
            }
            else if (eval instanceof ErrorEval) {
View Full Code Here

        }
        switch (cell.getCellType()) {
            case HSSFCell.CELL_TYPE_NUMERIC:
                return new NumberEval(cell.getNumericCellValue());
            case HSSFCell.CELL_TYPE_STRING:
                return new StringEval(cell.getRichStringCellValue().getString());
            case HSSFCell.CELL_TYPE_FORMULA:
                return internalEvaluate(cell, row, sheet, workbook);
            case HSSFCell.CELL_TYPE_BOOLEAN:
                return BoolEval.valueOf(cell.getBooleanCellValue());
            case HSSFCell.CELL_TYPE_BLANK:
View Full Code Here

       
        switch (cell.getCellType()) {
            case HSSFCell.CELL_TYPE_NUMERIC:
                return new Ref2DEval(ptg, new NumberEval(cell.getNumericCellValue()));
            case HSSFCell.CELL_TYPE_STRING:
                return new Ref2DEval(ptg, new StringEval(cell.getRichStringCellValue().getString()));
            case HSSFCell.CELL_TYPE_FORMULA:
                return new Ref2DEval(ptg, internalEvaluate(cell, row, sheet, workbook));
            case HSSFCell.CELL_TYPE_BOOLEAN:
                return new Ref2DEval(ptg, BoolEval.valueOf(cell.getBooleanCellValue()));
            case HSSFCell.CELL_TYPE_BLANK:
View Full Code Here

        }
        switch (cell.getCellType()) {
            case HSSFCell.CELL_TYPE_NUMERIC:
                return new Ref3DEval(ptg, new NumberEval(cell.getNumericCellValue()));
            case HSSFCell.CELL_TYPE_STRING:
                return new Ref3DEval(ptg, new StringEval(cell.getRichStringCellValue().getString()));
            case HSSFCell.CELL_TYPE_FORMULA:
                return new Ref3DEval(ptg, internalEvaluate(cell, row, sheet, workbook));
            case HSSFCell.CELL_TYPE_BOOLEAN:
                return new Ref3DEval(ptg, BoolEval.valueOf(cell.getBooleanCellValue()));
            case HSSFCell.CELL_TYPE_BLANK:
View Full Code Here

    // Error handling for lookup_range arg is also unusual
    if(eval instanceof NumericValueEval) {
      throw new EvaluationException(ErrorEval.NA);
    }
    if (eval instanceof StringEval) {
      StringEval se = (StringEval) eval;
      Double d = OperandResolver.parseDouble(se.getStringValue());
      if(d == null) {
        // plain string
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      // else looks like a number
View Full Code Here

    if(match_type instanceof NumericValueEval) {
      NumericValueEval ne = (NumericValueEval) match_type;
      return ne.getNumberValue();
    }
    if (match_type instanceof StringEval) {
      StringEval se = (StringEval) match_type;
      Double d = OperandResolver.parseDouble(se.getStringValue());
      if(d == null) {
        // plain string
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      // if the string parses as a number, it is OK
View Full Code Here

      _value = value;
    }

    public boolean matches(Eval x) {
      if(x instanceof StringEval) {
        StringEval se = (StringEval)x;
        Boolean val = parseBoolean(se.getStringValue());
        if(val == null) {
          // x is text that is not a boolean
          return false;
        }
        if (true) { // change to false to observe more intuitive behaviour
View Full Code Here

    public boolean matches(Eval x) {
      if(!(x instanceof StringEval)) {
        return false;
      }
      StringEval se = (StringEval) x;
      return se.getStringValue() == _value;
    }
View Full Code Here

            }
        case 1:
            ValueEval veval = singleOperandEvaluate(operands[0], srcCellRow, srcCellCol);
            String str = null;
            if (veval instanceof StringEval) {
                StringEval stringEval = (StringEval) veval;
                str = stringEval.getStringValue();
            }
            else if (veval instanceof BoolEval) {
                BoolEval beval = (BoolEval) veval;
                str = beval.getBooleanValue() ? "TRUE" : "FALSE";
            }
            else if (veval instanceof NumberEval) {
                NumberEval neval = (NumberEval) veval;
                str = neval.getStringValue();
            }
            if (null != str) {
                int strlen = str.length();
                str = str.substring(Math.max(0, strlen-index));
                retval = new StringEval(str);
            }
        }
        return retval;
    }
View Full Code Here

TOP

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

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.