1 16 17 18 package org.apache.poi.hssf.record.formula; 19 import org.apache.poi.util.LittleEndian; 20 21 25 public class FuncVarPtg extends AbstractFunctionPtg{ 26 27 public final static byte sid = 0x22; 28 private final static int SIZE = 4; 29 30 private FuncVarPtg() { 31 } 33 34 37 public FuncVarPtg(byte[] data, int offset) { 38 offset++; 39 field_1_num_args = data[ offset + 0 ]; 40 field_2_fnc_index = LittleEndian.getShort(data,offset + 1 ); 41 } 42 43 46 public FuncVarPtg(String pName, byte pNumOperands) { 47 field_1_num_args = pNumOperands; 48 field_2_fnc_index = lookupIndex(pName); 49 try{ 50 returnClass = ( (Byte ) functionData[field_2_fnc_index][0]).byteValue(); 51 paramClass = (byte[]) functionData[field_2_fnc_index][1]; 52 } catch (NullPointerException npe ) { 53 returnClass = Ptg.CLASS_VALUE; 54 paramClass = new byte[] {Ptg.CLASS_VALUE}; 55 } 56 } 57 58 public void writeBytes(byte[] array, int offset) { 59 array[offset+0]=(byte) (sid + ptgClass); 60 array[offset+1]=field_1_num_args; 61 LittleEndian.putShort(array,offset+2,field_2_fnc_index); 62 } 63 64 public int getNumberOfOperands() { 65 return field_1_num_args; 66 } 67 68 public Object clone() { 69 FuncVarPtg ptg = new FuncVarPtg(); 70 ptg.field_1_num_args = field_1_num_args; 71 ptg.field_2_fnc_index = field_2_fnc_index; 72 ptg.setClass(ptgClass); 73 return ptg; 74 } 75 76 public int getSize() { 77 return SIZE; 78 } 79 80 public String toString() { 81 StringBuffer buffer = new StringBuffer (); 82 buffer 83 .append("<FunctionVarPtg>").append("\n") 84 .append(" field_1_num_args=").append(field_1_num_args).append("\n") 85 .append(" name =").append(lookupName(field_2_fnc_index)).append("\n") 86 .append(" field_2_fnc_index=").append(field_2_fnc_index).append("\n") 87 .append("</FunctionPtg>"); 88 return buffer.toString(); 89 } 90 91 92 } 93 | Popular Tags |