]> source.dussan.org Git - poi.git/commitdiff
IDE and JavaDoc fixes
authorDominik Stadler <centic@apache.org>
Sun, 30 Dec 2018 22:44:29 +0000 (22:44 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 30 Dec 2018 22:44:29 +0000 (22:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1850007 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/SupBookRecord.java
src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
src/testcases/org/apache/poi/hssf/record/TestNameRecord.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java
src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java

index 9067c24cc7c25f88bdf3e9075b7d51140a2e133b..bda7cca026569ef4773e8131342ac583a4667e14 100644 (file)
@@ -130,7 +130,7 @@ public final class SupBookRecord extends StandardRecord {
      }
 
     public String toString() {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         sb.append("[SUPBOOK ");
 
         if(isExternalReferences()) {
@@ -158,8 +158,8 @@ public final class SupBookRecord extends StandardRecord {
 
         sum += StringUtil.getEncodedSize(field_2_encoded_url);
 
-        for(int i=0; i<field_3_sheet_names.length; i++) {
-            sum += StringUtil.getEncodedSize(field_3_sheet_names[i]);
+        for (String field_3_sheet_name : field_3_sheet_names) {
+            sum += StringUtil.getEncodedSize(field_3_sheet_name);
         }
         return sum;
     }
@@ -170,8 +170,8 @@ public final class SupBookRecord extends StandardRecord {
         if(isExternalReferences()) {
             StringUtil.writeUnicodeString(out, field_2_encoded_url);
 
-            for(int i=0; i<field_3_sheet_names.length; i++) {
-                StringUtil.writeUnicodeString(out, field_3_sheet_names[i]);
+            for (String field_3_sheet_name : field_3_sheet_names) {
+                StringUtil.writeUnicodeString(out, field_3_sheet_name);
             }
         } else {
             int field2val = _isAddInFunctions ? TAG_ADD_IN_FUNCTIONS : TAG_INTERNAL_REFERENCES;
index e7754ed576349b92dd542683364f461b48a2a49a..05e297f6d733ad68d4643857e3f6539c251f3d96 100644 (file)
@@ -17,7 +17,9 @@
 
 package org.apache.poi.openxml4j.opc.compliance;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -95,7 +97,7 @@ public final class TestOPCCompliancePartName {
             try {
                 uri = new URI(s);
             } catch (URISyntaxException e) {
-                assertTrue(s.equals("[Content_Types].xml"));
+                assertEquals("[Content_Types].xml", s);
                 continue;
             }
             assertFalse("This part name SHOULD NOT be valid: " + s,
@@ -225,9 +227,9 @@ public final class TestOPCCompliancePartName {
         for (int i = 0; i < partName1.length || i < partName2.length; ++i) {
             PackagePartName p1 = PackagingURIHelper.createPartName(partName1[i]);
             PackagePartName p2 = PackagingURIHelper.createPartName(partName2[i]);
-            assertTrue(p1.equals(p2));
-            assertTrue(p1.compareTo(p2) == 0);
-            assertTrue(p1.hashCode() == p2.hashCode());
+            assertEquals(p1, p2);
+            assertEquals(0, p1.compareTo(p2));
+            assertEquals(p1.hashCode(), p2.hashCode());
         }
     }
 
@@ -244,9 +246,9 @@ public final class TestOPCCompliancePartName {
         for (int i = 0; i < partName1.length || i < partName2.length; ++i) {
             PackagePartName p1 = PackagingURIHelper.createPartName(partName1[i]);
             PackagePartName p2 = PackagingURIHelper.createPartName(partName2[i]);
-            assertFalse(p1.equals(p2));
-            assertFalse(p1.compareTo(p2) == 0);
-            assertFalse(p1.hashCode() == p2.hashCode());
+            assertNotEquals(p1, p2);
+            assertNotEquals(0, p1.compareTo(p2));
+            assertNotEquals(p1.hashCode(), p2.hashCode());
         }
     }
 }
index 60a8f12ef05bf0f3a901e416baac607ad5647b33..9d94f8056867763fc8eaff6e35dcacfcc565b0ba 100644 (file)
@@ -875,7 +875,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
 
         // Column 1 has a font with regular colours
         XSSFCell cr = r.getCell(1);
-        XSSFFont fr = wb.getFontAt(cr.getCellStyle().getFontIndex());
+        XSSFFont fr = wb.getFontAt(cr.getCellStyle().getFontIndexAsInt());
         XSSFColor colr = fr.getXSSFColor();
         // No theme, has colours
         assertEquals(0, colr.getTheme());
@@ -883,7 +883,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
 
         // Column 0 has a font with colours from a theme
         XSSFCell ct = r.getCell(0);
-        XSSFFont ft = wb.getFontAt(ct.getCellStyle().getFontIndex());
+        XSSFFont ft = wb.getFontAt(ct.getCellStyle().getFontIndexAsInt());
         XSSFColor colt = ft.getXSSFColor();
         // Has a theme, which has the colours on it
         assertEquals(9, colt.getTheme());
index 231b6c92cbe8af53b865061bd43c6091c9a8f858..34397e3726b4acbfb967b6e39d72c6d31f6afc23 100644 (file)
@@ -72,7 +72,7 @@ public final class TestNameRecord extends TestCase {
                wb.createSheet("Sheet1");
                name.setNameName("test");
                name.setRefersToFormula("Sheet1!$B$3");
-               if (name.getRefersToFormula().equals("Sheet1!B3")) {
+               if ("Sheet1!B3".equals(name.getRefersToFormula())) {
                        fail("Identified bug 46174");
                }
                assertEquals("Sheet1!$B$3", name.getRefersToFormula());
@@ -701,7 +701,7 @@ public final class TestNameRecord extends TestCase {
         NameRecord record = new NameRecord();
         assertEquals(0, record.getExternSheetNumber());
         
-        record.setNameDefinition(new Ptg[] {});
+        record.setNameDefinition(Ptg.EMPTY_PTG_ARRAY);
         assertEquals(0, record.getExternSheetNumber());
         
         record.setNameDefinition(new Ptg[] {new NamePtg(1)});
index 725bb86458c2136af0a31a84c77bc18ce3dde3a1..b750e6454b256b3e08bae827cbe4d1e52614a2f3 100644 (file)
@@ -22,11 +22,9 @@ import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.model.HSSFFormulaParser;
 import org.apache.poi.hssf.record.NameRecord;
-import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.usermodel.BaseTestNamedRange;
-import org.apache.poi.ss.util.AreaReference;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.junit.Test;
 
@@ -126,7 +124,7 @@ public final class TestHSSFName extends BaseTestNamedRange {
 
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
         HSSFName nm = wb2.getNameAt(wb2.getNameIndex("RangeTest"));
-        assertTrue("Name is "+nm.getNameName(),"RangeTest".equals(nm.getNameName()));
+        assertEquals("Name is " + nm.getNameName(), "RangeTest", nm.getNameName());
         assertEquals(wb2.getSheetName(0)+"!$D$4:$E$8", nm.getRefersToFormula());
         wb2.close();
         wb1.close();
index 80c0750c42f513e93c662dcc29f03729e36cb635..8d54e9b021b81c3f973984f1abf97391a4310cd1 100644 (file)
@@ -25,10 +25,7 @@ import java.io.InputStream;
 
 import org.apache.poi.hpsf.SummaryInformation;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.apache.poi.poifs.filesystem.Entry;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
index b858e3dd11b2bd8e59d6fa3eeda65201fcf4b61c..a656ef38c1ebffea21ebe54d419b4500dabc7950 100644 (file)
@@ -248,12 +248,12 @@ public abstract class BaseTestNamedRange {
          // Read the Excel file and verify its content
          Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
          Name nm1 = wb2.getName("RangeTest1");
-         assertTrue("Name is "+nm1.getNameName(),"RangeTest1".equals(nm1.getNameName()));
-         assertTrue("Reference is "+nm1.getRefersToFormula(),(wb2.getSheetName(0)+"!$A$1:$L$41").equals(nm1.getRefersToFormula()));
+        assertEquals("Name is " + nm1.getNameName(), "RangeTest1", nm1.getNameName());
+        assertEquals("Reference is " + nm1.getRefersToFormula(), (wb2.getSheetName(0) + "!$A$1:$L$41"), nm1.getRefersToFormula());
 
          Name nm2 = wb2.getName("RangeTest2");
-         assertTrue("Name is "+nm2.getNameName(),"RangeTest2".equals(nm2.getNameName()));
-         assertTrue("Reference is "+nm2.getRefersToFormula(),(wb2.getSheetName(1)+"!$A$1:$O$21").equals(nm2.getRefersToFormula()));
+        assertEquals("Name is " + nm2.getNameName(), "RangeTest2", nm2.getNameName());
+        assertEquals("Reference is " + nm2.getRefersToFormula(), (wb2.getSheetName(1) + "!$A$1:$O$21"), nm2.getRefersToFormula());
          
          wb2.close();
          wb1.close();
@@ -464,12 +464,12 @@ public abstract class BaseTestNamedRange {
 
         Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
         Name nm =wb2.getName("RangeTest");
-        assertTrue("Name is "+nm.getNameName(),"RangeTest".equals(nm.getNameName()));
-        assertTrue("Reference is "+nm.getRefersToFormula(),(wb2.getSheetName(0)+"!$D$4:$E$8").equals(nm.getRefersToFormula()));
+        assertEquals("Name is " + nm.getNameName(), "RangeTest", nm.getNameName());
+        assertEquals("Reference is " + nm.getRefersToFormula(), (wb2.getSheetName(0) + "!$D$4:$E$8"), nm.getRefersToFormula());
 
         nm = wb2.getName("AnotherTest");
-        assertTrue("Name is "+nm.getNameName(),"AnotherTest".equals(nm.getNameName()));
-        assertTrue("Reference is "+nm.getRefersToFormula(),newNamedRange2.getRefersToFormula().equals(nm.getRefersToFormula()));
+        assertEquals("Name is " + nm.getNameName(), "AnotherTest", nm.getNameName());
+        assertEquals("Reference is " + nm.getRefersToFormula(), newNamedRange2.getRefersToFormula(), nm.getRefersToFormula());
         
         wb2.close();
         wb1.close();
@@ -695,7 +695,7 @@ public abstract class BaseTestNamedRange {
     }
     
     @Test
-    public void testInvalid() throws IOException {
+    public void testInvalid() {
         Workbook wb = _testDataProvider.createWorkbook();
         
         Name name = wb.createName();