]> source.dussan.org Git - poi.git/commitdiff
Some IDE warning fixes and unit test adjustments
authorDominik Stadler <centic@apache.org>
Wed, 5 Oct 2016 19:59:44 +0000 (19:59 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 5 Oct 2016 19:59:44 +0000 (19:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763482 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
src/java/org/apache/poi/ss/formula/eval/NumberEval.java
src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java

index 427779d2f4bc358c851258e00d746712b1f852bb..31a17e0c0fe727b5eab39fd21a2a12d982ff5833 100644 (file)
@@ -205,9 +205,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
      *  records too.
      */
     protected void removeAllCells() {
-        for(int i=0; i<cells.length; i++) {
-            if(cells[i] != null) {
-                removeCell(cells[i], true);
+        for (HSSFCell cell : cells) {
+            if (cell != null) {
+                removeCell(cell, true);
             }
         }
         cells=new HSSFCell[INITIAL_CAPACITY];
@@ -232,9 +232,9 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
                 row.setFirstCol(colIx);
             } else if (colIx > row.getLastCol()) {
                 row.setLastCol(colIx + 1);
-            } else {
+            } /*else {
                 // added cell is within first and last cells
-            }
+            }*/
         }
         // TODO - RowRecord column boundaries need to be updated for cell comments too
         return hcell;
@@ -446,12 +446,11 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
     @Override
     public int getPhysicalNumberOfCells()
     {
-      int count=0;
-      for(int i=0;i<cells.length;i++)
-      {
-        if(cells[i]!=null) count++;
-      }
-      return count;
+        int count = 0;
+        for (HSSFCell cell : cells) {
+            if (cell != null) count++;
+        }
+        return count;
     }
 
     /**
index 1233cea7fe770e4c57d6fa2dbaf675f9c852e605..87d425356b93531af95ce9d986a4592afdc4dcd6 100644 (file)
@@ -64,10 +64,8 @@ public final class NumberEval implements NumericValueEval, StringValueEval {
         return _stringValue;
     }
     public final String toString() {
-        StringBuffer sb = new StringBuffer(64);
-        sb.append(getClass().getName()).append(" [");
-        sb.append(getStringValue());
-        sb.append("]");
-        return sb.toString();
+        return getClass().getName() + " [" +
+                getStringValue() +
+                "]";
     }
 }
index 7c817833313f2d59efb3b7f02943c51ee62d4efb..2c00cbfe0eaa65330ead6189ce4115047cb7832a 100644 (file)
@@ -27,14 +27,7 @@ import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.poi.ddf.EscherBoolProperty;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherDgRecord;
-import org.apache.poi.ddf.EscherOptRecord;
-import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.ddf.EscherSimpleProperty;
-import org.apache.poi.ddf.EscherSpRecord;
-import org.apache.poi.ddf.EscherTextboxRecord;
+import org.apache.poi.ddf.*;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
 import org.apache.poi.hssf.record.EscherAggregate;
@@ -160,6 +153,9 @@ public class TestDrawingShapes {
         HSSFClientAnchor anchor = new HSSFClientAnchor(10, 10, 50, 50, (short) 2, 2, (short) 4, 4);
         anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE);
         assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType());
+        //noinspection deprecation
+        anchor.setAnchorType(AnchorType.MOVE_DONT_RESIZE.value);
+        assertEquals(AnchorType.MOVE_DONT_RESIZE, anchor.getAnchorType());
 
         HSSFSimpleShape rectangle = drawing.createSimpleShape(anchor);
         rectangle.setShapeType(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE);
@@ -175,8 +171,13 @@ public class TestDrawingShapes {
         rectangle.setWrapText(HSSFSimpleShape.WRAP_NONE);
         rectangle.setString(new HSSFRichTextString("teeeest"));
         assertEquals(rectangle.getLineStyleColor(), 1111);
-        assertEquals(((EscherSimpleProperty)((EscherOptRecord)HSSFTestHelper.getEscherContainer(rectangle).getChildById(EscherOptRecord.RECORD_ID))
-                .lookup(EscherProperties.TEXT__TEXTID)).getPropertyValue(), "teeeest".hashCode());
+        EscherContainerRecord escherContainer = HSSFTestHelper.getEscherContainer(rectangle);
+        assertNotNull(escherContainer);
+        EscherRecord childById = escherContainer.getChildById(EscherOptRecord.RECORD_ID);
+        assertNotNull(childById);
+        EscherProperty lookup = ((EscherOptRecord) childById).lookup(EscherProperties.TEXT__TEXTID);
+        assertNotNull(lookup);
+        assertEquals(((EscherSimpleProperty) lookup).getPropertyValue(), "teeeest".hashCode());
         assertEquals(rectangle.isNoFill(), true);
         assertEquals(rectangle.getWrapText(), HSSFSimpleShape.WRAP_NONE);
         assertEquals(rectangle.getString().getString(), "teeeest");