Package org.apache.poi.ss.formula.ptg

Examples of org.apache.poi.ss.formula.ptg.AbstractFunctionPtg


      return true;
    }

    // next 2 are special cases of OperationPtg
    if (tkn instanceof AbstractFunctionPtg) {
      AbstractFunctionPtg afp = (AbstractFunctionPtg) tkn;
      byte returnClass = afp.getDefaultOperandClass();
      return Ptg.CLASS_REF == returnClass;
    }
    if (tkn instanceof ValueOperatorPtg) {
      return false;
    }
View Full Code Here


      return new ParseNode(AttrPtg.getSumSingle(), args);
      // The code below would encode tFuncVar(SUM) which seems to do no harm
    }
    validateNumArgs(args.length, fm);

    AbstractFunctionPtg retval;
    if(isVarArgs) {
      retval = FuncVarPtg.create(name, numArgs);
    } else {
      retval = FuncPtg.create(funcIx);
    }
View Full Code Here

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("myFunc", tname.toFormulaString(book));

    AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
    assertTrue(tfunc.isExternalFunction());
  }
View Full Code Here

    if (result != null) {
      return  result.evaluate(args, ec.getRowIndex(), (short) ec.getColumnIndex());
    }

    if (ptg instanceof AbstractFunctionPtg) {
      AbstractFunctionPtg fptg = (AbstractFunctionPtg)ptg;
      int functionIndex = fptg.getFunctionIndex();
      switch (functionIndex) {
        case FunctionMetadataRegistry.FUNCTION_INDEX_INDIRECT:
          return Indirect.instance.evaluate(args, ec);
        case FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL:
          return UserDefinedFunction.instance.evaluate(args, ec);
View Full Code Here

    return false;
  }

  private static boolean isSimpleValueFunction(Ptg token) {
    if (token instanceof AbstractFunctionPtg) {
      AbstractFunctionPtg aptg = (AbstractFunctionPtg) token;
      if (aptg.getDefaultOperandClass() != Ptg.CLASS_VALUE) {
        return false;
      }
      int numberOfOperands = aptg.getNumberOfOperands();
      for (int i=numberOfOperands-1; i>=0; i--) {
        if (aptg.getParameterClass(i) != Ptg.CLASS_VALUE) {
          return false;
        }
      }
      return true;
    }
View Full Code Here

   
    // Check critical things in the Ptg array encoding.
    if(!(ptgF instanceof AbstractFunctionPtg)) {
        throw new RuntimeException("function token missing");
    }
    AbstractFunctionPtg func = (AbstractFunctionPtg) ptgF;
    if(func.getFunctionIndex() == 255) {
      throw new AssertionFailedError("Failed to recognise built-in function in formula '"
          + formula + "'");
    }
    assertEquals(expPtgArraySize, ptgs.length);
    assertEquals(funcIx, func.getFunctionIndex());
    Class expCls = isVarArgFunc ? FuncVarPtg.class : FuncPtg.class;
    assertEquals(expCls, ptgF.getClass());
   
    // check that parsed Ptg array converts back to formula text OK
    HSSFWorkbook book = new HSSFWorkbook();
View Full Code Here

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("myFunc", tname.toFormulaString(book));

    AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
    assertTrue(tfunc.isExternalFunction());
  }
View Full Code Here

    confirmFuncClass(ptgs, 14, "IRR", Ptg.CLASS_VALUE);
  }

  private void confirmFuncClass(Ptg[] ptgs, int i, String expectedFunctionName, byte operandClass) {
    confirmTokenClass(ptgs, i, operandClass);
    AbstractFunctionPtg afp = (AbstractFunctionPtg) ptgs[i];
    assertEquals(expectedFunctionName, afp.getName());
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.ptg.AbstractFunctionPtg

Copyright © 2018 www.massapicom. 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.