poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1607588 - in /poi/trunk/src/java/org/apache/poi/ss/formula: ./ atp/ eval/ functions/
Date Thu, 03 Jul 2014 11:20:32 GMT
Author: nick
Date: Thu Jul  3 11:20:32 2014
New Revision: 1607588

URL: http://svn.apache.org/r1607588
Log:
When throwing an exception during formula evaluation, if this is due to an unimplemented function,
have a more specific exception type

Added:
    poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedFunctionException.java
Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/UserDefinedFunction.java
    poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
    poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedException.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/NotImplementedFunction.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/Subtotal.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/UserDefinedFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/UserDefinedFunction.java?rev=1607588&r1=1607587&r2=1607588&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/UserDefinedFunction.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/UserDefinedFunction.java Thu Jul  3 11:20:32
2014
@@ -19,9 +19,9 @@ package org.apache.poi.ss.formula;
 
 import org.apache.poi.ss.formula.eval.NameEval;
 import org.apache.poi.ss.formula.eval.NameXEval;
+import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.functions.FreeRefFunction;
-import org.apache.poi.ss.formula.eval.NotImplementedException;
 /**
  *
  * Common entry point for all user-defined (non-built-in) functions (where
@@ -56,7 +56,7 @@ final class UserDefinedFunction implemen
 		}
 		FreeRefFunction targetFunc = ec.findUserDefinedFunction(functionName);
 		if (targetFunc == null) {
-			throw new NotImplementedException(functionName);
+			throw new NotImplementedFunctionException(functionName);
 		}
 		int nOutGoingArgs = nIncomingArgs -1;
 		ValueEval[] outGoingArgs = new ValueEval[nOutGoingArgs];

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java?rev=1607588&r1=1607587&r2=1607588&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java Thu Jul  3 11:20:32
2014
@@ -10,16 +10,35 @@
 
 package org.apache.poi.ss.formula.atp;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeSet;
+
 import org.apache.poi.ss.formula.OperationEvaluationContext;
-import org.apache.poi.ss.formula.eval.NotImplementedException;
+import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.function.FunctionMetadata;
 import org.apache.poi.ss.formula.function.FunctionMetadataRegistry;
-import org.apache.poi.ss.formula.functions.*;
+import org.apache.poi.ss.formula.functions.Bin2Dec;
+import org.apache.poi.ss.formula.functions.Complex;
+import org.apache.poi.ss.formula.functions.Countifs;
+import org.apache.poi.ss.formula.functions.Dec2Bin;
+import org.apache.poi.ss.formula.functions.Dec2Hex;
+import org.apache.poi.ss.formula.functions.Delta;
+import org.apache.poi.ss.formula.functions.EDate;
+import org.apache.poi.ss.formula.functions.FactDouble;
+import org.apache.poi.ss.formula.functions.FreeRefFunction;
+import org.apache.poi.ss.formula.functions.Hex2Dec;
+import org.apache.poi.ss.formula.functions.ImReal;
+import org.apache.poi.ss.formula.functions.Imaginary;
+import org.apache.poi.ss.formula.functions.Oct2Dec;
+import org.apache.poi.ss.formula.functions.Quotient;
+import org.apache.poi.ss.formula.functions.Sumifs;
+import org.apache.poi.ss.formula.functions.WeekNum;
 import org.apache.poi.ss.formula.udf.UDFFinder;
 
-import java.util.*;
-
 /**
  * Analysis Toolpack Function Definitions
  */
@@ -35,7 +54,7 @@ public final class AnalysisToolPak imple
         }
 
         public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
-            throw new NotImplementedException(_functionName);
+            throw new NotImplementedFunctionException(_functionName);
         }
     }
 

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedException.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedException.java?rev=1607588&r1=1607587&r2=1607588&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedException.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedException.java Thu Jul
 3 11:20:32 2014
@@ -20,14 +20,18 @@ package org.apache.poi.ss.formula.eval;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 
 /**
- * An exception thrown by implementors of {@link FormulaEvaluator} when attempting to evaluate
- * a formula which requires features that POI does not (yet) support.
- *
- * @author Josh Micich
+ * An exception thrown by implementors of {@link FormulaEvaluator},
+ *  when attempting to evaluate a formula which requires features
+ *   that POI does not (yet) support.
+ * 
+ * <p>Where possible, a subclass of this should be thrown, to provide
+ *  more detail of what part of the formula couldn't be processed due
+ *  to a missing implementation
  */
