poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r479289 - in /jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula: eval/FunctionEval.java functions/If.java
Date Sun, 26 Nov 2006 06:13:30 GMT
Author: amol
Date: Sat Nov 25 22:13:29 2006
New Revision: 479289

URL: http://svn.apache.org/viewvc?view=rev&rev=479289
Log:
implemented IF() function

Added:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/If.java
Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java?view=diff&rev=479289&r1=479288&r2=479289
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
(original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
Sat Nov 25 22:13:29 2006
@@ -23,7 +23,7 @@
     private static Function[] produceFunctions() {
         Function[] retval = new Function[368];
         retval[0] = new Count(); // COUNT
-        retval[1] = null; // Specialflag(); // SPECIALFLAG
+        retval[1] = new If(); // IF
         retval[2] = new IsNa(); // ISNA
         retval[3] = new IsError(); // ISERROR
         retval[4] = new Sum(); // SUM

Added: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/If.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/If.java?view=auto&rev=479289
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/If.java
(added)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/If.java
Sat Nov 25 22:13:29 2006
@@ -0,0 +1,39 @@
+/*
+ * Created on Nov 25, 2006
+ *
+ */
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.BoolEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+
+/**
+ * @author Amol S. Deshmukh < amolweb at ya hoo dot com >
+ * 
+ */
+public class If implements Function {
+
+    public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+        Eval retval = null;
+        Eval evalWhenFalse = BoolEval.FALSE;
+        switch (evals.length) {
+        case 3:
+            evalWhenFalse = evals[2];
+        case 2:
+            BoolEval beval = (BoolEval) evals[0];
+            if (beval.getBooleanValue()) {
+                retval = evals[1];
+            }
+            else {
+                retval = evalWhenFalse;
+            }
+            break;
+        default:
+            retval = ErrorEval.UNKNOWN_ERROR;
+        }
+        return retval;
+    }
+
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message