]> source.dussan.org Git - poi.git/commitdiff
[github-345] Use switch instead of if. Thanks to XenoAmess. This closes #345
authorPJ Fanning <fanningpj@apache.org>
Sat, 16 Jul 2022 10:13:18 +0000 (10:13 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 16 Jul 2022 10:13:18 +0000 (10:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902772 13f79535-47bb-0310-9956-ffa450edef68

15 files changed:
poi-examples/src/main/java/org/apache/poi/examples/ss/LoadEmbedded.java
poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/EmbeddedObjects.java
poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ContentTypes.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/ArcTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/Ellipse.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/EllipticalArcTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/InfiniteLine.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/NURBSTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/RelCubBezTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/RelEllipticalArcTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/RelQuadBezTo.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineKnot.java
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/section/geometry/SplineStart.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/RecordUtil.java

index 68ea9229ef5b301e38b3de57a0a018cfd0d364bd..8eabd2ced905b5ada9f61518325c31b4891c5e19 100644 (file)
@@ -68,79 +68,96 @@ public final class LoadEmbedded {
        for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {
            //the OLE2 Class Name of the object
            String oleName = obj.getOLE2ClassName();
-           if (oleName.equals("Worksheet")) {
-               DirectoryNode dn = (DirectoryNode) obj.getDirectory();
-               HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(dn, false);
-               embeddedWorkbook.close();
-           } else if (oleName.equals("Document")) {
-               DirectoryNode dn = (DirectoryNode) obj.getDirectory();
-               HWPFDocument embeddedWordDocument = new HWPFDocument(dn);
-               embeddedWordDocument.close();
-           }  else if (oleName.equals("Presentation")) {
-               DirectoryNode dn = (DirectoryNode) obj.getDirectory();
-               SlideShow<?,?> embeddedSlieShow = new HSLFSlideShow(dn);
-               embeddedSlieShow.close();
-           } else {
-               if(obj.hasDirectoryEntry()){
-                   // The DirectoryEntry is a DocumentNode. Examine its entries to find out what it is
+           switch (oleName) {
+               case "Worksheet": {
                    DirectoryNode dn = (DirectoryNode) obj.getDirectory();
-                   for (Entry entry : dn) {
-                       //System.out.println(oleName + "." + entry.getName());
-                   }
-               } else {
-                   // There is no DirectoryEntry
-                   // Recover the object's data from the HSSFObjectData instance.
-                   byte[] objectData = obj.getObjectData();
+                   HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(dn, false);
+                   embeddedWorkbook.close();
+                   break;
+               }
+               case "Document": {
+                   DirectoryNode dn = (DirectoryNode) obj.getDirectory();
+                   HWPFDocument embeddedWordDocument = new HWPFDocument(dn);
+                   embeddedWordDocument.close();
+                   break;
+               }
+               case "Presentation": {
+                   DirectoryNode dn = (DirectoryNode) obj.getDirectory();
+                   SlideShow<?, ?> embeddedSlieShow = new HSLFSlideShow(dn);
+                   embeddedSlieShow.close();
+                   break;
                }
+               default:
+                   if (obj.hasDirectoryEntry()) {
+                       // The DirectoryEntry is a DocumentNode. Examine its entries to find out what it is
+                       DirectoryNode dn = (DirectoryNode) obj.getDirectory();
+                       for (Entry entry : dn) {
+                           //System.out.println(oleName + "." + entry.getName());
+                       }
+                   } else {
+                       // There is no DirectoryEntry
+                       // Recover the object's data from the HSSFObjectData instance.
+                       byte[] objectData = obj.getObjectData();
+                   }
+                   break;
            }
        }
    }
 
-   public static void loadEmbedded(XSSFWorkbook workbook) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
+   public static void loadEmbedded(XSSFWorkbook workbook) throws IOException, InvalidFormatException,
+           OpenXML4JException, XmlException {
        for (PackagePart pPart : workbook.getAllEmbeddedParts()) {
            String contentType = pPart.getContentType();
-           if (contentType.equals("application/vnd.ms-excel")) {
-               // Excel Workbook - either binary or OpenXML
-               try (InputStream stream = pPart.getInputStream()) {
-                   HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(stream);
-                   embeddedWorkbook.close();
-               }
-           } else if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
-               // Excel Workbook - OpenXML file format
-               try (InputStream stream = pPart.getInputStream()) {
-                   XSSFWorkbook embeddedWorkbook = new XSSFWorkbook(stream);
-                   embeddedWorkbook.close();
-               }
-           } else if (contentType.equals("application/msword")) {
-               // Word Document - binary (OLE2CDF) file format
-               try (InputStream stream = pPart.getInputStream()) {
-                   HWPFDocument document = new HWPFDocument(stream);
-                   document.close();
-               }
-           } else if (contentType.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) {
-               // Word Document - OpenXML file format
-               try (InputStream stream = pPart.getInputStream()) {
-                   XWPFDocument document = new XWPFDocument(stream);
-                   document.close();
-               }
-           } else if (contentType.equals("application/vnd.ms-powerpoint")) {
-               // PowerPoint Document - binary file format
-               try (InputStream stream = pPart.getInputStream()) {
-                   HSLFSlideShow slideShow = new HSLFSlideShow(stream);
-                   slideShow.close();
-               }
-           } else if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) {
-               // PowerPoint Document - OpenXML file format
-               try (InputStream stream = pPart.getInputStream()) {
-                   XMLSlideShow slideShow = new XMLSlideShow(stream);
-                   slideShow.close();
-               }
-           } else {
-               // Any other type of embedded object.
-               System.out.println("Unknown Embedded Document: " + contentType);
-               try (InputStream inputStream = pPart.getInputStream()) {
+           switch (contentType) {
+               case "application/vnd.ms-excel":
+                   // Excel Workbook - either binary or OpenXML
+                   try (InputStream stream = pPart.getInputStream()) {
+                       HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(stream);
+                       embeddedWorkbook.close();
+                   }
+                   break;
+               case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
+                   // Excel Workbook - OpenXML file format
+                   try (InputStream stream = pPart.getInputStream()) {
+                       XSSFWorkbook embeddedWorkbook = new XSSFWorkbook(stream);
+                       embeddedWorkbook.close();
+                   }
+                   break;
+               case "application/msword":
+                   // Word Document - binary (OLE2CDF) file format
+                   try (InputStream stream = pPart.getInputStream()) {
+                       HWPFDocument document = new HWPFDocument(stream);
+                       document.close();
+                   }
+                   break;
+               case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
+                   // Word Document - OpenXML file format
+                   try (InputStream stream = pPart.getInputStream()) {
+                       XWPFDocument document = new XWPFDocument(stream);
+                       document.close();
+                   }
+                   break;
+               case "application/vnd.ms-powerpoint":
+                   // PowerPoint Document - binary file format
+                   try (InputStream stream = pPart.getInputStream()) {
+                       HSLFSlideShow slideShow = new HSLFSlideShow(stream);
+                       slideShow.close();
+                   }
+                   break;
+               case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
+                   // PowerPoint Document - OpenXML file format
+                   try (InputStream stream = pPart.getInputStream()) {
+                       XMLSlideShow slideShow = new XMLSlideShow(stream);
+                       slideShow.close();
+                   }
+                   break;
+               default:
+                   // Any other type of embedded object.
+                   System.out.println("Unknown Embedded Document: " + contentType);
+                   try (InputStream inputStream = pPart.getInputStream()) {
 
-               }
+                   }
+                   break;
            }
        }
    }
index b4af95c5ae55cbdd271d3e3de97e18f5a8352333..93f12a0d762d6b584d072552f70658be2fb65584 100644 (file)
@@ -37,27 +37,35 @@ public class EmbeddedObjects {
                 String contentType = pPart.getContentType();
                 try (InputStream is = pPart.getInputStream()) {
                     Closeable document;
-                    if (contentType.equals("application/vnd.ms-excel")) {
-                        // Excel Workbook - either binary or OpenXML
-                        document = new HSSFWorkbook(is);
-                    } else if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
-                        // Excel Workbook - OpenXML file format
-                        document = new XSSFWorkbook(is);
-                    } else if (contentType.equals("application/msword")) {
-                        // Word Document - binary (OLE2CDF) file format
-                        document = new HWPFDocument(is);
-                    } else if (contentType.equals("application/vnd.openxmlformats-officedocument.wordprocessingml.document")) {
-                        // Word Document - OpenXML file format
-                        document = new XWPFDocument(is);
-                    } else if (contentType.equals("application/vnd.ms-powerpoint")) {
-                        // PowerPoint Document - binary file format
-                        document = new HSLFSlideShow(is);
-                    } else if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) {
-                        // PowerPoint Document - OpenXML file format
-                        document = new XMLSlideShow(is);
-                    } else {
-                        // Any other type of embedded object.
-                        document = is;
+                    switch (contentType) {
+                        case "application/vnd.ms-excel":
+                            // Excel Workbook - either binary or OpenXML
+                            document = new HSSFWorkbook(is);
+                            break;
+                        case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
+                            // Excel Workbook - OpenXML file format
+                            document = new XSSFWorkbook(is);
+                            break;
+                        case "application/msword":
+                            // Word Document - binary (OLE2CDF) file format
+                            document = new HWPFDocument(is);
+                            break;
+                        case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
+                            // Word Document - OpenXML file format
+                            document = new XWPFDocument(is);
+                            break;
+                        case "application/vnd.ms-powerpoint":
+                            // PowerPoint Document - binary file format
+                            document = new HSLFSlideShow(is);
+                            break;
+                        case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
+                            // PowerPoint Document - OpenXML file format
+                            document = new XMLSlideShow(is);
+                            break;
+                        default:
+                            // Any other type of embedded object.
+                            document = is;
+                            break;
                     }
                     document.close();
                 }
index bda08f64454f353bd354fe94b0a6179b77ad218d..12dcdb1b129c3ce5593a2eff025183570a684289 100644 (file)
@@ -111,20 +111,22 @@ public final class ContentTypes {
     public static String getContentTypeFromFileExtension(String filename) {
         String extension = filename.substring(filename.lastIndexOf('.') + 1)
                 .toLowerCase(Locale.ROOT);
-        if (extension.equals(EXTENSION_JPG_1)
-                || extension.equals(EXTENSION_JPG_2))
-            return IMAGE_JPEG;
-        else if (extension.equals(EXTENSION_GIF))
-            return IMAGE_GIF;
-        else if (extension.equals(EXTENSION_PICT))
-            return IMAGE_PICT;
-        else if (extension.equals(EXTENSION_PNG))
-            return IMAGE_PNG;
-        else if (extension.equals(EXTENSION_TIFF))
-            return IMAGE_TIFF;
-        else if (extension.equals(EXTENSION_XML))
-            return XML;
-        else
-            return null;
+        switch (extension) {
+            case EXTENSION_JPG_1:
+            case EXTENSION_JPG_2:
+                return IMAGE_JPEG;
+            case EXTENSION_GIF:
+                return IMAGE_GIF;
+            case EXTENSION_PICT:
+                return IMAGE_PICT;
+            case EXTENSION_PNG:
+                return IMAGE_PNG;
+            case EXTENSION_TIFF:
+                return IMAGE_TIFF;
+            case EXTENSION_XML:
+                return XML;
+            default:
+                return null;
+        }
     }
 }
index aa07938b3e42cf391d7eb4a60c8d8d5d8e7bcb34..a991815c4a915e69b3b916a32134680cd77ba029 100644 (file)
@@ -53,15 +53,19 @@ public class ArcTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in ArcTo row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in ArcTo row");
             }
         }
     }
