* @param func the functoin to register
* @throws IllegalArgumentException if the function is unknown or already registered.
* @since 3.8 beta6
*/
public static void registerFunction(String name, Function func){
FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByName(name);
if(metaData == null) {
if(AnalysisToolPak.isATPFunction(name)) {
throw new IllegalArgumentException(name + " is a function from the Excel Analysis Toolpack. " +
"Use AnalysisToolpack.registerFunction(String name, FreeRefFunction func) instead.");
} else {
throw new IllegalArgumentException("Unknown function: " + name);
}
}
int idx = metaData.getIndex();
if(functions[idx] instanceof NotImplementedFunction) {
functions[idx] = func;
} else {
throw new IllegalArgumentException("POI already implememts " + name +
". You cannot override POI's implementations of Excel functions");