reverted changes of r1747942 and deprecated instead
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748313 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
227a62ce1e
commit
d8437d0476
@ -48,7 +48,7 @@ public class SettingExternalFunction {
|
||||
/**
|
||||
* wrap external functions in a plugin
|
||||
*/
|
||||
public static class BloombergAddIn extends UDFFinder {
|
||||
public static class BloombergAddIn implements UDFFinder {
|
||||
private final Map<String, FreeRefFunction> _functionsByName;
|
||||
|
||||
public BloombergAddIn() {
|
||||
@ -89,7 +89,6 @@ public class SettingExternalFunction {
|
||||
wb.write(out);
|
||||
out.close();
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.io.PrintWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
@ -38,7 +39,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.poi.EncryptedDocumentException;
|
||||
@ -181,7 +181,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* The locator of user-defined functions.
|
||||
* By default includes functions from the Excel Analysis Toolpack
|
||||
*/
|
||||
private UDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.getDefault());
|
||||
private UDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT);
|
||||
|
||||
public static HSSFWorkbook create(InternalWorkbook book) {
|
||||
return new HSSFWorkbook(book);
|
||||
|
@ -44,7 +44,7 @@ import org.apache.poi.ss.formula.udf.UDFFinder;
|
||||
/**
|
||||
* Analysis Toolpack Function Definitions
|
||||
*/
|
||||
public final class AnalysisToolPak extends UDFFinder {
|
||||
public final class AnalysisToolPak implements UDFFinder {
|
||||
|
||||
public static final UDFFinder instance = new AnalysisToolPak();
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.poi.ss.formula.udf;
|
||||
|
||||
import org.apache.poi.ss.formula.atp.AnalysisToolPak;
|
||||
import org.apache.poi.ss.formula.functions.FreeRefFunction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -25,8 +26,15 @@ import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Collects add-in libraries and VB macro functions together into one UDF finder
|
||||
*
|
||||
* @author PUdalau
|
||||
*/
|
||||
public class AggregatingUDFFinder extends UDFFinder {
|
||||
public class AggregatingUDFFinder implements UDFFinder {
|
||||
|
||||
/**
|
||||
* Default UDFFinder implementation
|
||||
*/
|
||||
public static final UDFFinder DEFAULT = new AggregatingUDFFinder(AnalysisToolPak.instance);
|
||||
|
||||
private final Collection<UDFFinder> _usedToolPacks;
|
||||
|
||||
|
@ -25,8 +25,10 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
|
||||
|
||||
/**
|
||||
* Default UDF finder - for adding your own user defined functions.
|
||||
*
|
||||
* @author PUdalau
|
||||
*/
|
||||
public final class DefaultUDFFinder extends UDFFinder {
|
||||
public final class DefaultUDFFinder implements UDFFinder {
|
||||
private final Map<String, FreeRefFunction> _functionsByName;
|
||||
|
||||
public DefaultUDFFinder(String[] functionNames, FreeRefFunction[] functionImpls) {
|
||||
|
@ -21,12 +21,18 @@ import org.apache.poi.ss.formula.atp.AnalysisToolPak;
|
||||
import org.apache.poi.ss.formula.functions.FreeRefFunction;
|
||||
|
||||
/**
|
||||
* Common abstract class for "Add-in" libraries and user defined function libraries.
|
||||
* Common interface for "Add-in" libraries and user defined function libraries.
|
||||
*/
|
||||
public abstract class UDFFinder {
|
||||
public static UDFFinder getDefault() {
|
||||
return new AggregatingUDFFinder(AnalysisToolPak.instance);
|
||||
}
|
||||
public interface UDFFinder {
|
||||
// FIXME: Findbugs error: IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION
|
||||
/**
|
||||
* Default UDFFinder implementation
|
||||
*
|
||||
* @deprecated use AggregatingUDFFinder.DEFAULT instead, deprecated in POI 3.15,
|
||||
* scheduled for removable in POI 3.17
|
||||
*/
|
||||
@Deprecated
|
||||
public static final UDFFinder DEFAULT = new AggregatingUDFFinder(AnalysisToolPak.instance);
|
||||
|
||||
/**
|
||||
* Returns executor by specified name. Returns <code>null</code> if the function name is unknown.
|
||||
@ -34,5 +40,5 @@ public abstract class UDFFinder {
|
||||
* @param name Name of function.
|
||||
* @return Function executor.
|
||||
*/
|
||||
public abstract FreeRefFunction findFunction(String name);
|
||||
FreeRefFunction findFunction(String name);
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.regex.Pattern;
|
||||
@ -57,6 +56,7 @@ import org.apache.poi.openxml4j.opc.TargetMode;
|
||||
import org.apache.poi.poifs.crypt.HashAlgorithm;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.formula.SheetNameFormatter;
|
||||
import org.apache.poi.ss.formula.udf.AggregatingUDFFinder;
|
||||
import org.apache.poi.ss.formula.udf.IndexedUDFFinder;
|
||||
import org.apache.poi.ss.formula.udf.UDFFinder;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
@ -160,7 +160,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
|
||||
* The locator of user-defined functions.
|
||||
* By default includes functions from the Excel Analysis Toolpack
|
||||
*/
|
||||
private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.getDefault());
|
||||
private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
|
@ -106,7 +106,7 @@ public final class TestWorkbook {
|
||||
public void testAddNameX() throws IOException {
|
||||
HSSFWorkbook hwb = new HSSFWorkbook();
|
||||
InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(hwb);
|
||||
assertNotNull(wb.getNameXPtg("ISODD", UDFFinder.getDefault()));
|
||||
assertNotNull(wb.getNameXPtg("ISODD", AggregatingUDFFinder.DEFAULT));
|
||||
|
||||
FreeRefFunction NotImplemented = new FreeRefFunction() {
|
||||
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
|
||||
|
Loading…
Reference in New Issue
Block a user