All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.poi.hssf.record.formula.AbstractFunctionPtg Maven / Gradle / Ivy

There is a newer version: 3.1-FINAL
Show newest version
/* ====================================================================
   Copyright 2003-2004   Apache Software Foundation

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
==================================================================== */

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("").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("");
        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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy