}
return (String) stack.pop(); //TODO: catch stack underflow and throw parse exception.
}
-
+ /** Create a tree representation of the RPN token array
+ *used to run the class(RVA) change algo
+ */
private Node createTree() {
java.util.Stack stack = new java.util.Stack();
int numPtgs = tokens.size();
return buf.toString();
}
-}
+}
+ /** Private helper class, used to create a tree representation of the formula*/
class Node {
private Ptg value=null;
private Node[] children=new Node[0];
//constant used allow a ptgAttr to be mapped properly for its functionPtg
public static final String ATTR_NAME = "specialflag";
- private final static int SIZE = 4;
+
private static BinaryTree map = produceHash();
protected static Object[][] functionData = produceFunctionData();
}
public abstract void writeBytes(byte[] array, int offset);
+ public abstract int getSize();
- public int getSize() {
- return SIZE;
- }
+
- private String lookupName(short index) {
+ protected String lookupName(short index) {
return ((String)map.get(new Integer(index)));
}
import org.apache.poi.util.LittleEndian;
/**
- *
+ * @author aviks
* @author Jason Height (jheight at chariot dot net dot au)
* @author Danny Mui (dmui at apache dot org) (Leftover handling)
*/
public class FuncPtg extends AbstractFunctionPtg{
public final static byte sid = 0x21;
+ public final static int SIZE = 3;
private int numParams=0;
/**
* <p>
* If the leftovers are removed, a prompt "Warning: Data may have been lost occurs in Excel"
*/
- protected byte[] leftOvers = null;
-
+ //protected byte[] leftOvers = null;
+
private FuncPtg() {
//Required for clone methods
}
//field_1_num_args = data[ offset + 0 ];
field_2_fnc_index = LittleEndian.getShort(data,offset + 0 );
-
+ /*
if (data.length - offset > 2) { //save left overs if there are any
leftOvers = new byte[2];
System.arraycopy(data, offset+1, leftOvers, 0, leftOvers.length);
}
-
+ */
try {
numParams = ( (Integer)functionData[field_2_fnc_index][2]).intValue();
} catch (NullPointerException npe) {
array[offset+0]= (byte) (sid + ptgClass);
//array[offset+1]=field_1_num_args;
LittleEndian.putShort(array,offset+1,field_2_fnc_index);
- if (leftOvers != null) {
+ /**if (leftOvers != null) {
System.arraycopy(leftOvers, 0, array, offset+2, leftOvers.length);
- }
+ }**/
}
public int getNumberOfOperands() {
public Object clone() {
FuncPtg ptg = new FuncPtg();
- ptg.field_1_num_args = field_1_num_args;
+ //ptg.field_1_num_args = field_1_num_args;
ptg.field_2_fnc_index = field_2_fnc_index;
return ptg;
}
+
+ public int getSize() {
+ return SIZE;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer
+ .append("<FunctionPtg>").append("\n")
+ .append(" numArgs(internal)=").append(this.numParams).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();
+ }
}
\ No newline at end of file
public class FuncVarPtg extends AbstractFunctionPtg{
public final static byte sid = 0x22;
+ private final static int SIZE = 4;
private FuncVarPtg() {
//Required for clone methods
ptg.field_2_fnc_index = field_2_fnc_index;
return ptg;
}
+
+ public int getSize() {
+ return SIZE;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer
+ .append("<FunctionVarPtg>").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();
+ }
}