]> source.dussan.org Git - poi.git/commitdiff
fix some Eclipse warnings, adjust some unit tests slightly
authorDominik Stadler <centic@apache.org>
Fri, 23 Aug 2013 10:44:39 +0000 (10:44 +0000)
committerDominik Stadler <centic@apache.org>
Fri, 23 Aug 2013 10:44:39 +0000 (10:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1516818 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/StyleRecord.java
src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java
src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java
src/testcases/org/apache/poi/POIDataSamples.java
src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java

index ef2f703617f95d663e9a1580045a95d7a689f6cd..77e677485d57c26b935ee8a0a0a9b9e764621686 100644 (file)
@@ -61,7 +61,7 @@ public final class StyleRecord extends StandardRecord {
                        field_3_outline_style_level = in.readByte();
                } else {
                        int field_2_name_length = in.readShort();
-                       
+
                        if(in.remaining() < 1) {
                                // Some files from Crystal Reports lack the is16BitUnicode byte
                                //  the remaining fields, which is naughty
@@ -71,7 +71,7 @@ public final class StyleRecord extends StandardRecord {
                                // guess this is OK if the string length is zero
                                field_4_name = "";
                        } else {
-                               
+
                                field_3_stringHasMultibyte = in.readByte() != 0x00;
                                if (field_3_stringHasMultibyte) {
                                        field_4_name = StringUtil.readUnicodeLE(in, field_2_name_length);
@@ -92,7 +92,7 @@ public final class StyleRecord extends StandardRecord {
 
        /**
         * get the actual index of the style extended format record
-        * @see #getXFIndex() 
+        * @see #getXFIndex()
         * @return index of the xf record
         */
        public int getXFIndex() {
@@ -138,6 +138,7 @@ public final class StyleRecord extends StandardRecord {
                return field_4_name;
        }
 
+       @Override
        public String toString() {
                StringBuffer sb = new StringBuffer();
 
@@ -155,16 +156,18 @@ public final class StyleRecord extends StandardRecord {
                return sb.toString();
        }
 
-       
+
+       @Override
        protected int getDataSize() {
                if (isBuiltin()) {
                        return 4; // short, byte, byte
                }
-               return 2 // short xf index 
-                       + 3 // str len + flag 
+               return 2 // short xf index
+                       + 3 // str len + flag
                        + field_4_name.length() * (field_3_stringHasMultibyte ? 2 : 1);
        }
 
+       @Override
        public void serialize(LittleEndianOutput out) {
                out.writeShort(field_1_xf_index);
                if (isBuiltin()) {
@@ -181,6 +184,7 @@ public final class StyleRecord extends StandardRecord {
                }
        }
 
+       @Override
        public short getSid() {
                return sid;
        }
index d73a31ee8e24008ce15e1c72567b1dece9506c3f..551ff754747e0b6104fc1e56509788d8b13cdaad 100644 (file)
@@ -21,7 +21,7 @@ import org.apache.poi.ss.formula.udf.UDFFinder;
 import java.util.*;
 
 /**
- * Analysis Toolpack Function Definitions 
+ * Analysis Toolpack Function Definitions
  */
 public final class AnalysisToolPak implements UDFFinder {
 
@@ -229,9 +229,9 @@ public final class AnalysisToolPak implements UDFFinder {
             if(metaData != null) {
                 throw new IllegalArgumentException(name + " is a built-in Excel function. " +
                         "Use FunctoinEval.registerFunction(String name, Function func) instead.");
-            } else {
-                throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
             }
+
+            throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
         }
         FreeRefFunction f = inst.findFunction(name);
         if(f != null && !(f instanceof NotImplemented)) {
index fe147b622817271f4ea5161276eb9be8d3a2e6f8..97af09c268ece27967ffc6bd8b7afef01feef711 100644 (file)
@@ -106,7 +106,7 @@ public class POIXMLDocumentPart {
      *
      * @param part - The package part that holds xml data represenring this sheet.
      * @param rel - the relationship of the given package part
-     * @see #read(POIXMLFactory, java.util.Map) 
+     * @see #read(POIXMLFactory, java.util.Map)
      */
     public POIXMLDocumentPart(PackagePart part, PackageRelationship rel){
         this.packagePart = part;
@@ -131,7 +131,7 @@ public class POIXMLDocumentPart {
     /**
      * When you open something like a theme, call this to
      *  re-base the XML Document onto the core child of the
-     *  current core document 
+     *  current core document
      */
     protected final void rebase(OPCPackage pkg) throws InvalidFormatException {
         PackageRelationshipCollection cores =
@@ -179,7 +179,7 @@ public class POIXMLDocumentPart {
      * {@link POIXMLDocumentPart} to the {@link PackagePart} of the target
      * {@link POIXMLDocumentPart} with a {@link PackageRelationship#getId()}
      * matching the given parameter value.
-     * 
+     *
      * @param id
      *            The relation id to look for
      * @return the target part of the relation, or null, if none exists
@@ -193,7 +193,7 @@ public class POIXMLDocumentPart {
      * {@link PackageRelationship}, that sources from the {@link PackagePart} of
      * this {@link POIXMLDocumentPart} to the {@link PackagePart} of the given
      * parameter value.
-     * 
+     *
      * @param part
      *            The {@link POIXMLDocumentPart} for which the according
      *            relation-id shall be found.
@@ -233,7 +233,7 @@ public class POIXMLDocumentPart {
     /**
      * Remove the relation to the specified part in this package and remove the
      * part, if it is no longer needed and flag is set to true.
-     * 
+     *
      * @param part
      *            The related part, to which the relation shall be removed.
      * @param removeUnusedParts
@@ -343,7 +343,8 @@ public class POIXMLDocumentPart {
      * @param noRelation if true, then no relationship is added.
      * @return the created child POIXMLDocumentPart
      */
-    protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){
+    @SuppressWarnings("null")
+       protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){
         try {
             PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getFileName(idx));
             PackageRelationship rel = null;
@@ -414,7 +415,7 @@ public class POIXMLDocumentPart {
             }
         }
     }
-    
+
     /**
      * Get the PackagePart that is the target of a relationship from this Part.
      *
index 6cdf7ce8f5a2226054f456c3b7f6fa9745b02c5c..b3352153903b3caf563c5bd2d3a8b55466d8a83f 100644 (file)
 ==================================================================== */\r
 package org.apache.poi;\r
 \r
-import java.io.*;\r
+import java.io.ByteArrayOutputStream;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
 \r
 /**\r
  * Centralises logic for finding/opening sample files\r
@@ -219,16 +224,20 @@ public final class POIDataSamples {
             _is = is;\r
         }\r
 \r
-        public int read() throws IOException {\r
+        @Override\r
+               public int read() throws IOException {\r
             return _is.read();\r
         }\r
-        public int read(byte[] b, int off, int len) throws IOException {\r
+        @Override\r
+               public int read(byte[] b, int off, int len) throws IOException {\r
             return _is.read(b, off, len);\r
         }\r
-        public boolean markSupported() {\r
+        @Override\r
+               public boolean markSupported() {\r
             return false;\r
         }\r
-        public void close() throws IOException {\r
+        @Override\r
+               public void close() throws IOException {\r
             _is.close();\r
         }\r
     }\r
index e71289c149eb7b41edec62fc1cebf43a6390432f..8363449bfaf1996f05fea95409d3af5a10e1ead2 100644 (file)
@@ -71,9 +71,8 @@ public class AllUserModelTests {
                result.addTestSuite(TestRowStyle.class);
                result.addTestSuite(TestSanityChecker.class);
                result.addTestSuite(TestSheetHiding.class);
-               if (false) { // deliberately avoiding this one
-                       result.addTestSuite(TestUnfixedBugs.class);
-               }
+               /* deliberately avoiding this one
+               result.addTestSuite(TestUnfixedBugs.class);*/
                result.addTestSuite(TestUnicodeWorkbook.class);
                result.addTestSuite(TestNonStandardWorkbookStreamNames.class);
                result.addTestSuite(TestWorkbook.class);
index eb185471f469fd931592163d4973089b698ed2ae..d013beaf217cca2ace6912663a971ea73b87a15b 100644 (file)
@@ -89,36 +89,41 @@ public abstract class BaseTestRow extends TestCase {
 
     public void testRemoveCell() {
         Workbook workbook = _testDataProvider.createWorkbook();
-        Sheet sheet = workbook.createSheet();
-        Row row = sheet.createRow(0);
-
-        assertEquals(0, row.getPhysicalNumberOfCells());
-        assertEquals(-1, row.getLastCellNum());
-        assertEquals(-1, row.getFirstCellNum());
-
-        row.createCell(1);
-        assertEquals(2, row.getLastCellNum());
-        assertEquals(1, row.getFirstCellNum());
-        assertEquals(1, row.getPhysicalNumberOfCells());
-        row.createCell(3);
-        assertEquals(4, row.getLastCellNum());
-        assertEquals(1, row.getFirstCellNum());
-        assertEquals(2, row.getPhysicalNumberOfCells());
-        row.removeCell(row.getCell(3));
-        assertEquals(2, row.getLastCellNum());
-        assertEquals(1, row.getFirstCellNum());
-        assertEquals(1, row.getPhysicalNumberOfCells());
-        row.removeCell(row.getCell(1));
-        assertEquals(-1, row.getLastCellNum());
-        assertEquals(-1, row.getFirstCellNum());
-        assertEquals(0, row.getPhysicalNumberOfCells());
+        {
+            Sheet sheet = workbook.createSheet();
+            Row row = sheet.createRow(0);
+
+            assertEquals(0, row.getPhysicalNumberOfCells());
+            assertEquals(-1, row.getLastCellNum());
+            assertEquals(-1, row.getFirstCellNum());
+
+            row.createCell(1);
+            assertEquals(2, row.getLastCellNum());
+            assertEquals(1, row.getFirstCellNum());
+            assertEquals(1, row.getPhysicalNumberOfCells());
+            row.createCell(3);
+            assertEquals(4, row.getLastCellNum());
+            assertEquals(1, row.getFirstCellNum());
+            assertEquals(2, row.getPhysicalNumberOfCells());
+            row.removeCell(row.getCell(3));
+            assertEquals(2, row.getLastCellNum());
+            assertEquals(1, row.getFirstCellNum());
+            assertEquals(1, row.getPhysicalNumberOfCells());
+            row.removeCell(row.getCell(1));
+            assertEquals(-1, row.getLastCellNum());
+            assertEquals(-1, row.getFirstCellNum());
+            assertEquals(0, row.getPhysicalNumberOfCells());
+        }
 
         workbook = _testDataProvider.writeOutAndReadBack(workbook);
-        sheet = workbook.getSheetAt(0);
-        row = sheet.getRow(0);
-        assertEquals(-1, row.getLastCellNum());
-        assertEquals(-1, row.getFirstCellNum());
-        assertEquals(0, row.getPhysicalNumberOfCells());
+
+        {
+            Sheet sheet = workbook.getSheetAt(0);
+            Row row = sheet.getRow(0);
+            assertEquals(-1, row.getLastCellNum());
+            assertEquals(-1, row.getFirstCellNum());
+            assertEquals(0, row.getPhysicalNumberOfCells());
+        }
     }
 
     public void baseTestRowBounds(int maxRowNum) {
@@ -387,30 +392,30 @@ public abstract class BaseTestRow extends TestCase {
         assertTrue(cell2 == it.next());
         assertEquals(Cell.CELL_TYPE_STRING, cell5.getCellType());
     }
-    
+
     public void testRowStyle() {
        Workbook workbook = _testDataProvider.createWorkbook();
        Sheet sheet = workbook.createSheet("test");
        Row row1 = sheet.createRow(0);
        Row row2 = sheet.createRow(1);
-       
+
        // Won't be styled currently
        assertEquals(false, row1.isFormatted());
        assertEquals(false, row2.isFormatted());
        assertEquals(null, row1.getRowStyle());
        assertEquals(null, row2.getRowStyle());
-       
+
        // Style one
        CellStyle style = workbook.createCellStyle();
        style.setDataFormat((short)4);
        row2.setRowStyle(style);
-       
+
        // Check
        assertEquals(false, row1.isFormatted());
        assertEquals(true, row2.isFormatted());
        assertEquals(null, row1.getRowStyle());
        assertEquals(style, row2.getRowStyle());
-       
+
        // Save, load and re-check
        workbook = _testDataProvider.writeOutAndReadBack(workbook);
        sheet = workbook.getSheetAt(0);
@@ -418,7 +423,7 @@ public abstract class BaseTestRow extends TestCase {
        row1 = sheet.getRow(0);
        row2 = sheet.getRow(1);
        style = workbook.getCellStyleAt(style.getIndex());
-       
+
        assertEquals(false, row1.isFormatted());
        assertEquals(true, row2.isFormatted());
        assertEquals(null, row1.getRowStyle());