]> source.dussan.org Git - poi.git/commitdiff
fix several findbugs SF_SWITCH_NO_DEFAULT warnings
authorJaven O'Neal <onealj@apache.org>
Tue, 12 Apr 2016 12:03:24 +0000 (12:03 +0000)
committerJaven O'Neal <onealj@apache.org>
Tue, 12 Apr 2016 12:03:24 +0000 (12:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1738782 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
src/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java
src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
src/java/org/apache/poi/ss/formula/functions/FinanceFunction.java
src/java/org/apache/poi/ss/formula/functions/Offset.java
src/java/org/apache/poi/util/HexDump.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java
src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java

index f78d307adef0403e4237f544dc0c62f65d18e171..625897d532d6f81ed39874dd32f765d633dfd97e 100644 (file)
@@ -259,6 +259,8 @@ public final class HSSFPatriarch implements HSSFShapeContainer, Drawing {
                case HSSFWorkbook.PICTURE_TYPE_PICT:
                    ftCf.setFlags(FtCfSubRecord.BITMAP_BIT);
                    break;
+               default:
+                   throw new IllegalStateException("Invalid picture type: " + pictData.getFormat());
         }
         obj.addSubRecord(ftCf);
         // FtPioGrbit (pictFlags)
index ef1b13b22d8b54cd40458e104dff93952b7a946b..772ee5821d30fdbf5182b5d18642db5fab7b493f 100644 (file)
@@ -66,6 +66,8 @@ public class HSSFShapeFactory {
                     case EscherTextboxRecord.RECORD_ID:\r
                         txtRecord = (TextObjectRecord) shapeToObj.get(record);\r
                         break;\r
+                    default:\r
+                        break;\r
                 }\r
             }\r
             if (isEmbeddedObject(objRecord)) {\r
index f97b23a8c0ed392f5a65c5c289e9f844ea38edda..9e339c7c1cba57dc4d3f9f413639859db805f2c2 100644 (file)
@@ -49,6 +49,8 @@ public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer {
                 case EscherChildAnchorRecord.RECORD_ID:
                     anchor = new HSSFChildAnchor((EscherChildAnchorRecord) ch);
                     break;
+                default:
+                    break;
             }
         }
     }
index 9c080cac170a1935f19b8f1d17cd7d37b2f9dd8c..9844b98c51e9cd622d251a5d4eb9325075734f6e 100644 (file)
@@ -1736,6 +1736,12 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
      * @param format            The format of the picture.  One of <code>PICTURE_TYPE_*</code>
      *
      * @return the index to this picture (1 based).
+     * @see #PICTURE_TYPE_WMF
+     * @see #PICTURE_TYPE_EMF
+     * @see #PICTURE_TYPE_PICT
+     * @see #PICTURE_TYPE_PNG
+     * @see #PICTURE_TYPE_JPEG
+     * @see #PICTURE_TYPE_DIB
      */
     @Override
     public int addPicture(byte[] pictureData, int format)
@@ -1792,12 +1798,14 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
             case PICTURE_TYPE_PNG:
                 blipRecord.setOptions(HSSFPictureData.MSOBI_PNG);
                 break;
-            case HSSFWorkbook.PICTURE_TYPE_JPEG:
+            case PICTURE_TYPE_JPEG:
                 blipRecord.setOptions(HSSFPictureData.MSOBI_JPEG);
                 break;
-            case HSSFWorkbook.PICTURE_TYPE_DIB:
+            case PICTURE_TYPE_DIB:
                 blipRecord.setOptions(HSSFPictureData.MSOBI_DIB);
                 break;
+            default:
+                throw new IllegalStateException("Unexpected picture format: " + format);
         }
 
         EscherBSERecord r = new EscherBSERecord();
index ac379c840e4cddb12abbf6565468dca9aaa14379..c34b2f6228b9b243c21daac5d3ba132c31c7a3ff 100644 (file)
@@ -82,8 +82,9 @@ public abstract class FinanceFunction implements Function3Arg, Function4Arg {
                 }
                 return evaluate(srcRowIndex, srcColumnIndex, args[0], args[1], args[2], arg3, arg4);
             }
