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

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


            NumberEval neval = (NumberEval) eval;
            double d = neval.getNumberValue();
            numval = (int) d;
        }
        else if (eval instanceof StringEval) {
            StringEval seval = (StringEval) eval;
            String s = seval.getStringValue();
            try {
                double d = Double.parseDouble(s);
                numval = (int) d;
            }
            catch (Exception e) {
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) {
                str = str.substring(0, Math.min(str.length(), index));
                retval = new StringEval(str);
            }
        }
        return retval;
    }
View Full Code Here

            NumberEval neval = (NumberEval) eval;
            double d = neval.getNumberValue();
            numval = (int) d;
        }
        else if (eval instanceof StringEval) {
            StringEval seval = (StringEval) eval;
            String s = seval.getStringValue();
            try {
                double d = Double.parseDouble(s);
                numval = (int) d;
            }
            catch (Exception e) {
View Full Code Here

                break;
            }
        }
       
        if (retval == null) {
            retval = new StringEval(sb.toString());
        }
       
        return retval;
    }
View Full Code Here

        else if (ve instanceof NumberEval) {
            NumberEval ne = (NumberEval) ve;
            retval = ne.getNumberValue() != 0 ? BoolEval.TRUE : BoolEval.FALSE;
        }
        else if (ve instanceof StringEval) {
            StringEval se = (StringEval) ve;
            String str = se.getStringValue();
            retval = str.equalsIgnoreCase("true")
                    ? BoolEval.TRUE
                    : str.equalsIgnoreCase("false")
                            ? BoolEval.FALSE
                            : (ValueEval) ErrorEval.VALUE_INVALID;
View Full Code Here

            }
        }
       
        if (retval == null) {
            s = (s == null) ? EMPTY_STRING : s;
            retval = new StringEval(s.toLowerCase());
        }
       
        return retval;
    }
View Full Code Here

    public boolean matches(Eval x) {
      if(x instanceof StringEval) {
        // if the target(x) is a string, but parses as a number
        // it may still count as a match
        StringEval se = (StringEval)x;
        Double val = parseDouble(se.getStringValue());
        if(val == null) {
          // x is text that is not a number
          return false;
        }
        return val.doubleValue() == _value;
View Full Code Here

            }
        }
       
        if (retval == null) {
            s = (s == null) ? EMPTY_STRING : s;
            retval = new StringEval(s.toUpperCase());
        }
       
        return retval;
    }
View Full Code Here

   
    if (ve instanceof NumericValueEval) {
      return ((NumericValueEval) ve).getNumberValue();
    }
    if (ve instanceof StringEval) {
      StringEval se = (StringEval) ve;
      Double d = parseDouble(se.getStringValue());
      if(d == null) {
        throw new EvalEx(ErrorEval.VALUE_INVALID);
      }
      return d.doubleValue();
    }
View Full Code Here

    }
    if (numChars < 0) {
      return ErrorEval.VALUE_INVALID;
    }
    if (numChars < 0 || startIx > len) {
      return new StringEval("");
    }
    int endIx = startIx + numChars;
    if (endIx > len) {
      endIx = len;
    }
    String result = text.substring(startIx, endIx);
    return new StringEval(result);

  }
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.