From 18f7a2de88d3b13c3dc5bbc9d1b6521bfb5aeb75 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Tue, 12 Apr 2016 11:12:57 +0000 Subject: [PATCH] fix several findbugs SF_SWITCH_NO_DEFAULT warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1738765 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/dev/FormulaViewer.java | 10 ++++++++++ .../MissingRecordAwareHSSFListener.java | 2 ++ .../apache/poi/hssf/extractor/ExcelExtractor.java | 2 ++ .../org/apache/poi/hssf/model/CommentShape.java | 2 ++ .../apache/poi/hssf/model/InternalWorkbook.java | 14 +++++++++++++- .../org/apache/poi/hssf/usermodel/HSSFCell.java | 7 +++++++ .../poi/hssf/converter/ExcelToFoConverter.java | 1 + 7 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/hssf/dev/FormulaViewer.java b/src/java/org/apache/poi/hssf/dev/FormulaViewer.java index 5ea0331ad7..8fce8d2e9e 100644 --- a/src/java/org/apache/poi/hssf/dev/FormulaViewer.java +++ b/src/java/org/apache/poi/hssf/dev/FormulaViewer.java @@ -110,6 +110,8 @@ public class FormulaViewer case Ptg.CLASS_ARRAY : buf.append("ARRAY"); break; + default: + throwInvalidRVAToken(token); } buf.append(sep); @@ -125,6 +127,8 @@ public class FormulaViewer case Ptg.CLASS_ARRAY : buf.append("ARRAY"); break; + default: + throwInvalidRVAToken(token); } }else { buf.append("VALUE"); @@ -173,12 +177,18 @@ public class FormulaViewer case Ptg.CLASS_ARRAY : buf.append("(A)"); break; + default: + throwInvalidRVAToken(token); } buf.append(' '); } return buf.toString(); } + private static void throwInvalidRVAToken(Ptg token) { + throw new IllegalStateException("Invalid RVA type (" + token.getPtgClass() + "). This should never happen."); + } + private static String composeFormula(FormulaRecord record) { diff --git a/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java b/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java index 503f8d81b1..ea9b70d88d 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java @@ -134,6 +134,8 @@ public final class MissingRecordAwareHSSFListener implements HSSFListener { thisRow = nrec.getRow(); thisColumn = nrec.getColumn(); break; + default: + break; } } diff --git a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java index 27df0c8f17..f95c7b2a9a 100644 --- a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java +++ b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java @@ -367,6 +367,8 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p case HSSFCell.CELL_TYPE_ERROR: text.append(ErrorEval.getText(cell.getErrorCellValue())); break; + default: + throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultType()); } } diff --git a/src/java/org/apache/poi/hssf/model/CommentShape.java b/src/java/org/apache/poi/hssf/model/CommentShape.java index aa61a3676b..ba1fad9770 100644 --- a/src/java/org/apache/poi/hssf/model/CommentShape.java +++ b/src/java/org/apache/poi/hssf/model/CommentShape.java @@ -116,6 +116,8 @@ public final class CommentShape extends TextboxShape { case EscherProperties.LINESTYLE__COLOR: iterator.remove(); break; + default: + break; } } diff --git a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java index 7ca7c942df..12854558af 100644 --- a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java +++ b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java @@ -334,7 +334,11 @@ public final class InternalWorkbook { if (log.check( POILogger.DEBUG )) log.log(DEBUG, "found NameComment at " + k); retval.commentRecords.put(ncr.getNameText(), ncr); - default : + break; + default: + if (log.check( POILogger.DEBUG )) + log.log(DEBUG, "ignoring record (sid=" + rec.getSid() + ") at " + k); + break; } records.add(rec); } @@ -352,6 +356,8 @@ public final class InternalWorkbook { case HyperlinkRecord.sid: retval.hyperlinks.add((HyperlinkRecord)rec); break; + default: + break; } } @@ -1682,6 +1688,9 @@ public final class InternalWorkbook { retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; + + default: + throw new IllegalStateException("Unrecognized format id: " + id); } return retval; } @@ -1754,6 +1763,9 @@ public final class InternalWorkbook { retval.setBuiltinStyle(5); retval.setOutlineStyleLevel(( byte ) 0xffffffff); break; + + default: + throw new IllegalStateException("Unrecognized style id: " + id); } return retval; } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index e31f2f5808..6e9911be34 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -186,6 +186,9 @@ public class HSSFCell implements Cell { case CELL_TYPE_FORMULA : _stringValue=new HSSFRichTextString(((FormulaRecordAggregate) cval).getStringValue()); break; + + default : + break; } } @@ -422,6 +425,8 @@ public class HSSFCell implements Cell { errRec.setRow(row); _record = errRec; break; + default : + throw new IllegalStateException("Invalid cell type: " + cellType); } if (cellType != _cellType && _cellType!=-1 ) // Special Value to indicate an uninitialized Cell @@ -1088,6 +1093,8 @@ public class HSSFCell implements Cell { case HSSFHyperlink.LINK_DOCUMENT: link.setLabel("place"); break; + default: + break; } List records = _sheet.getSheet().getRecords(); diff --git a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java index eff2f218d3..6000485122 100644 --- a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java +++ b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java @@ -409,6 +409,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter triplet.bold = true; break; case HSSFFont.BOLDWEIGHT_NORMAL: + default: triplet.bold = false; break; } -- 2.39.5