poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r664220 [1/3] - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/model/ java/org/apache/poi/hssf/record/ java/org/apache/poi/hssf/record/formula/ java/org/apache/poi/hssf/record/formula/eval/ java/org/apache/poi/hssf...
Date Sat, 07 Jun 2008 00:53:03 GMT
Author: josh
Date: Fri Jun  6 17:53:01 2008
New Revision: 664220

URL: http://svn.apache.org/viewvc?rev=664220&view=rev
Log:
Fix for bug 45091 - serialization of RefN~ tokens. Simplified Ptg class hierarchy

Added:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java   (with props)
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java
      - copied, changed from r664139, poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefPtgBase.java
      - copied, changed from r664139, poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
Removed:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaAPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaVPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefAPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNAPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefVPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java
    poi/trunk/src/java/org/apache/poi/hssf/record/FormulaRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/NotEqualPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/OperationPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/PercentPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RangePtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefErrorPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ScalarConstantPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/UnaryMinusPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/UnaryPlusPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/UnionPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/ValueOperatorPtg.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/Ref2DEval.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestUnaryPlusEval.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/EvalFactory.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Jun  6 17:53:01 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-final" date="2008-06-??">
+           <action dev="POI-DEVELOPERS" type="fix">45091 - Fixed serialization of RefN~ tokens.  Simplified Ptg class hierarchy</action>
            <action dev="POI-DEVELOPERS" type="fix">45133 - Fixed OBJ Record (5Dh) to pad the sub-record data to a 4-byte boundary</action>
            <action dev="POI-DEVELOPERS" type="fix">45145 - Fixed Sheet to always enforce RowRecordsAggregate before ValueRecordsAggregate</action>
            <action dev="POI-DEVELOPERS" type="fix">45123 - Fixed SharedFormulaRecord.convertSharedFormulas() to propagate token operand classes</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jun  6 17:53:01 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-final" date="2008-06-??">
+           <action dev="POI-DEVELOPERS" type="fix">45091 - Fixed serialization of RefN~ tokens.  Simplified Ptg class hierarchy</action>
            <action dev="POI-DEVELOPERS" type="fix">45133 - Fixed OBJ Record (5Dh) to pad the sub-record data to a 4-byte boundary</action>
            <action dev="POI-DEVELOPERS" type="fix">45145 - Fixed Sheet to always enforce RowRecordsAggregate before ValueRecordsAggregate</action>
            <action dev="POI-DEVELOPERS" type="fix">45123 - Fixed SharedFormulaRecord.convertSharedFormulas() to propagate token operand classes</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java Fri Jun  6 17:53:01 2008
@@ -274,7 +274,7 @@
         boolean cellRef = CELL_REFERENCE_PATTERN.matcher(name).matches();
 
         if (cellRef) {
-            return new ReferencePtg(name);
+            return new RefPtg(name);
         }
 
         for(int i = 0; i < book.getNumberOfNames(); i++) {
@@ -324,9 +324,9 @@
         FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
         int numArgs = args.length;
         if(fm == null) {
-        	if (namePtg == null) {
-        		throw new IllegalStateException("NamePtg must be supplied for external functions");
-        	}
+            if (namePtg == null) {
+                throw new IllegalStateException("NamePtg must be supplied for external functions");
+            }
             // must be external function
             ParseNode[] allArgs = new ParseNode[numArgs+1];
             allArgs[0] = new ParseNode(namePtg);
@@ -335,8 +335,8 @@
         }
 
         if (namePtg != null) {
-    		throw new IllegalStateException("NamePtg no applicable to internal functions");
-    	}
+            throw new IllegalStateException("NamePtg no applicable to internal functions");
+        }
         boolean isVarArgs = !fm.hasFixedArgsLength();
         int funcIx = fm.getIndex();
         validateNumArgs(args.length, fm);
