From 75dd68f99c4909492b8066b62669abe182b28eb3 Mon Sep 17 00:00:00 2001 From: "Andrew C. Oliver" Date: Sat, 20 Apr 2002 23:42:10 +0000 Subject: [PATCH] seperated out my experimental parsing stuff. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352455 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/record/formula/Ptg.java | 53 +++---------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/formula/Ptg.java b/src/java/org/apache/poi/hssf/record/formula/Ptg.java index dc437e9be8..5db1dbfe97 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ptg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ptg.java @@ -77,44 +77,10 @@ public abstract class Ptg { } - public static Ptg[] parse(String formula, int offset) { - List ptgs = new ArrayList(); - - while (offset < formula.length()) { - Ptg ptg = getNextToken(formula,offset); - offset += ptg.getStringLength(); - ptgs.add(ptg); - } - - Ptg[] retval = new Ptg[ptgs.size()]; - retval = (Ptg[])ptgs.toArray(retval); - return retval; - } - public static String ptgsToString(Ptg[] ptgs) { - StringBuffer res = new StringBuffer(); - for (int k =0; k < ptgs.length; k++) { - Ptg ptg = ptgs[k]; - res.append(ptg.toFormulaString()); - } - return res.toString(); - } - - public static Ptg getNextToken(String formula, int offset) { - //later use array of reflected methods like RecordFactory - Ptg retval = null; - - if (AddPtg.isNextStringToken(formula,offset)) { - retval = new AddPtg(formula,offset); - } else if (IntPtg.isNextStringToken(formula,offset)) { - retval = new IntPtg(formula,offset); - } else { - throw new RuntimeException("didn't parse "+formula+" at " +offset); - } - return retval; - } -/* private static List ptgsToList(Class [] ptgs) + /* + private static List ptgsToList(Class [] ptgs) { List result = new ArrayList(); Constructor constructor; @@ -143,7 +109,7 @@ public abstract class Ptg }*/ - /*public static Ptg createPtg(byte [] data, int offset) + public static Ptg createPtg(byte [] data, int offset) { byte id = data[ offset + 0 ]; Ptg retval = null; @@ -193,9 +159,9 @@ public abstract class Ptg retval = new ValueReferencePtg(data, offset); break; - case ParenthesisPtg.sid : - retval = new ParenthesisPtg(data, offset); - break; + // case ParenthesisPtg.sid : + // retval = new ParenthesisPtg(data, offset); + // break; case ValueVariableFunctionPtg.sid : retval = new ValueVariableFunctionPtg(data, offset); @@ -217,7 +183,7 @@ public abstract class Ptg + " (" + ( int ) id + ")"); } return retval; - }*/ + } public abstract int getSize(); @@ -249,10 +215,5 @@ public abstract class Ptg return 0; } - public static void main(String[] args) { - if (args != null && args[0] != null) { - System.out.println("Parsed Formula="+ ptgsToString(parse(args[0],0))); - } - } } -- 2.39.5