Examples of FunctionMetadata


Examples of org.apache.poi.hssf.record.formula.function.FunctionMetadata

    protected String lookupName(short index) {
        if(index == FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL) {
            return "#external#";
        }
        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(index);
        if(fm == null) {
            throw new RuntimeException("bad function index (" + index + ")");
        }
        return fm.getName();
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.function.FunctionMetadata

     * @param numArgs
     * @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, NamePtg 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(new FuncVarPtg(name, (byte)(numArgs+1)), allArgs);
        }

        if (namePtg != null) {
            throw new IllegalStateException("NamePtg no applicable to internal functions");
        }
        boolean isVarArgs = !fm.hasFixedArgsLength();
        int funcIx = fm.getIndex();
        validateNumArgs(args.length, fm);

        AbstractFunctionPtg retval;
        if(isVarArgs) {
            retval = new FuncVarPtg(name, (byte)numArgs);
View Full Code Here

Examples of org.apache.poi.hssf.record.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.hssf.record.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.hssf.record.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.hssf.record.formula.function.FunctionMetadata

     */
    private AbstractFunctionPtg getFunction(String name, int numArgs, List argumentPointers) {

        boolean isVarArgs;
        int funcIx;
        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
        if(fm == null) {
            // must be external function
            isVarArgs = true;
            funcIx = FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL;
        } else {
            isVarArgs = !fm.hasFixedArgsLength();
            funcIx = fm.getIndex();
        }
        AbstractFunctionPtg retval;
        if(isVarArgs) {
            retval = new FuncVarPtg(name, (byte)numArgs);
        } else {
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.function.FunctionMetadata

    protected String lookupName(short index) {
        if(index == FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL) {
            return "#external#";
        }
        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(index);
        if(fm == null) {
            throw new RuntimeException("bad function index (" + index + ")");
        }
        return fm.getName();
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.function.FunctionMetadata

     * Create a function ptg from a string tokenised by the parser
     */
    public FuncVarPtg(String pName, byte pNumOperands) {
        field_1_num_args = pNumOperands;
        field_2_fnc_index = lookupIndex(pName);
        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(field_2_fnc_index);
        if(fm == null) {
            // Happens only as a result of a call to FormulaParser.parse(), with a non-built-in function name
            returnClass = Ptg.CLASS_VALUE;
            paramClass = new byte[] {Ptg.CLASS_VALUE};
        } else {
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.function.FunctionMetadata

     */
    public FuncPtg(RecordInputStream in) {
        //field_1_num_args = data[ offset + 0 ];
        field_2_fnc_index  = in.readShort();

        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(field_2_fnc_index);
        if(fm == null) {
            throw new RuntimeException("Invalid built-in function index (" + field_2_fnc_index + ")");
        }
        numParams = fm.getMinParams();
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.function.FunctionMetadata

     * @param numArgs
     * @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(new FuncVarPtg(name, (byte)(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
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.