poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject cvs commit: jakarta-poi/src/testcases/org/apache/poi/hssf/record/aggregates TestFormulaRecordAggregate.java
Date Thu, 20 Mar 2003 20:01:19 GMT
avik        2003/03/20 12:01:18

  Modified:    src/java/org/apache/poi/hssf/record StringRecord.java
               src/java/org/apache/poi/hssf/record/aggregates
                        FormulaRecordAggregate.java
  Added:       src/testcases/org/apache/poi/hssf/record/aggregates
                        TestFormulaRecordAggregate.java
  Log:
  Add clone() to FormulaRecordAggregate
  Original patch supplied by Henning Boeger
  Changed to make it deeper clone, added clone to StringRecord in the process
  Also added a test.
  
  Revision  Changes    Path
  1.3       +9 -0      jakarta-poi/src/java/org/apache/poi/hssf/record/StringRecord.java
  
  Index: StringRecord.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/StringRecord.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringRecord.java	5 Aug 2002 12:53:01 -0000	1.2
  +++ StringRecord.java	20 Mar 2003 20:01:13 -0000	1.3
  @@ -237,5 +237,14 @@
           buffer.append("[/STRING]\n");
           return buffer.toString();
       }
  +    
  +    public Object clone() {
  +        StringRecord rec = new StringRecord();
  +        rec.field_1_string_length = this.field_1_string_length;
  +        rec.field_2_unicode_flag= this.field_2_unicode_flag;
  +        rec.field_3_string = this.field_3_string;
  +        return rec;
  +
  +    }
   
   }
  
  
  
  1.2       +8 -0      jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
  
  Index: FormulaRecordAggregate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FormulaRecordAggregate.java	5 Aug 2002 12:54:05 -0000	1.1
  +++ FormulaRecordAggregate.java	20 Mar 2003 20:01:14 -0000	1.2
  @@ -205,6 +205,14 @@
       {
           return formulaRecord.toString();
       }
  +    
  +    /**
  +     * @see java.lang.Object#clone()
  +     */
  +    public Object clone() {
  +        return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), (StringRecord)
this.stringRecord.clone());
  +    }
  +
   
   
   }
  
  
  
  1.1                  jakarta-poi/src/testcases/org/apache/poi/hssf/record/aggregates/TestFormulaRecordAggregate.java
  
  Index: TestFormulaRecordAggregate.java
  ===================================================================
  /*
   * TestFormulaRecordAggregate.java
   *
   * Created on March 21, 2003, 12:32 AM
   */
  
  package org.apache.poi.hssf.record.aggregates;
  import org.apache.poi.hssf.record.FormulaRecord;
  import org.apache.poi.hssf.record.StringRecord;
  
  /**
   *
   * @author  avik
   */
  public class TestFormulaRecordAggregate extends junit.framework.TestCase {
      
      /** Creates a new instance of TestFormulaRecordAggregate */
      public TestFormulaRecordAggregate(String arg) {
          super(arg);
      }
      
      public void testClone() {
          FormulaRecord f = new FormulaRecord();
          StringRecord s = new StringRecord();
          FormulaRecordAggregate fagg = new FormulaRecordAggregate(f,s);
          FormulaRecordAggregate newFagg = (FormulaRecordAggregate) fagg.clone();
          assertTrue("objects are different", fagg!=newFagg);
          assertTrue("deep clone", fagg.getFormulaRecord() != newFagg.getFormulaRecord());
          assertTrue("deep clone",  fagg.getStringRecord() != newFagg.getStringRecord());
  
          
      }
      
  }
  
  
  

Mime
View raw message