index 8f509f960761584411c09ea2d108dcd27202e304..703a24b499d3c4b320ec64fa09dfd33ac8c0b5de 100644 (file)
@@ -59,21 +59,28 @@ public class Ellipse implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("C")) {
-                c = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("D")) {
-                d = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in Ellipse row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "C":
+                    c = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "D":
+                    d = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in Ellipse row");
             }
         }
     }
index 2ec09f6b6b89c828d40d5eb999a2d2938df61372..dcce505f642923452665700f7e7350881d3c9c1e 100644 (file)
@@ -71,21 +71,28 @@ public class EllipticalArcTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("C")) {
-                c = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("D")) {
-                d = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in EllipticalArcTo row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "C":
+                    c = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "D":
+                    d = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in EllipticalArcTo row");
             }
         }
     }
index c7383f3cc2dc70ef9cdcd992a32ff3ffb132f471..894bcb3665ba36e28fa023a1eef450975078e7a6 100644 (file)
@@ -61,17 +61,22 @@ public class InfiniteLine implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in InfiniteLine row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in InfiniteLine row");
             }
         }
     }
index 1b9f0f9556ce0875c8a33c9b84b7cba4fe43be0b..e3d6f59eb86b3bd824574b0a633f904fd008bafb 100644 (file)
@@ -68,23 +68,31 @@ public class NURBSTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("C")) {
-                c = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("D")) {
-                d = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("E")) {
-                e = cell.getV();
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in NURBS row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "C":
+                    c = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "D":
+                    d = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "E":
+                    e = cell.getV();
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in NURBS row");
             }
         }
     }