+            default:
+                return ErrorEval.VALUE_INVALID;
         }
-        return ErrorEval.VALUE_INVALID;
     }
 
     protected double evaluate(double[] ds) throws EvaluationException {
index cffa26a4c4c6a5bf5267518e293333c37f6230e5..8877f2410f5a603696d424ef2c44000c316c2ec1 100644 (file)
@@ -179,10 +179,16 @@ public final class Offset implements Function {
                                        if(!(args[4] instanceof MissingArgEval)) {
                                                width = evaluateIntArg(args[4], srcCellRow, srcCellCol);
                                        }
+                                       // fall-through to pick up height
                                case 4:
                                        if(!(args[3] instanceof MissingArgEval)) {
                                                height = evaluateIntArg(args[3], srcCellRow, srcCellCol);
                                        }
+                                       break;
+                               //case 3:
+                                       // nothing to do
+                               default:
+                                       break;
                        }
                        // Zero height or width raises #REF! error
                        if(height == 0 || width == 0) {
index d134b540f18eb6d6523173e2b969d121208a1dbe..2e3a45f526ddc7893ee506e761002e340231e06b 100644 (file)
@@ -172,10 +172,13 @@ public class HexDump {
         if (Character.isISOControl(charB)) return '.';
         
         switch (charB) {
-        // printable, but not compilable with current compiler encoding
-        case 0xFF: case 0xDD:
-            charB = '.';
-            break;
+            // printable, but not compilable with current compiler encoding
+            case 0xFF:
+            case 0xDD:
+                charB = '.';
+                break;
+            default:
+                break;
         }
         return charB;
     }
index 77e99d2d399420527c6bf81f3deeddeb86ef2f7f..0e9e741b3b6e76115ca45ede1522aa9cd1ca5ff7 100644 (file)
@@ -110,6 +110,8 @@ public class XSLFFreeformShape extends XSLFAutoShape
                     numPoints++;\r
                     ctPath.addNewClose();\r
                     break;\r
+                default:\r
+                    throw new IllegalStateException("Unrecognized path segment type: " + type);\r
             }\r
             it.next();\r
         }\r
index 992dc0791879a7b43db8edb07b8650aaf8e4d8fe..7418d7b9ad20bee624a4af42293b3426b757db82 100644 (file)
@@ -213,6 +213,8 @@ public class SheetDataWriter {
                             _out.write("<v>" + nval + "</v>");\r
                         }\r
                         break;\r
+                    default:\r
+                        break;\r
                 }\r
                 break;\r
             }\r
@@ -255,7 +257,7 @@ public class SheetDataWriter {
                 break;\r
             }\r
             default: {\r
-                throw new RuntimeException("Huh?");\r
+                throw new IllegalStateException("Invalid cell type: " + cellType);\r
             }\r
         }\r
         _out.write("</c>");\r
index 2e9c842ed4e0a652b5f86c198e14583739690881..8b5dc413b10b799b1ee49fb72f9ddeba9caa862b 100644 (file)
@@ -505,6 +505,8 @@ public class XSSFFont implements Font {
                 case Font.SS_SUPER:
                     offsetProperty.setVal(STVerticalAlignRun.SUPERSCRIPT);
                     break;
+                default:
+                    throw new IllegalStateException("Invalid type offset: " + offset);
             }
         }
     }
index 713a7d90159292d62f02dc0cfd1e38d751fe1ed6..03199b330e70845b2c917369a534ea4f1161d125 100644 (file)
@@ -160,6 +160,8 @@ public final class FileInformationBlock implements Cloneable
         case 0x0112:
             assertCbRgFcLcb( "0x0112", 0x00B7, "0x00B7", _cbRgFcLcb );
             break;
+        default:
+            throw new IllegalStateException("Invalid file format version number: " + getNFib());
         }
     }
 
@@ -194,6 +196,8 @@ public final class FileInformationBlock implements Cloneable
         case 0x0112:
             assertCswNew( "0x0112", 0x0005, "0x0005", _cswNew );
             break;
+        default:
+            throw new IllegalStateException("Invalid file format version number: " + getNFib());
         }
     }