-public final class NotImplementedException extends RuntimeException {
-
-	public NotImplementedException(String message) {
+public class NotImplementedException extends RuntimeException {
+    private static final long serialVersionUID = -5840703336495141301L;
+    
+    public NotImplementedException(String message) {
 		super(message);
 	}
 	public NotImplementedException(String message, NotImplementedException cause) {

Added: poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedFunctionException.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedFunctionException.java?rev=1607588&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedFunctionException.java
(added)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/NotImplementedFunctionException.java
Thu Jul  3 11:20:32 2014
@@ -0,0 +1,44 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.ss.formula.eval;
+
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+
+/**
+ * An exception thrown by implementors of {@link FormulaEvaluator} when 
+ *  attempting to evaluate a formula which requires a function that POI 
+ *  does not (yet) support.
+ */
+public final class NotImplementedFunctionException extends NotImplementedException {
+    private static final long serialVersionUID = 1208119411557559057L;
+    
+    private String functionName;
+    
+	public NotImplementedFunctionException(String functionName) {
+		super(functionName);
+		this.functionName = functionName;
+	}
+	public NotImplementedFunctionException(String functionName, NotImplementedException cause)
{
+		super(functionName, cause);
+        this.functionName = functionName;
+	}
+	
+	public String getFunctionName() {
+	    return functionName;
+	}
+}

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/NotImplementedFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/NotImplementedFunction.java?rev=1607588&r1=1607587&r2=1607588&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/NotImplementedFunction.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/NotImplementedFunction.java Thu
Jul  3 11:20:32 2014
@@ -17,15 +17,13 @@
 
 package org.apache.poi.ss.formula.functions;
 
+import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
 import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.ss.formula.eval.NotImplementedException;
 
 /**
- *
- * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
  * This is the default implementation of a Function class.
  * The default behaviour is to raise a POI internal error
- * ({@link NotImplementedException}). This error should alert
+ * ({@link NotImplementedFunctionException}). This error should alert
  * the user that the formula contained a function that is not
  * yet implemented.
  */
@@ -39,7 +37,7 @@ public final class NotImplementedFunctio
 	}
 
 	public ValueEval evaluate(ValueEval[] operands, int srcRow, int srcCol) {
-		throw new NotImplementedException(_functionName);
+		throw new NotImplementedFunctionException(_functionName);
 	}
 	public String getFunctionName() {
 		return _functionName;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Subtotal.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Subtotal.java?rev=1607588&r1=1607587&r2=1607588&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Subtotal.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Subtotal.java Thu Jul  3 11:20:32
2014
@@ -17,12 +17,14 @@
 
 package org.apache.poi.ss.formula.functions;
 
+import static org.apache.poi.ss.formula.functions.AggregateFunction.subtotalInstance;
+
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.EvaluationException;
+import org.apache.poi.ss.formula.eval.NotImplementedException;
+import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
 import org.apache.poi.ss.formula.eval.OperandResolver;
 import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.ss.formula.eval.NotImplementedException;
-import static org.apache.poi.ss.formula.functions.AggregateFunction.subtotalInstance;
 
 /**
  * Implementation for the Excel function SUBTOTAL<p>
@@ -68,10 +70,10 @@ public class Subtotal implements Functio
 			case 5: return subtotalInstance(AggregateFunction.MIN);
 			case 6: return subtotalInstance(AggregateFunction.PRODUCT);
 			case 7: return subtotalInstance(AggregateFunction.STDEV);
-			case 8: throw new NotImplementedException("STDEVP");
+			case 8: throw new NotImplementedFunctionException("STDEVP");
 			case 9: return subtotalInstance(AggregateFunction.SUM);
-			case 10: throw new NotImplementedException("VAR");
-			case 11: throw new NotImplementedException("VARP");
+			case 10: throw new NotImplementedFunctionException("VAR");
+			case 11: throw new NotImplementedFunctionException("VARP");
 		}
 		if (functionCode > 100 && functionCode < 112) {
 			throw new NotImplementedException("SUBTOTAL - with 'exclude hidden values' option");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message