@@ -392,7 +392,7 @@
             SkipWhite();
             if (isArgumentDelimiter(look)) {
                 if (missedPrevArg) {
-                	temp.add(new ParseNode(new MissingArgPtg()));
+                    temp.add(new ParseNode(MissingArgPtg.instance));
                     numArgs++;
                 }
                 if (look == ')') {
@@ -417,7 +417,7 @@
 
    /** Parse and Translate a Math Factor  */
     private ParseNode powerFactor() {
-    	ParseNode result = percentFactor();
+        ParseNode result = percentFactor();
         while(true) {
             SkipWhite();
             if(look != '^') {
@@ -425,19 +425,19 @@
             }
             Match('^');
             ParseNode other = percentFactor();
-            result = new ParseNode(new PowerPtg(), result, other);
+            result = new ParseNode(PowerPtg.instance, result, other);
         }
     }
 
     private ParseNode percentFactor() {
-    	ParseNode result = parseSimpleFactor();
+        ParseNode result = parseSimpleFactor();
         while(true) {
             SkipWhite();
             if(look != '%') {
                 return result;
             }
             Match('%');
-            result = new ParseNode(new PercentPtg(), result);
+            result = new ParseNode(PercentPtg.instance, result);
         }
     }
 
@@ -452,15 +452,15 @@
                 return new ParseNode(parseErrorLiteral());
             case '-':
                 Match('-');
-                return new ParseNode(new UnaryMinusPtg(), powerFactor());
+                return new ParseNode(UnaryMinusPtg.instance, powerFactor());
             case '+':
                 Match('+');
-                return new ParseNode(new UnaryPlusPtg(), powerFactor());
+                return new ParseNode(UnaryPlusPtg.instance, powerFactor());
             case '(':
                 Match('(');
                 ParseNode inside = comparisonExpression();
                 Match(')');
-                return new ParseNode(new ParenthesisPtg(), inside);
+                return new ParseNode(ParenthesisPtg.instance, inside);
             case '"':
                 return new ParseNode(parseStringLiteral());
         }
@@ -625,18 +625,18 @@
 
     /** Parse and Translate a Math Term */
     private ParseNode  Term() {
-    	ParseNode result = powerFactor();
+        ParseNode result = powerFactor();
         while(true) {
             SkipWhite();
             Ptg operator;
             switch(look) {
                 case '*':
                     Match('*');
-                    operator = new MultiplyPtg();
+                    operator = MultiplyPtg.instance;
                     break;
                 case '/':
                     Match('/');
-                    operator = new DividePtg();
+                    operator = DividePtg.instance;
                     break;
                 default:
                     return result; // finished with Term
@@ -647,7 +647,7 @@
     }
 
     private ParseNode comparisonExpression() {
-    	ParseNode result = concatExpression();
+        ParseNode result = concatExpression();
         while (true) {
             SkipWhite();
             switch(look) {
@@ -666,26 +666,26 @@
     private Ptg getComparisonToken() {
         if(look == '=') {
             Match(look);
-            return new EqualPtg();
+            return EqualPtg.instance;
         }
         boolean isGreater = look == '>';
         Match(look);
         if(isGreater) {
             if(look == '=') {
                 Match('=');
-                return new GreaterEqualPtg();
+                return GreaterEqualPtg.instance;
             }
-            return new GreaterThanPtg();
+            return GreaterThanPtg.instance;
         }
         switch(look) {
             case '=':
                 Match('=');
-                return new LessEqualPtg();
+                return LessEqualPtg.instance;
             case '>':
                 Match('>');
-                return new NotEqualPtg();
+                return NotEqualPtg.instance;
         }
-        return new LessThanPtg();
+        return LessThanPtg.instance;
     }
 
 
@@ -698,7 +698,7 @@
             }
             Match('&');
             ParseNode other = additiveExpression();
-            result = new ParseNode(new ConcatPtg(), result, other);
+            result = new ParseNode(ConcatPtg.instance, result, other);
         }
         return result;
     }
@@ -706,18 +706,18 @@
 
     /** Parse and Translate an Expression */
     private ParseNode additiveExpression() {
-    	ParseNode result = Term();
+        ParseNode result = Term();
         while (true) {
             SkipWhite();
             Ptg operator;
             switch(look) {
                 case '+':
                     Match('+');
-                    operator = new AddPtg();
+                    operator = AddPtg.instance;
                     break;
                 case '-':
                     Match('-');
-                    operator = new SubtractPtg();
+                    operator = SubtractPtg.instance;
                     break;
                 default:
                     return result; // finished with additive expression
@@ -771,9 +771,9 @@
     }
 
     public Ptg[] getRPNPtg(int formulaType) {
-    	OperandClassTransformer oct = new OperandClassTransformer(formulaType);
+        OperandClassTransformer oct = new OperandClassTransformer(formulaType);
         // RVA is for 'operand class': 'reference', 'value', 'array'
-    	oct.transformFormula(_rootNode);
+        oct.transformFormula(_rootNode);
         return ParseNode.toTokenArray(_rootNode);
     }
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/FormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/FormulaRecord.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/FormulaRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/FormulaRecord.java Fri Jun  6 17:53:01 2008
@@ -557,7 +557,7 @@
       if (field_8_parsed_expr != null)
         size = field_8_parsed_expr.size();
       for (int i=0; i< size; i++) {
-        Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone();        
+        Ptg ptg = ((Ptg)field_8_parsed_expr.get(i)).copy();        
         rec.field_8_parsed_expr.add(i, ptg);
       }
       rec.value_data = value_data;

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/NameRecord.java Fri Jun  6 17:53:01 2008
@@ -737,7 +737,7 @@
         	}
         	// And then a union if we had more than one area
         	if(refs.length > 1) {
-        		ptg = new UnionPtg();
+        		ptg = UnionPtg.instance;
                 field_13_name_definition.push(ptg);
 	            this.setDefinitionTextLength( (short)(getDefinitionLength() + ptg.getSize()) );
         	}

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java Fri Jun  6 17:53:01 2008
@@ -207,22 +207,10 @@
             }
             if (ptg instanceof RefNPtg) {
               RefNPtg refNPtg = (RefNPtg)ptg;
-              ptg = new ReferencePtg(fixupRelativeRow(formulaRow,refNPtg.getRow(),refNPtg.isRowRelative()),
+              ptg = new RefPtg(fixupRelativeRow(formulaRow,refNPtg.getRow(),refNPtg.isRowRelative()),
                                      fixupRelativeColumn(formulaColumn,refNPtg.getColumn(),refNPtg.isColRelative()),
                                      refNPtg.isRowRelative(),
                                      refNPtg.isColRelative());
-            } else if (ptg instanceof RefNVPtg) {
-              RefNVPtg refNVPtg = (RefNVPtg)ptg;
-              ptg = new RefVPtg(fixupRelativeRow(formulaRow,refNVPtg.getRow(),refNVPtg.isRowRelative()),
-                                fixupRelativeColumn(formulaColumn,refNVPtg.getColumn(),refNVPtg.isColRelative()),
-                                refNVPtg.isRowRelative(),
-                                refNVPtg.isColRelative());
-            } else if (ptg instanceof RefNAPtg) {
-              RefNAPtg refNAPtg = (RefNAPtg)ptg;
-              ptg = new RefAPtg( fixupRelativeRow(formulaRow,refNAPtg.getRow(),refNAPtg.isRowRelative()),
-                                 fixupRelativeColumn(formulaColumn,refNAPtg.getColumn(),refNAPtg.isColRelative()),
-                                 refNAPtg.isRowRelative(),
-                                 refNAPtg.isColRelative());
             } else if (ptg instanceof AreaNPtg) {
               AreaNPtg areaNPtg = (AreaNPtg)ptg;
               ptg = new AreaPtg(fixupRelativeRow(formulaRow,areaNPtg.getFirstRow(),areaNPtg.isFirstRowRelative()),
@@ -233,26 +221,6 @@
                                 areaNPtg.isLastRowRelative(),
                                 areaNPtg.isFirstColRelative(),
                                 areaNPtg.isLastColRelative());
-            } else if (ptg instanceof AreaNVPtg) {
-              AreaNVPtg areaNVPtg = (AreaNVPtg)ptg;
-              ptg = new AreaVPtg(fixupRelativeRow(formulaRow,areaNVPtg.getFirstRow(),areaNVPtg.isFirstRowRelative()),
-                                fixupRelativeRow(formulaRow,areaNVPtg.getLastRow(),areaNVPtg.isLastRowRelative()),
-                                fixupRelativeColumn(formulaColumn,areaNVPtg.getFirstColumn(),areaNVPtg.isFirstColRelative()),
-                                fixupRelativeColumn(formulaColumn,areaNVPtg.getLastColumn(),areaNVPtg.isLastColRelative()),
-                                areaNVPtg.isFirstRowRelative(),
-                                areaNVPtg.isLastRowRelative(),
-                                areaNVPtg.isFirstColRelative(),
-                                areaNVPtg.isLastColRelative());
-            } else if (ptg instanceof AreaNAPtg) {
-              AreaNAPtg areaNAPtg = (AreaNAPtg)ptg;
-              ptg = new AreaAPtg(fixupRelativeRow(formulaRow,areaNAPtg.getFirstRow(),areaNAPtg.isFirstRowRelative()),
-                                fixupRelativeRow(formulaRow,areaNAPtg.getLastRow(),areaNAPtg.isLastRowRelative()),
-                                fixupRelativeColumn(formulaColumn,areaNAPtg.getFirstColumn(),areaNAPtg.isFirstColRelative()),
-                                fixupRelativeColumn(formulaColumn,areaNAPtg.getLastColumn(),areaNAPtg.isLastColRelative()),
-                                areaNAPtg.isFirstRowRelative(),
-                                areaNAPtg.isLastRowRelative(),
-                                areaNAPtg.isFirstColRelative(),
-                                areaNAPtg.isLastColRelative());
             }
             if (!ptg.isBaseToken()) {
                 ptg.setClass(originalOperandClass);

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java Fri Jun  6 17:53:01 2008
@@ -56,12 +56,6 @@
         return sb.toString();
     }
 
-    public int getType() {
-        return -1;
-    }
-
-
-
     public short getFunctionIndex() {
         return field_2_fnc_index;
     }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AddPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AddPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AddPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AddPtg.java Fri Jun  6 17:53:01 2008
@@ -17,9 +17,6 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
-
 /**
  * Addition operator PTG the "+" binomial operator.  If you need more 
  * explanation than that then well...We really can't help you here.
@@ -27,49 +24,23 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  */
 public final class AddPtg extends ValueOperatorPtg {
-    public final static int  SIZE = 1;
     public final static byte sid  = 0x03;
     
     private final static String ADD = "+";
 
-    /** Creates new AddPtg */
-
-    public AddPtg()
-    {
-    }
-
-    public AddPtg(RecordInputStream in)
-    {
+    public static final ValueOperatorPtg instance = new AddPtg();
 
-        // doesn't need anything
+    private AddPtg() {
+    	// enforce singleton
     }
     
-   
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
-    }
-
-    public int getSize()
-    {
-        return SIZE;
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
-    
-    /** Implementation of method from Ptg */
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return "+";
-    }
        
    /** implementation of method from OperationsPtg*/  
     public String toFormulaString(String[] operands) {
@@ -80,9 +51,4 @@
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }
-           
-    public Object clone() {
-      return new AddPtg();
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java Fri Jun  6 17:53:01 2008
@@ -95,7 +95,7 @@
 
 	public void writeBytes( byte[] array, int offset )
 	{
-		array[0 + offset] = (byte) ( sid + ptgClass );
+		array[0 + offset] = (byte) ( sid + getPtgClass() );
 		LittleEndian.putShort( array, 1 + offset, getExternSheetIndex() );
 		LittleEndian.putShort( array, 3 + offset, (short)getFirstRow() );
 		LittleEndian.putShort( array, 5 + offset, (short)getLastRow() );
@@ -280,24 +280,10 @@
 		return retval.toString();
 	}
 
-	public byte getDefaultOperandClass()
-	{
+	public byte getDefaultOperandClass() {
 		return Ptg.CLASS_REF;
 	}
-
-	public Object clone()
-	{
-		Area3DPtg ptg = new Area3DPtg();
-		ptg.field_1_index_extern_sheet = field_1_index_extern_sheet;
-		ptg.field_2_first_row = field_2_first_row;
-		ptg.field_3_last_row = field_3_last_row;
-		ptg.field_4_first_column = field_4_first_column;
-		ptg.field_5_last_column = field_5_last_column;
-		ptg.setClass(ptgClass);
-		return ptg;
-	}
-
-
+	// TODO - one junit relies on this. remove
 	public boolean equals( Object o )
 	{
 		if ( this == o ) return true;
@@ -313,18 +299,4 @@
 
 		return true;
 	}
-
-	public int hashCode()
-	{
-		// TODO - hashCode seems to be unused
-		int result;
-		result = (int) field_1_index_extern_sheet;
-		result = 29 * result + (int) field_2_first_row;
-		result = 29 * result + (int) field_3_last_row;
-		result = 29 * result + (int) field_4_first_column;
-		result = 29 * result + (int) field_5_last_column;
-		return result;
-	}
-
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaErrPtg.java Fri Jun  6 17:53:01 2008
@@ -17,73 +17,40 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * AreaErr - handles deleted cell area references.
  *
  * @author Daniel Noll (daniel at nuix dot com dot au)
  */
-public class AreaErrPtg extends AreaPtg
-{
+public final class AreaErrPtg extends OperandPtg {
     public final static byte sid  = 0x2b;
 
-    private AreaErrPtg()
-    {
-        //Required for clone methods
-        super();
-    }
-    
-    public AreaErrPtg(RecordInputStream in)
-    {
-        super(in);
-    }
-
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("AreaErrPtg\n");
-        buffer.append("firstRow = " + getFirstRow()).append("\n");
-        buffer.append("lastRow  = " + getLastRow()).append("\n");
-        buffer.append("firstCol = " + getFirstColumn()).append("\n");
-        buffer.append("lastCol  = " + getLastColumn()).append("\n");
-        buffer.append("firstColRowRel= "
-                      + isFirstRowRelative()).append("\n");
-        buffer.append("lastColRowRel = "
-                      + isLastRowRelative()).append("\n");
-        buffer.append("firstColRel   = " + isFirstColRelative()).append("\n");
-        buffer.append("lastColRel    = " + isLastColRelative()).append("\n");
-        return buffer.toString();
+    public AreaErrPtg(RecordInputStream in) {
+    	// 8 bytes unused:
+        in.readInt();
+        in.readInt();
     }
 
     public void writeBytes(byte [] array, int offset) {
-        super.writeBytes(array, offset);
-        array[offset] = (byte) (sid + ptgClass);
+        array[offset] = (byte) (sid + getPtgClass());
+        LittleEndian.putInt(array, offset+1, 0);
+        LittleEndian.putInt(array, offset+5, 0);
     }
 
-    public String toFormulaString(HSSFWorkbook book)
-    {
+    public String toFormulaString(HSSFWorkbook book) {
         return "#REF!";
     }
-    
-    public Object clone()
-    {
-        AreaErrPtg ptg = new AreaErrPtg();
-        ptg.setFirstRow(getFirstRow());
-        ptg.setFirstColumn(getFirstColumn());
-        ptg.setLastRow(getLastRow());
-        ptg.setLastColumn(getLastColumn());
-        ptg.setFirstColRelative(isFirstColRelative());
-        ptg.setLastColRelative(isLastColRelative());
-        ptg.setFirstRowRelative(isFirstRowRelative());
-        ptg.setLastRowRelative(isLastRowRelative());
-        ptg.setClass(ptgClass);
-        return ptg;
-    }
+
+	public byte getDefaultOperandClass() {
+		return Ptg.CLASS_REF;
+	}
+
+	public int getSize() {
+		return 9;
+	}
 }
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java Fri Jun  6 17:53:01 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -16,49 +15,22 @@
    limitations under the License.
 ==================================================================== */
 
-/*
- * AreaPtg.java
- *
- * Created on November 17, 2001, 9:30 PM
- */
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.AreaReference;
-import org.apache.poi.hssf.util.CellReference;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
 /**
  * Specifies a rectangular area of cells A1:A4 for instance.
  * @author Jason Height (jheight at chariot dot net dot au)
  */
+public final class AreaNPtg extends AreaPtgBase {
+	public final static short sid = 0x2D;
 
-public final class AreaNPtg extends AreaPtg
-{
-  public final static short sid  = 0x2D;
-
-  protected AreaNPtg() {
-    //Required for clone methods
-  }
-
-  public AreaNPtg(RecordInputStream in)
-  {
-    super(in);
-  }
-
-  public String getAreaPtgName() {
-    return "AreaNPtg";
-  }
-
-  public String toFormulaString(HSSFWorkbook book)
-  {
-    throw notImplemented();
-  }
-
-  public Object clone() {
-    throw notImplemented();
-  }
+	public AreaNPtg(RecordInputStream in) {
+		super(in);
+	}
+
+	protected byte getSid() {
+		return sid;
+	}
 }

Added: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java?rev=664220&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java Fri Jun  6 17:53:01 2008
@@ -0,0 +1,41 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.hssf.record.RecordInputStream;
+
+/**
+ * Specifies a rectangular area of cells A1:A4 for instance.
+ * @author Jason Height (jheight at chariot dot net dot au)
+ */
+public final class AreaPtg extends AreaPtgBase {
+    public final static short sid  = 0x25;
+
+    public AreaPtg(int firstRow, int lastRow, int firstColumn, int lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
+      super(firstRow, lastRow, firstColumn, lastColumn, firstRowRelative, lastRowRelative, firstColRelative, lastColRelative);
+    }
+    public AreaPtg(RecordInputStream in) {
+      super(in);
+    }
+    public AreaPtg(String arearef) {
+		super(arearef);
+	}
+	protected byte getSid() {
+		return sid;
+	}
+}

Propchange: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java (from r664139, poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java?p2=poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java&p1=poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java&r1=664139&r2=664220&rev=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AreaPtgBase.java Fri Jun  6 17:53:01 2008
@@ -31,7 +31,7 @@
  * @author  andy
  * @author Jason Height (jheight at chariot dot net dot au)
  */
-public class AreaPtg extends OperandPtg implements AreaI {
+public abstract class AreaPtgBase extends OperandPtg implements AreaI {
     /**
      * TODO - (May-2008) fix subclasses of AreaPtg 'AreaN~' which are used in shared formulas.
      * see similar comment in ReferencePtg
@@ -55,11 +55,7 @@
     private final static BitField   colRelative = BitFieldFactory.getInstance(0x4000);
     private final static BitField   columnMask      = BitFieldFactory.getInstance(0x3FFF);
 
-    protected AreaPtg() {
-      //Required for clone methods
-    }
-   
-    public AreaPtg(String arearef) {
+    protected AreaPtgBase(String arearef) {
         AreaReference ar = new AreaReference(arearef);
         CellReference firstCell = ar.getFirstCell();
         CellReference lastCell = ar.getLastCell();
@@ -73,7 +69,7 @@
         setLastRowRelative(!lastCell.isRowAbsolute());        
     }
     
-    public AreaPtg(int firstRow, int lastRow, int firstColumn, int lastColumn,
+    protected AreaPtgBase(int firstRow, int lastRow, int firstColumn, int lastColumn,
             boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) {
         
         checkColumnBounds(firstColumn);
@@ -101,20 +97,15 @@
         }
     }
 
-    public AreaPtg(RecordInputStream in)
+    protected AreaPtgBase(RecordInputStream in)
     {
         field_1_first_row    = in.readUShort();
         field_2_last_row     = in.readUShort();
         field_3_first_column = in.readUShort();
         field_4_last_column  = in.readUShort();
-        //System.out.println(toString());
     }
-    
-    public String getAreaPtgName() {
-      return "AreaPtg";
-    }    
 
-    public String toString() {
+    public final String toString() {
         StringBuffer sb = new StringBuffer();
         sb.append(getClass().getName());
         sb.append(" [");
@@ -122,25 +113,25 @@
         sb.append("]");
         return sb.toString();
     }
+    protected abstract byte getSid();
 
-    public void writeBytes(byte [] array, int offset) {
-        array[offset] = (byte) (sid + ptgClass);
+    public final void writeBytes(byte [] array, int offset) {
+        array[offset] = (byte) (getSid() + getPtgClass());
         LittleEndian.putShort(array,offset+1,(short)field_1_first_row);
         LittleEndian.putShort(array,offset+3,(short)field_2_last_row);
         LittleEndian.putShort(array,offset+5,(short)field_3_first_column);
         LittleEndian.putShort(array,offset+7,(short)field_4_last_column);        
     }
 
-    public int getSize()
-    {
+    
+    public final int getSize() {
         return SIZE;
     }
 
     /**
      * @return the first row in the area
      */
-    public int getFirstRow()
-    {
+    public final int getFirstRow() {
         return field_1_first_row;
     }
 
@@ -148,7 +139,7 @@
      * sets the first row
      * @param rowIx number (0-based)
      */
-    public void setFirstRow(int rowIx) {
+    public final void setFirstRow(int rowIx) {
         checkRowBounds(rowIx);
         field_1_first_row = rowIx;
     }
@@ -156,15 +147,14 @@
     /**
      * @return last row in the range (x2 in x1,y1-x2,y2)
      */
-    public int getLastRow()
-    {
+    public final int getLastRow() {
         return field_2_last_row;
     }
 
     /**
      * @param rowIx last row number in the area 
      */
-    public void setLastRow(int rowIx) {
+    public final void setLastRow(int rowIx) {
         checkRowBounds(rowIx);
         field_2_last_row = rowIx;
     }
@@ -172,24 +162,21 @@
     /**
      * @return the first column number in the area.
      */
-    public int getFirstColumn()
-    {
+    public final int getFirstColumn() {
         return columnMask.getValue(field_3_first_column);
     }
 
     /**
      * @return the first column number + the options bit settings unstripped
      */
-    public short getFirstColumnRaw()
-    {
+    public final short getFirstColumnRaw() {
         return (short) field_3_first_column; // TODO
     }
 
     /**
      * @return whether or not the first row is a relative reference or not.
      */
-    public boolean isFirstRowRelative()
-    {
+    public final boolean isFirstRowRelative() {
         return rowRelative.isSet(field_3_first_column);
     }
     
@@ -197,62 +184,57 @@
      * sets the first row to relative or not
      * @param rel is relative or not.
      */
-    public void setFirstRowRelative(boolean rel) {
+    public final void setFirstRowRelative(boolean rel) {
         field_3_first_column=rowRelative.setBoolean(field_3_first_column,rel);
     }
 
     /**
      * @return isrelative first column to relative or not
      */
-    public boolean isFirstColRelative()
-    {
+    public final boolean isFirstColRelative() {
         return colRelative.isSet(field_3_first_column);
     }
     
     /**
      * set whether the first column is relative 
      */
-    public void setFirstColRelative(boolean rel) {
+    public final void setFirstColRelative(boolean rel) {
         field_3_first_column=colRelative.setBoolean(field_3_first_column,rel);
     }
 
     /**
      * set the first column in the area
      */
-    public void setFirstColumn(int colIx) {
+    public final void setFirstColumn(int colIx) {
         checkColumnBounds(colIx);
     	field_3_first_column=columnMask.setValue(field_3_first_column, colIx);
     }
 
     /**
-     * set the first column irespective of the bitmasks
+     * set the first column irrespective of the bitmasks
      */
-    public void setFirstColumnRaw(int column)
-    {
+    public final void setFirstColumnRaw(int column) {
         field_3_first_column = column;
     }
 
     /**
      * @return lastcolumn in the area
      */
-    public int getLastColumn()
-    {
+    public final int getLastColumn() {
         return columnMask.getValue(field_4_last_column);
     }
 
     /**
      * @return last column and bitmask (the raw field)
      */
-    public short getLastColumnRaw()
-    {
+    public final short getLastColumnRaw() {
         return (short) field_4_last_column;
     }
 
     /**
      * @return last row relative or not
      */
-    public boolean isLastRowRelative()
-    {
+    public final boolean isLastRowRelative() {
         return rowRelative.isSet(field_4_last_column);
     }
     
@@ -261,30 +243,28 @@
      * @param rel <code>true</code> if the last row relative, else
      * <code>false</code>
      */
-    public void setLastRowRelative(boolean rel) {
+    public final void setLastRowRelative(boolean rel) {
         field_4_last_column=rowRelative.setBoolean(field_4_last_column,rel);
     }
 
     /**
      * @return lastcol relative or not
      */
-    public boolean isLastColRelative()
-    {
+    public final boolean isLastColRelative() {
         return colRelative.isSet(field_4_last_column);
     }
     
     /**
      * set whether the last column should be relative or not
      */
-    public void setLastColRelative(boolean rel) {
+    public final void setLastColRelative(boolean rel) {
         field_4_last_column=colRelative.setBoolean(field_4_last_column,rel);
     }
     
-
     /**
      * set the last column in the area
      */
-    public void setLastColumn(int colIx) {
+    public final void setLastColumn(int colIx) {
         checkColumnBounds(colIx);
     	field_4_last_column=columnMask.setValue(field_4_last_column, colIx);
     }
@@ -292,8 +272,7 @@
     /**
      * set the last column irrespective of the bitmasks
      */
-    public void setLastColumnRaw(short column)
-    {
+    public final void setLastColumnRaw(short column) {
         field_4_last_column = column;
     }
     
@@ -304,15 +283,4 @@
     public byte getDefaultOperandClass() {
         return Ptg.CLASS_REF;
     }
-    
-    public Object clone() {
-      AreaPtg ptg = new AreaPtg();
-      ptg.field_1_first_row = field_1_first_row;
-      ptg.field_2_last_row = field_2_last_row;
-      ptg.field_3_first_column = field_3_first_column;
-      ptg.field_4_last_column = field_4_last_column;
-      ptg.setClass(ptgClass);
-      return ptg;
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java Fri Jun  6 17:53:01 2008
@@ -35,29 +35,28 @@
  *  
  * @author Jason Height (jheight at chariot dot net dot au)
  */
-public class ArrayPtg extends Ptg {
+public final class ArrayPtg extends Ptg {
 	public static final byte sid  = 0x20;
 
 	private static final int RESERVED_FIELD_LEN = 7;
 	// TODO - fix up field visibility and subclasses
-	protected byte[] field_1_reserved;
+	private byte[] field_1_reserved;
+	
 	// data from these fields comes after the Ptg data of all tokens in current formula
-	protected short  token_1_columns;
-	protected short token_2_rows;
-	protected Object[] token_3_arrayValues;
-
-	protected ArrayPtg() {
-	  //Required for clone methods
-	}
+	private short  token_1_columns;
+	private short token_2_rows;
+	private Object[] token_3_arrayValues;
 
-	public ArrayPtg(RecordInputStream in)
-	{
+	public ArrayPtg(RecordInputStream in) {
 		field_1_reserved = new byte[RESERVED_FIELD_LEN];
 		// TODO - add readFully method to RecordInputStream
 		for(int i=0; i< RESERVED_FIELD_LEN; i++) {
 			field_1_reserved[i] = in.readByte();
 		}
 	}
+	public Object[] getTokenArrayValues() {
+		return (Object[]) token_3_arrayValues.clone();
+	}
 	
 	public boolean isBaseToken() {
 		return false;
@@ -117,7 +116,7 @@
 
 	public void writeBytes(byte[] data, int offset) {
 		
-		LittleEndian.putByte(data, offset + 0, sid + ptgClass);
+		LittleEndian.putByte(data, offset + 0, sid + getPtgClass());
 		System.arraycopy(field_1_reserved, 0, data, offset+1, RESERVED_FIELD_LEN);
 	}
 
@@ -190,13 +189,9 @@
 	}
 	
 	public Object clone() {
-	  ArrayPtg ptg = new ArrayPtg();
+	  ArrayPtg ptg = (ArrayPtg) super.clone();
 	  ptg.field_1_reserved = (byte[]) field_1_reserved.clone();
-	  
-	  ptg.token_1_columns = token_1_columns;
-	  ptg.token_2_rows = token_2_rows;
 	  ptg.token_3_arrayValues = (Object[]) token_3_arrayValues.clone();
-	  ptg.setClass(ptgClass);
 	  return ptg;
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/BoolPtg.java Fri Jun  6 17:53:01 2008
@@ -30,11 +30,7 @@
 public final class BoolPtg extends ScalarConstantPtg {
     public final static int  SIZE = 2;
     public final static byte sid  = 0x1d;
-    private boolean          field_1_value;
-
-    private BoolPtg() {
-      //Required for clone methods
-    }
+    private final boolean field_1_value;
 
     public BoolPtg(RecordInputStream in)
     {
@@ -46,11 +42,6 @@
         field_1_value = (formulaToken.equals("TRUE"));
     }
 
-    public void setValue(boolean value)
-    {
-        field_1_value = value;
-    }
-
     public boolean getValue()
     {
         return field_1_value;
@@ -71,10 +62,4 @@
     {
         return field_1_value ? "TRUE" : "FALSE";
     }
-
-    public Object clone() {
-        BoolPtg ptg = new BoolPtg();
-        ptg.field_1_value = field_1_value;
-        return ptg;
-    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java Fri Jun  6 17:53:01 2008
@@ -17,54 +17,29 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
-
 /**
  *
  * @author  andy
  * @author Jason Height (jheight at chariot dot net dot au)
  */
 public final class ConcatPtg extends ValueOperatorPtg {
-    public final static int  SIZE = 1;
     public final static byte sid  = 0x08;
     
     private final static String CONCAT = "&";
     
-    public ConcatPtg(RecordInputStream in)
-    {
-    	// No contents
-    }
-    
-    public ConcatPtg() {
-        
-    }
-
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
-    }
+    public static final ValueOperatorPtg instance = new ConcatPtg();
 
-    public int getSize()
-    {
-        return SIZE;
+    private ConcatPtg() {
+    	// enforce singleton
     }
-
-    public int getType()
-    {
-        return TYPE_BINARY;
+    
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
-
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return CONCAT;
-    }    
-
        
     public String toFormulaString(String[] operands) {
         StringBuffer buffer = new StringBuffer();
@@ -74,9 +49,4 @@
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }
-           
-    public Object clone() {
-      return new ConcatPtg();
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/DividePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/DividePtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/DividePtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/DividePtg.java Fri Jun  6 17:53:01 2008
@@ -17,66 +17,34 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
-
 /**
  * This PTG implements the standard binomial divide "/"
  * @author  Andrew C. Oliver acoliver at apache dot org
  * @author Jason Height (jheight at chariot dot net dot au)
  */
 public final class DividePtg extends ValueOperatorPtg {
-    public final static int  SIZE = 1;
     public final static byte sid  = 0x06;
 
-    /** Creates new AddPtg */
-
-    public DividePtg()
-    {
-    }
-
-    public DividePtg(RecordInputStream in)
-    {
+    public static final ValueOperatorPtg instance = new DividePtg();
 
-        // doesn't need anything
+    private DividePtg() {
+    	// enforce singleton
     }
-
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
-    }
-
-    public int getSize()
-    {
-        return SIZE;
+    
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
 
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return "/";
-    }
-
      public String toFormulaString(String[] operands) {
         StringBuffer buffer = new StringBuffer();
 
         buffer.append(operands[ 0 ]);
-        buffer.append(toFormulaString((HSSFWorkbook)null));
+        buffer.append("/");
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }      
-
-    public Object clone() {
-      DividePtg ptg = new DividePtg();
-      return ptg;
-    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java Fri Jun  6 17:53:01 2008
@@ -17,67 +17,34 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
-
 /**
  *
  * @author  andy
  */
 public final class EqualPtg extends ValueOperatorPtg {
-    public final static int  SIZE = 1;
     public final static byte sid  = 0x0b;
 
-    /** Creates new AddPtg */
-
-   public EqualPtg()
-    {
-    }
-
-    public EqualPtg(RecordInputStream in)
-    {
+    public static final ValueOperatorPtg instance = new EqualPtg();
 
-        // doesn't need anything
+    private EqualPtg() {
+    	// enforce singleton
     }
-
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
-    }
-
-    public int getSize()
-    {
-        return SIZE;
+    
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
-
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return "=";
-    }
  
     public String toFormulaString(String[] operands) {
          StringBuffer buffer = new StringBuffer();
 
         
         buffer.append(operands[ 0 ]);
-        buffer.append(toFormulaString((HSSFWorkbook)null));
+        buffer.append("=");
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }       
-
-    public Object clone() {
-      return new EqualPtg();
-    }
-
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/ErrPtg.java Fri Jun  6 17:53:01 2008
@@ -47,7 +47,7 @@
     
     public static final short sid  = 0x1c;
     private static final int  SIZE = 2;
-    private int              field_1_error_code;
+    private final int field_1_error_code;
 
     /** Creates new ErrPtg */
 
@@ -64,7 +64,7 @@
 
     public void writeBytes(byte [] array, int offset)
     {
-        array[offset] = (byte) (sid + ptgClass);
+        array[offset] = (byte) (sid + getPtgClass());
         array[offset + 1] = (byte)field_1_error_code;
     }
 
@@ -76,10 +76,6 @@
         return SIZE;
     }
 
-    public Object clone() {
-        return new ErrPtg(field_1_error_code);
-    }
-
     public int getErrorCode() {
         return field_1_error_code;
     }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java Fri Jun  6 17:53:01 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -30,20 +29,11 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  * @author dmui (save existing implementation)
  */
-
 public final class ExpPtg extends ControlPtg {
     private final static int  SIZE = 5;
     public final static short sid  = 0x1;
-    private short            field_1_first_row;
-    private short            field_2_first_col;
-
-    /** Creates new ExpPtg */
-
-    public ExpPtg()
-    {
-    }
-
-    /** Creates new ExpPtg */
+    private final short            field_1_first_row;
+    private final short            field_2_first_col;
 
     public ExpPtg(RecordInputStream in)
     {
@@ -83,12 +73,4 @@
         buffer.append("col = ").append(getColumn()).append("\n");
         return buffer.toString();
     }    
-    
-    public Object clone() {
-	ExpPtg result = new ExpPtg();
-        result.field_1_first_row = field_1_first_row;
-        result.field_2_first_col = field_2_first_col;        
-        return result;
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java Fri Jun  6 17:53:01 2008
@@ -56,7 +56,7 @@
     }
 
     public void writeBytes(byte[] array, int offset) {
-        array[offset+0]= (byte) (sid + ptgClass);
+        array[offset+0]= (byte) (sid + getPtgClass());
         LittleEndian.putShort(array,offset+1,field_2_fnc_index);
     }
 
@@ -64,12 +64,6 @@
         return numParams;
     }
 
-    public Object clone() {
-        FuncPtg ptg = new FuncPtg(field_2_fnc_index);
-        ptg.setClass(ptgClass);
-        return ptg;
-    }
-
     public int getSize() {
         return SIZE;
     }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java Fri Jun  6 17:53:01 2008
@@ -30,11 +30,7 @@
     public final static byte sid  = 0x22;
     private final static int  SIZE = 4;
 
-    private FuncVarPtg() {
-      //Required for clone methods
-    }
-
- /**Creates new function pointer from a byte array
+    /**Creates new function pointer from a byte array
      * usually called while reading an excel file.
      */
     public FuncVarPtg(RecordInputStream in) {
@@ -69,7 +65,7 @@
     }
 
      public void writeBytes(byte[] array, int offset) {
-        array[offset+0]=(byte) (sid + ptgClass);
+        array[offset+0]=(byte) (sid + getPtgClass());
         array[offset+1]=field_1_num_args;
         LittleEndian.putShort(array,offset+2,field_2_fnc_index);
     }
@@ -78,14 +74,6 @@
         return field_1_num_args;
     }
 
-    public Object clone() {
-      FuncVarPtg ptg = new FuncVarPtg();
-      ptg.field_1_num_args = field_1_num_args;
-      ptg.field_2_fnc_index = field_2_fnc_index;
-      ptg.setClass(ptgClass);
-      return ptg;
-    }
-
     public int getSize() {
         return SIZE;
     }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterEqualPtg.java Fri Jun  6 17:53:01 2008
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
 
 /**
  * PTG class to implement greater or equal to
@@ -29,56 +27,28 @@
     public final static int  SIZE = 1;
     public final static byte sid  = 0x0c;
 
-    /** Creates new GreaterEqualPtg */
+    public static final ValueOperatorPtg instance = new GreaterEqualPtg();
 
-   public GreaterEqualPtg()
-    {
+    private GreaterEqualPtg() {
+    	// enforce singleton
     }
-
-    public GreaterEqualPtg(RecordInputStream in)
-    {
-
-        // doesn't need anything
-    }
-
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
+    
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getSize()
-    {
-        return SIZE;
-    }
-
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
 
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return ">=";
-    }
-
     public String toFormulaString(String[] operands) {
          StringBuffer buffer = new StringBuffer();
 
         buffer.append(operands[ 0 ]);
 
-        buffer.append(toFormulaString((HSSFWorkbook)null));
+        buffer.append(">=");
         buffer.append(operands[ 1 ]);
 
         return buffer.toString();
     }
-
-    public Object clone() {
-      return new GreaterEqualPtg();
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/GreaterThanPtg.java Fri Jun  6 17:53:01 2008
@@ -17,82 +17,34 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
 /**
  * Greater than operator PTG ">"
  * @author  Cameron Riley (criley at ekmail.com)
  */
 public final class GreaterThanPtg extends ValueOperatorPtg {
-    public final static int  SIZE = 1;
     public final static byte sid  = 0x0D;    
     private final static String GREATERTHAN = ">";
 
-    /** 
-     * Constructor. Creates new GreaterThanPtg 
-     */
-    public GreaterThanPtg()
-    {
-        //deliberately empty
-    }
+    public static final ValueOperatorPtg instance = new GreaterThanPtg();
 
-    /**
-     * Constructor. Create a new GreaterThanPtg.
-     * @param in the RecordInputstream to read the record from
-     */
-    public GreaterThanPtg(RecordInputStream in)
-    {
-        //deliberately empty
+    private GreaterThanPtg() {
+    	// enforce singleton
     }
     
-    /**
-     * Write the sid to an array
-     * @param array the array of bytes to write the sid to
-     * @param offset the offset to add the sid to
-     */
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
-    }
-
-    /**
-     * Get the size of the sid
-     * @return int the size of the sid in terms of byte additions to an array
-     */
-    public int getSize()
-    {
-        return SIZE;
-    }
-
-    /**
-     * Get the type of PTG for Greater Than
-     * @return int the identifier for the type
-     */
-    public int getType()
-    {
-        return TYPE_BINARY;
+    protected byte getSid() {
+    	return sid;
     }
 
     /**
      * Get the number of operands for the Less than operator
      * @return int the number of operands
      */
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
     
     /** 
-     * Implementation of method from Ptg 
-     * @param book the Sheet References
-     */
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return this.GREATERTHAN;
-    }
-      
-    /** 
      * Implementation of method from OperationsPtg
      * @param operands a String array of operands
      * @return String the Formula as a String
@@ -102,17 +54,8 @@
         StringBuffer buffer = new StringBuffer();
 
         buffer.append(operands[ 0 ]);
-        buffer.append(this.GREATERTHAN);
+        buffer.append(GREATERTHAN);
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }
-    
-    /**
-     * Implementation of clone method from Object
-     * @return Object a clone of this class as an Object
-     */ 
-    public Object clone() 
-    {
-        return new GreaterThanPtg();
-    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntPtg.java Fri Jun  6 17:53:01 2008
@@ -43,13 +43,12 @@
 
     public final static int  SIZE = 3;
     public final static byte sid  = 0x1e;
-    private int            field_1_value;
+    private final int field_1_value;
   
     public IntPtg(RecordInputStream in) {
         this(in.readUShort());
     }
 
-
     public IntPtg(int value) {
         if(!isInRange(value)) {
             throw new IllegalArgumentException("value is out of range: " + value);
@@ -61,7 +60,6 @@
         return field_1_value;
     }
 
-
     public void writeBytes(byte [] array, int offset)
     {
         array[ offset + 0 ] = sid;
@@ -76,9 +74,6 @@
         return String.valueOf(getValue());
     }
 
-    public Object clone() {
-     return new IntPtg(field_1_value);
-    }
     public String toString() {
         StringBuffer sb = new StringBuffer(64);
         sb.append(getClass().getName()).append(" [");

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/IntersectionPtg.java Fri Jun  6 17:53:01 2008
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula;
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
 
 /**
  * @author Daniel Noll (daniel at nuix dot com dot au)
@@ -26,14 +25,10 @@
 public final class IntersectionPtg extends OperationPtg {
     public final static byte sid  = 0x0f;
 
+    public static final OperationPtg instance = new IntersectionPtg();
 
-    public IntersectionPtg()
-    {
-    }
-
-    public IntersectionPtg(RecordInputStream in)
-    {
-        // doesn't need anything
+    private IntersectionPtg() {
+    	// enforce singleton
     }
 
     public final boolean isBaseToken() {
@@ -50,16 +45,6 @@
         array[ offset + 0 ] = sid;
     }
 
-    public Object clone()
-    {
-        return new IntersectionPtg();
-    }
-
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
     /** Implementation of method from Ptg */
     public String toFormulaString(HSSFWorkbook book)
     {

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessEqualPtg.java Fri Jun  6 17:53:01 2008
@@ -19,8 +19,6 @@
 package org.apache.poi.hssf.record.formula;
 
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
 
 
 /**
@@ -29,58 +27,27 @@
  * @author fred at stsci dot edu
  */
 public final class LessEqualPtg extends ValueOperatorPtg {
-    public final static int SIZE = 1;
     public final static byte sid = 0x0a;
 
-    /**
-     * Creates new LessEqualPtg
-     */
-    public LessEqualPtg()
-    {
+    public static final ValueOperatorPtg instance = new LessEqualPtg();
 
+    private LessEqualPtg() {
+    	// enforce singleton
     }
-
-    public LessEqualPtg( RecordInputStream in )
-    {
-        // doesn't need anything
-    }
-
-    public void writeBytes( byte[] array, int offset )
-    {
-        array[offset + 0] = sid;
+    
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getSize()
-    {
-        return SIZE;
-    }
-
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
 
-    public String toFormulaString( HSSFWorkbook book )
-    {
-        return "<=";
-    }
-
-    public String toFormulaString( String[] operands )
-    {
+    public String toFormulaString(String[] operands) {
         StringBuffer buffer = new StringBuffer();
         buffer.append( operands[0] );
-        buffer.append( toFormulaString( (HSSFWorkbook) null ) );
+        buffer.append("<=");
         buffer.append( operands[1] );
         return buffer.toString();
     }
-
-    public Object clone()
-    {
-        return new LessEqualPtg();
-    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/LessThanPtg.java Fri Jun  6 17:53:01 2008
@@ -17,9 +17,6 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
-
 /**
  * Less than operator PTG "<". The SID is taken from the 
  * Openoffice.orgs Documentation of the Excel File Format,
@@ -27,79 +24,31 @@
  * @author Cameron Riley (criley at ekmail.com)
  */
 public final class LessThanPtg extends ValueOperatorPtg {
-    /** the size of the Ptg  */
-    public final static int SIZE = 1;
-
     /** the sid for the less than operator as hex */
     public final static byte sid  = 0x09;    
 
     /** identifier for LESS THAN char */
     private final static String LESSTHAN = "<";
 
-    /** 
-     * Constructor. Creates new LessThanPtg 
-     */
-    public LessThanPtg()
-    {
-        //deliberately empty
-    }
+    public static final ValueOperatorPtg instance = new LessThanPtg();
 
-    /**
-     * Constructor. Create a new LessThanPtg.
-     * @param in the RecordInputstream to read the record from
-     */
-    public LessThanPtg(RecordInputStream in)
-    {
-        //deliberately empty
+    private LessThanPtg() {
+    	// enforce singleton
     }
     
-    /**
-     * Write the sid to an array
-     * @param array the array of bytes to write the sid to
-     * @param offset the offset to add the sid to
-     */
-    public void writeBytes(byte[] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
-    }
-
-    /**
-     * Get the size of the sid
-     * @return int the size of the sid in terms of byte additions to an array
-     */
-    public int getSize()
-    {
-        return SIZE;
-    }
-
-    /**
-     * Get the type of PTG for Less Than
-     * @return int the identifier for the type
-     */
-    public int getType()
-    {
-        return TYPE_BINARY;
+    protected byte getSid() {
+    	return sid;
     }
 
     /**
      * Get the number of operands for the Less than operator
      * @return int the number of operands
      */
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
     
-    /** 
-     * Implementation of method from Ptg 
-     * @param book the Sheet References
-     */
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return this.LESSTHAN;
-    }
-       
-    /** 
+     /** 
      * Implementation of method from OperationsPtg
      * @param operands a String array of operands
      * @return String the Formula as a String
@@ -108,18 +57,8 @@
     {
         StringBuffer buffer = new StringBuffer();
         buffer.append(operands[ 0 ]);
-        buffer.append(this.LESSTHAN);
+        buffer.append(LESSTHAN);
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }
-    
-    /**
-     * Implementation of clone method from Object
-     * @return Object a clone of this class as an Object
-     */       
-    public Object clone() 
-    {
-        return new LessThanPtg();
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemAreaPtg.java Fri Jun  6 17:53:01 2008
@@ -64,7 +64,7 @@
 
     public void writeBytes(byte [] array, int offset)
     {
-        array[offset] = (byte) (sid + ptgClass);
+        array[offset] = (byte) (sid + getPtgClass());
         LittleEndian.putInt(array, offset + 1, field_1_reserved);
         LittleEndian.putShort(array, offset + 5, field_2_subex_len);
     }
@@ -79,12 +79,7 @@
         return ""; // TODO: Not sure how to format this. -- DN
     }
 
-    public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
-
-    public Object clone() {
-      MemAreaPtg ptg = new MemAreaPtg();
-      ptg.field_1_reserved = field_1_reserved;
-      ptg.field_2_subex_len = field_2_subex_len;
-      return ptg;
+    public byte getDefaultOperandClass() {
+    	return Ptg.CLASS_VALUE;
     }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java Fri Jun  6 17:53:01 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -16,17 +15,10 @@
    limitations under the License.
 ==================================================================== */
 
-
-/*
- * MemErrPtg.java
- *
- * Created on November 21, 2001, 8:46 AM
- */
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
 /**
  *
@@ -35,9 +27,7 @@
  * @author Daniel Noll (daniel at nuix dot com dot au)
  */
 
-public class MemErrPtg
-    extends MemAreaPtg
-{
+public final class MemErrPtg extends MemAreaPtg {
     public final static short sid  = 0x27;
 
     /** Creates new MemErrPtg */
@@ -46,26 +36,17 @@
     {
     }
 
-    public MemErrPtg(RecordInputStream in)
-    {
+    public MemErrPtg(RecordInputStream in) {
         super(in);
     }
 
-    public void writeBytes(byte [] array, int offset)
-    {
+    public void writeBytes(byte [] array, int offset) {
         super.writeBytes(array, offset);
-        array[offset] = (byte) (sid + ptgClass);
+        array[offset] = (byte) (sid + getPtgClass());
     }
 
     public String toFormulaString(HSSFWorkbook book)
     {
         return "ERR#";
     }
-
-    public Object clone() {
-      MemErrPtg ptg = new MemErrPtg();
-      ptg.setReserved(getReserved());
-      ptg.setSubexpressionLength(getSubexpressionLength());
-      return ptg;
-    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/MemFuncPtg.java Fri Jun  6 17:53:01 2008
@@ -15,12 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
-/*
- * Ptg.java
- *
- * Created on October 28, 2001, 6:30 PM
- */
 package org.apache.poi.hssf.record.formula;
 
 import org.apache.poi.util.LittleEndian;
@@ -30,25 +24,23 @@
 /**
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class MemFuncPtg extends OperandPtg {
+public final class MemFuncPtg extends OperandPtg {
 
     public final static byte sid = 0x29;
-    private short field_1_len_ref_subexpression = 0;
-
-    public MemFuncPtg()
-    {
-        //Required for clone methods
-    }
+    private final int field_1_len_ref_subexpression;
 
     /**Creates new function pointer from a byte array
      * usually called while reading an excel file.
      */
-    public MemFuncPtg( RecordInputStream in )
-    {
-        field_1_len_ref_subexpression = in.readShort();
+    public MemFuncPtg(RecordInputStream in) {
+        this(in.readUShort());
     }
 
-    public int getSize()
+    public MemFuncPtg(int subExprLen) {
+    	field_1_len_ref_subexpression = subExprLen;
+	}
+
+	public int getSize()
     {
         return 3;
     }
@@ -56,7 +48,7 @@
     public void writeBytes( byte[] array, int offset )
     {
         array[offset + 0] =  sid ;
-        LittleEndian.putShort( array, offset + 1, (short)field_1_len_ref_subexpression );
+        LittleEndian.putUShort( array, offset + 1, field_1_len_ref_subexpression );
     }
 
     public String toFormulaString(HSSFWorkbook book)
@@ -66,7 +58,7 @@
 
     public byte getDefaultOperandClass()
     {
-        return 0;
+        return Ptg.CLASS_REF;
     }
 
     public int getNumberOfOperands()
@@ -74,21 +66,8 @@
         return field_1_len_ref_subexpression;
     }
 
-    public Object clone()
-    {
-        MemFuncPtg ptg = new MemFuncPtg();
-        ptg.field_1_len_ref_subexpression = this.field_1_len_ref_subexpression;
-        return ptg;
-    }
-
     public int getLenRefSubexpression()
     {
         return field_1_len_ref_subexpression;
     }
-
-    public void setLenRefSubexpression(int len)
-    {
-        field_1_len_ref_subexpression = (short)len;
-    }
-
 }
\ No newline at end of file

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java Fri Jun  6 17:53:01 2008
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula;
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
 
 /**
  * Missing Function Arguments
@@ -31,16 +30,10 @@
     private final static int SIZE = 1;
     public final static byte sid  = 0x16;
    
-    public MissingArgPtg()
+    public static final Ptg instance = new MissingArgPtg();
+    private MissingArgPtg()
     {
     }
-
-    public MissingArgPtg(RecordInputStream in)
-    {
-       // doesn't need anything
-    }
-    
-  
      
     public void writeBytes(byte [] array, int offset)
     {
@@ -51,15 +44,9 @@
     {
         return SIZE;
     }
-
    
     public String toFormulaString(HSSFWorkbook book)
     {
         return " ";
     }
-        
-    public Object clone() {
-      return new MissingArgPtg();
-    }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java Fri Jun  6 17:53:01 2008
@@ -14,83 +14,37 @@
    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.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.RecordInputStream;
+package org.apache.poi.hssf.record.formula;
 
 /**
  * Implements the standard mathmatical multiplication - *
  * @author  Andrew C. Oliver (acoliver at apache dot org)
  * @author Jason Height (jheight at chariot dot net dot au)
  */
-
 public final class MultiplyPtg extends ValueOperatorPtg {
-    public final static int  SIZE = 1;
     public final static byte sid  = 0x05;
 
-    /** Creates new AddPtg */
-
-    public MultiplyPtg()
-    {
-    }
-
-    public MultiplyPtg(RecordInputStream in)
-    {
+    public static final ValueOperatorPtg instance = new MultiplyPtg();
 
-        // doesn't need anything
+    private MultiplyPtg() {
+    	// enforce singleton
     }
     
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = sid;
+    protected byte getSid() {
+    	return sid;
     }
 
-    public int getSize()
-    {
-        return SIZE;
-    }
-
-    public int getType()
-    {
-        return TYPE_BINARY;
-    }
-
-    public int getNumberOfOperands()
-    {
+    public int getNumberOfOperands() {
         return 2;
     }
-
-    public int getStringLength() {
-        return 1;
-    }
-    
-
-    public String toFormulaString(HSSFWorkbook book)
-    {
-        return "*";
-    }
-
-    public String toFormulaString(Ptg [] operands)
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append(operands[ 0 ].toFormulaString((HSSFWorkbook)null));
-        buffer.append("*");
-        buffer.append(operands[ 1 ].toFormulaString((HSSFWorkbook)null));
-        return buffer.toString();
-    }
     
     public String toFormulaString(String[] operands) {
         StringBuffer buffer = new StringBuffer();
 
         buffer.append(operands[ 0 ]);
-        buffer.append(toFormulaString((HSSFWorkbook)null));
+        buffer.append("*");
         buffer.append(operands[ 1 ]);
         return buffer.toString();
     }                  
-
-    public Object clone() {
-      return new MultiplyPtg();
-    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/NamePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/NamePtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/NamePtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/NamePtg.java Fri Jun  6 17:53:01 2008
@@ -17,11 +17,10 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hssf.record.RecordInputStream;
 import org.apache.poi.hssf.usermodel.HSSFName;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.record.NameRecord;
-import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.util.LittleEndian;
 
 /**
  *
@@ -34,12 +33,6 @@
     /** one-based index to defined name record */
     private short             field_1_label_index;
     private short             field_2_zero;   // reserved must be 0
-    boolean xtra=false;
-
-
-    private NamePtg() {
-      //Required for clone methods
-    }
 
     /**
      * Creates new NamePtg and sets its name index to that of the corresponding defined name record
@@ -69,12 +62,9 @@
 
     /** Creates new NamePtg */
 
-    public NamePtg(RecordInputStream in)
-    {
-        //field_1_ixti        = LittleEndian.getShort(data, offset);
+    public NamePtg(RecordInputStream in) {
         field_1_label_index = in.readShort();
         field_2_zero        = in.readShort();
-        //if (data[offset+6]==0) xtra=true;
     }
     
     /**
@@ -84,15 +74,13 @@
         return field_1_label_index-1; // convert to zero based
     }
 
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[offset+0]= (byte) (sid + ptgClass);
+    public void writeBytes(byte [] array, int offset) {
+        array[offset+0]= (byte) (sid + getPtgClass());
         LittleEndian.putShort(array,offset+1,field_1_label_index);
         LittleEndian.putShort(array,offset+3, field_2_zero);
     }
 
-    public int getSize()
-    {
+    public int getSize() {
         return SIZE;
     }
 
@@ -101,12 +89,7 @@
     	return book.getNameName(field_1_label_index - 1);
     }
     
-    public byte getDefaultOperandClass() {return Ptg.CLASS_REF;}
-
-    public Object clone() {
-      NamePtg ptg = new NamePtg();
-      ptg.field_1_label_index = field_1_label_index;
-      ptg.field_2_zero = field_2_zero;
-      return ptg;
-    }
+    public byte getDefaultOperandClass() {
+		return Ptg.CLASS_REF;
+	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java?rev=664220&r1=664219&r2=664220&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/NameXPtg.java Fri Jun  6 17:53:01 2008
@@ -33,31 +33,20 @@
     private short            field_3_reserved;   // reserved must be 0
 
 
-    private NameXPtg() {
-      //Required for clone methods
-    }
-
-    /** Creates new NamePtg */
-
-    public NameXPtg(RecordInputStream in)
-    {
+    public NameXPtg(RecordInputStream in) {
         field_1_ixals        = in.readShort();
         field_2_ilbl        = in.readShort();
         field_3_reserved = in.readShort();
-        
-        //field_2_reserved = LittleEndian.getByteArray(data, offset + 12,12);
     }
 
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[ offset + 0 ] = (byte)(sid + ptgClass);
+    public void writeBytes(byte [] array, int offset) {
+        array[ offset + 0 ] = (byte)(sid + getPtgClass());
         LittleEndian.putShort(array, offset + 1, field_1_ixals);
         LittleEndian.putShort(array,offset+3, field_2_ilbl);
         LittleEndian.putShort(array, offset + 5, field_3_reserved);
     }
 
-    public int getSize()
-    {
+    public int getSize() {
         return SIZE;
     }
 
@@ -67,14 +56,7 @@
         return book.resolveNameXText(field_1_ixals, field_2_ilbl-1); 
     }
     
-    public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
-
-    public Object clone() {
-      NameXPtg ptg = new NameXPtg();
-      ptg.field_1_ixals = field_1_ixals;
-      ptg.field_3_reserved = field_3_reserved;
-      ptg.field_2_ilbl = field_2_ilbl;
-      ptg.setClass(ptgClass);
-      return ptg;
-    }
+    public byte getDefaultOperandClass() {
+		return Ptg.CLASS_VALUE;
+	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message