index b64518138b7cc39c45492caa795105eafb7bbd19..70d652bda9d810973e2faa4bda7f1465a1d717ba 100644 (file)
@@ -50,15 +50,19 @@ public class PolyLineTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = cell.getV();
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in ArcTo row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = cell.getV();
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in ArcTo row");
             }
         }
     }
index 847dce06b774a6b86c69efad692888fae6aeb322..3e1d294387783ff99055b58f15895f5069ee00cc 100644 (file)
@@ -66,21 +66,28 @@ public class RelCubBezTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("C")) {
-                c = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("D")) {
-                d = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in RelCubBezTo row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "C":
+                    c = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "D":
+                    d = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in RelCubBezTo row");
             }
         }
     }
index 9e11bb31a6637844819b6288216f6eb0a1327473..229896d01aa775af3ce0bbce524da39428d251e4 100644 (file)
@@ -63,21 +63,28 @@ public class RelEllipticalArcTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("C")) {
-                c = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("D")) {
-                d = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in RelEllipticalArcTo row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "C":
+                    c = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "D":
+                    d = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in RelEllipticalArcTo row");
             }
         }
     }
index e6037279eaca79de2fc303e1a2a826737434ec20..b5127161200938bf3a16bf1f6767593b79c16e94 100644 (file)
@@ -62,17 +62,22 @@ public class RelQuadBezTo implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in RelQuadBezTo row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in RelQuadBezTo row");
             }
         }
     }
