⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractfunctionptg.java

📁 Office格式转换代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003, 2003 The Apache Software Foundation.  All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and *    "Apache POI" must not be used to endorse or promote products *    derived from this software without prior written permission. For *    written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    "Apache POI", nor may "Apache" appear in their name, without *    prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.hssf.record.formula;import org.apache.poi.util.BinaryTree;import org.apache.poi.hssf.model.Workbook;/** * This class provides the base functionality for Excel sheet functions  * There are two kinds of function Ptgs - tFunc and tFuncVar * Therefore, this class will have ONLY two subclasses * @author  Avik Sengupta * @author Andrew C. Oliver (acoliver at apache dot org) */public abstract class AbstractFunctionPtg extends OperationPtg {	//constant used allow a ptgAttr to be mapped properly for its functionPtg	public static final String ATTR_NAME = "specialflag";	        public static final short INDEX_EXTERNAL = 255;        private static BinaryTree map = produceHash();     protected static Object[][] functionData = produceFunctionData();    protected byte returnClass;    protected byte[] paramClass;        protected byte field_1_num_args;    protected short field_2_fnc_index;     public String toString() {        StringBuffer buffer = new StringBuffer();        buffer        .append("<FunctionPtg>").append("\n")        .append("   field_1_num_args=").append(field_1_num_args).append("\n")        .append("      name         =").append(lookupName(field_2_fnc_index)).append("\n")        .append("   field_2_fnc_index=").append(field_2_fnc_index).append("\n")        .append("</FunctionPtg>");        return buffer.toString();    }       public int getType() {        return -1;    }                  public short getFunctionIndex() {        return field_2_fnc_index;    }        public String getName() {        return lookupName(field_2_fnc_index);    }        public String toFormulaString(Workbook book) {        return getName();    }        public String toFormulaString(String[] operands) {        StringBuffer buf = new StringBuffer();                            if (field_2_fnc_index != 1) {              buf.append(getName());              buf.append('(');          }          if (operands.length >0) {              for (int i=0;i<operands.length;i++) {                  buf.append(operands[i]);                  buf.append(',');              }              buf.deleteCharAt(buf.length()-1);          }          if (field_2_fnc_index != 1) {            buf.append(")");          }        return buf.toString();    }        public abstract void writeBytes(byte[] array, int offset);    public abstract int getSize();                   protected String lookupName(short index) {        return ((String)map.get(new Integer(index)));     }        protected short lookupIndex(String name) {        Integer index = (Integer) map.getKeyForValue(name);        if (index != null) return index.shortValue();        return INDEX_EXTERNAL;    }        /**     * Produces the function table hashmap     */    private static BinaryTree produceHash() {        BinaryTree dmap = new BinaryTree();        dmap.put(new Integer(0),"COUNT");        dmap.put(new Integer(1),"specialflag");        dmap.put(new Integer(2),"ISNA");        dmap.put(new Integer(3),"ISERROR");        dmap.put(new Integer(4),"SUM");        dmap.put(new Integer(5),"AVERAGE");        dmap.put(new Integer(6),"MIN");        dmap.put(new Integer(7),"MAX");        dmap.put(new Integer(8),"ROW");        dmap.put(new Integer(9),"COLUMN");        dmap.put(new Integer(10),"NA");        dmap.put(new Integer(11),"NPV");        dmap.put(new Integer(12),"STDEV");        dmap.put(new Integer(13),"DOLLAR");        dmap.put(new Integer(14),"FIXED");        dmap.put(new Integer(15),"SIN");        dmap.put(new Integer(16),"COS");        dmap.put(new Integer(17),"TAN");        dmap.put(new Integer(18),"ATAN");        dmap.put(new Integer(19),"PI");        dmap.put(new Integer(20),"SQRT");        dmap.put(new Integer(21),"EXP");        dmap.put(new Integer(22),"LN");        dmap.put(new Integer(23),"LOG10");        dmap.put(new Integer(24),"ABS");        dmap.put(new Integer(25),"INT");        dmap.put(new Integer(26),"SIGN");        dmap.put(new Integer(27),"ROUND");        dmap.put(new Integer(28),"LOOKUP");        dmap.put(new Integer(29),"INDEX");        dmap.put(new Integer(30),"REPT");        dmap.put(new Integer(31),"MID");        dmap.put(new Integer(32),"LEN");        dmap.put(new Integer(33),"VALUE");        dmap.put(new Integer(34),"TRUE");        dmap.put(new Integer(35),"FALSE");        dmap.put(new Integer(36),"AND");        dmap.put(new Integer(37),"OR");        dmap.put(new Integer(38),"NOT");        dmap.put(new Integer(39),"MOD");        dmap.put(new Integer(40),"DCOUNT");        dmap.put(new Integer(41),"DSUM");        dmap.put(new Integer(42),"DAVERAGE");        dmap.put(new Integer(43),"DMIN");        dmap.put(new Integer(44),"DMAX");        dmap.put(new Integer(45),"DSTDEV");        dmap.put(new Integer(46),"VAR");        dmap.put(new Integer(47),"DVAR");        dmap.put(new Integer(48),"TEXT");        dmap.put(new Integer(49),"LINEST");        dmap.put(new Integer(50),"TREND");        dmap.put(new Integer(51),"LOGEST");        dmap.put(new Integer(52),"GROWTH");        dmap.put(new Integer(53),"GOTO");        dmap.put(new Integer(54),"HALT");        dmap.put(new Integer(56),"PV");        dmap.put(new Integer(57),"FV");        dmap.put(new Integer(58),"NPER");        dmap.put(new Integer(59),"PMT");        dmap.put(new Integer(60),"RATE");        dmap.put(new Integer(61),"MIRR");        dmap.put(new Integer(62),"IRR");        dmap.put(new Integer(63),"RAND");        dmap.put(new Integer(64),"MATCH");        dmap.put(new Integer(65),"DATE");        dmap.put(new Integer(66),"TIME");        dmap.put(new Integer(67),"DAY");        dmap.put(new Integer(68),"MONTH");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -