Examples of FunctionMetadata


Examples of org.apache.poi.ss.formula.function.FunctionMetadata

     * @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");
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

     */
    public static Collection<String> getSupportedFunctionNames(){
        Collection<String> lst = new TreeSet<String>();
        for(int i = 0; i < functions.length; i++){
            Function func = functions[i];
            FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByIndex(i);
            if(func != null && !(func instanceof NotImplementedFunction)){
                lst.add(metaData.getName());
            }
        }
        lst.add("INDIRECT"); // INDIRECT is a special case
        return Collections.unmodifiableCollection(lst);
    }
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

    public static Collection<String> getNotSupportedFunctionNames(){
        Collection<String> lst = new TreeSet<String>();
        for(int i = 0; i < functions.length; i++){
            Function func = functions[i];
            if(func != null && (func instanceof NotImplementedFunction)){
                FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByIndex(i);
                lst.add(metaData.getName());
            }
        }
        lst.remove("INDIRECT"); // INDIRECT is a special case
        return Collections.unmodifiableCollection(lst);
    }
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

     * @since 3.8 beta6
     */
   public static void registerFunction(String name, FreeRefFunction func){
        AnalysisToolPak inst = (AnalysisToolPak)instance;
        if(!isATPFunction(name)) {
            FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByName(name);
            if(metaData != null) {
                throw new IllegalArgumentException(name + " is a built-in Excel function. " +
                        "Use FunctoinEval.registerFunction(String name, Function func) instead.");
            } else {
                throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

     * @since 3.8 beta6
     */
   public static void registerFunction(String name, FreeRefFunction func){
        AnalysisToolPak inst = (AnalysisToolPak)instance;
        if(!isATPFunction(name)) {
            FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByName(name);
            if(metaData != null) {
                throw new IllegalArgumentException(name + " is a built-in Excel function. " +
                        "Use FunctoinEval.registerFunction(String name, Function func) instead.");
            } else {
                throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

   * @param name a {@link NamePtg} or {@link NameXPtg} or <code>null</code>
   * @return Ptg a null is returned if we're in an IF formula, it needs extreme manipulation and is handled in this function
   */
  private ParseNode getFunction(String name, Ptg namePtg, ParseNode[] args) {

    FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
    int numArgs = args.length;
    if(fm == null) {
      if (namePtg == null) {
        throw new IllegalStateException("NamePtg must be supplied for external functions");
      }
      // must be external function
      ParseNode[] allArgs = new ParseNode[numArgs+1];
      allArgs[0] = new ParseNode(namePtg);
      System.arraycopy(args, 0, allArgs, 1, numArgs);
      return new ParseNode(FuncVarPtg.create(name, numArgs+1), allArgs);
    }

    if (namePtg != null) {
      throw new IllegalStateException("NamePtg no applicable to internal functions");
    }
    boolean isVarArgs = !fm.hasFixedArgsLength();
    int funcIx = fm.getIndex();
    if (funcIx == FunctionMetadataRegistry.FUNCTION_INDEX_SUM && args.length == 1) {
      // Excel encodes the sum of a single argument as tAttrSum
      // POI does the same for consistency, but this is not critical
      return new ParseNode(AttrPtg.getSumSingle(), args);
      // The code below would encode tFuncVar(SUM) which seems to do no harm
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

    retval[363] = MinaMaxa.MINA;

    for (int i = 0; i < retval.length; i++) {
      Function f = retval[i];
      if (f == null) {
        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(i);
        if (fm == null) {
          continue;
        }
        retval[i] = new NotImplementedFunction(fm.getName());
      }
    }
    return retval;
  }
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

     * @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");
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

     */
    public static Collection<String> getSupportedFunctionNames(){
        Collection<String> lst = new TreeSet<String>();
        for(int i = 0; i < functions.length; i++){
            Function func = functions[i];
            FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByIndex(i);
            if(func != null && !(func instanceof NotImplementedFunction)){
                lst.add(metaData.getName());
            }
        }
        lst.add("INDIRECT"); // INDIRECT is a special case
        return Collections.unmodifiableCollection(lst);
    }
View Full Code Here

Examples of org.apache.poi.ss.formula.function.FunctionMetadata

    public static Collection<String> getNotSupportedFunctionNames(){
        Collection<String> lst = new TreeSet<String>();
        for(int i = 0; i < functions.length; i++){
            Function func = functions[i];
            if(func != null && (func instanceof NotImplementedFunction)){
                FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByIndex(i);
                lst.add(metaData.getName());
            }
        }
        lst.remove("INDIRECT"); // INDIRECT is a special case
        return Collections.unmodifiableCollection(lst);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.