index bd006ac60ec608149552d0c9754ab7e030e32ffc..0e0bfccade8caff1336da4c8533f6ff278acfa8c 100644 (file)
@@ -53,15 +53,19 @@ public class SplineKnot implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in SplineKnot row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in SplineKnot row");
             }
         }
     }
index c6e0332d6c56d5ecb324c73494f1508c6adfeb22..8e3cf929342ee241b7146d94578982c113963790 100644 (file)
@@ -61,21 +61,28 @@ public class SplineStart implements GeometryRow {
         for (CellType cell : row.getCellArray()) {
             String cellName = cell.getN();
 
-            if (cellName.equals("X")) {
-                x = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("Y")) {
-                y = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("A")) {
-                a = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("B")) {
-                b = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("C")) {
-                c = XDGFCell.parseDoubleValue(cell);
-            } else if (cellName.equals("D")) {
-                d = XDGFCell.parseIntegerValue(cell);
-            } else {
-                throw new POIXMLException("Invalid cell '" + cellName
-                        + "' in SplineStart row");
+            switch (cellName) {
+                case "X":
+                    x = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "Y":
+                    y = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "A":
+                    a = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "B":
+                    b = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "C":
+                    c = XDGFCell.parseDoubleValue(cell);
+                    break;
+                case "D":
+                    d = XDGFCell.parseIntegerValue(cell);
+                    break;
+                default:
+                    throw new POIXMLException("Invalid cell '" + cellName
+                            + "' in SplineStart row");
             }
         }
     }
index cd11e5d8790d42949be26259510c1a0d3204147c..6c401cc512bd2c2d63cc6efbd19d7919dd1ef259 100644 (file)
@@ -107,12 +107,17 @@ public class RecordUtil
         byte numBits = 0;
         int mask = (int) Long.parseLong( bitMask.substring( 2 ), 16 );
 
-        if ( parentType.equals( "byte" ) )
-            parentSize = 8;
-        else if ( parentType.equals( "short" ) )
-            parentSize = 16;
-        else if ( parentType.equals( "int" ) )
-            parentSize = 32;
+        switch (parentType) {
+            case "byte":
+                parentSize = 8;
+                break;
+            case "short":
+                parentSize = 16;
+                break;
+            case "int":
+                parentSize = 32;
+                break;
+        }
 
         for ( int x = 0; x < parentSize; x++ )
         {