1    package org.apache.poi.hssf.record.formula;
2    import org.apache.poi.util.LittleEndian;
3    
4    /**
5     *
6     * @author Jason Height (jheight at chariot dot net dot au)
7     */
8    public class FuncPtg extends AbstractFunctionPtg{
9        
10       public final static byte sid  = 0x21;
11       private int numParams=0;
12   
13       private FuncPtg() {
14         //Required for clone methods
15       }
16   
17       /**Creates new function pointer from a byte array 
18        * usually called while reading an excel file. 
19        */
20       public FuncPtg(byte[] data, int offset) {
21           offset++;
22           //field_1_num_args = data[ offset + 0 ];
23           field_2_fnc_index  = LittleEndian.getShort(data,offset + 0 );
24           try {
25               numParams = ( (Integer)functionData[field_2_fnc_index][2]).intValue();
26           } catch (NullPointerException npe) {
27               numParams=0;
28           }   
29       }
30       
31        public void writeBytes(byte[] array, int offset) {
32           array[offset+0]= (byte) (sid + ptgClass);
33           //array[offset+1]=field_1_num_args;
34           LittleEndian.putShort(array,offset+1,field_2_fnc_index);
35       }
36       
37        public int getNumberOfOperands() {
38           return numParams;
39       }
40   
41       public Object clone() {
42         FuncPtg ptg = new FuncPtg();
43         ptg.field_1_num_args = field_1_num_args;
44         ptg.field_2_fnc_index = field_2_fnc_index;
45         return ptg;
46       }
47   }