]> source.dussan.org Git - poi.git/commitdiff
Some IntelliJ and Javadoc fixes
authorDominik Stadler <centic@apache.org>
Sun, 4 Mar 2018 13:33:31 +0000 (13:33 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 4 Mar 2018 13:33:31 +0000 (13:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825817 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java
src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java
src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java

index 1c7f29cf6fc83f15a0ddc58bd1cd26f451524bf5..83f37ef91853a3a05ced4ec857bbda4392024c91 100644 (file)
@@ -236,7 +236,7 @@ public final class PackagingURIHelper {
         * @return the combined URI
         */
        public static URI combine(URI prefix, URI suffix) {
-               URI retUri = null;
+               URI retUri;
                try {
                        retUri = new URI(combine(prefix.getPath(), suffix.getPath()));
                } catch (URISyntaxException e) {
@@ -694,7 +694,7 @@ public final class PackagingURIHelper {
      */
     public static URI toURI(String value) throws URISyntaxException  {
         //5. Convert all back slashes to forward slashes
-        if (value.indexOf("\\") != -1) {
+        if (value.contains("\\")) {
              value = value.replace('\\', '/');
         }
 
index b913196e4a42cd92da993d2d928c86ebee2e741b..a5c741e287e1acfdc261472f66d1d97e32e13669 100644 (file)
@@ -31,7 +31,6 @@ import java.util.zip.ZipInputStream;
 
 import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
 import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
 import org.apache.poi.openxml4j.opc.ZipPackage;
@@ -39,7 +38,6 @@ import org.apache.poi.openxml4j.util.ZipSecureFile;
 import org.apache.poi.openxml4j.util.ZipSecureFile.ThresholdInputStream;
 import org.apache.poi.poifs.filesystem.FileMagic;
 import org.apache.poi.util.Internal;
-import org.apache.poi.util.Removal;
 
 @Internal
 public final class ZipHelper {
@@ -59,8 +57,9 @@ public final class ZipHelper {
     /**
      * Retrieve the zip entry of the core properties part.
      *
-     * @throws OpenXML4JException
-     *             Throws if internal error occurs.
+     * @throws IllegalArgumentException If the relationship for
+     *      core properties cannot be read or an invalid name is
+     *      specified in the properties.
      */
     public static ZipEntry getCorePropertiesZipEntry(ZipPackage pkg) {
         PackageRelationship corePropsRel = pkg.getRelationshipsByType(
@@ -221,11 +220,8 @@ public final class ZipHelper {
         }
         
         // Peek at the first few bytes to sanity check
-        FileInputStream input = new FileInputStream(file);
-        try {
+        try (FileInputStream input = new FileInputStream(file)) {
             verifyZipHeader(input);
-        } finally {
-            input.close();
         }
 
         // Open as a proper zip file
index 7025a266c7b5994e942566d8b7d41177c937ed29..08e439310d85bd43f78200566699151cfd3538a2 100644 (file)
@@ -56,7 +56,7 @@ public class TestXWPFFootnotes extends TestCase {
             for (IBodyElement e : fn.getBodyElements()) {
                 if (e instanceof XWPFParagraph) {
                     String txt = ((XWPFParagraph) e).getText();
-                    if (txt.indexOf("Footnote_sdt") > -1) {
+                    if (txt.contains("Footnote_sdt")) {
                         hits++;
                     }
                 }
index b0b4293a7477251147386f4171ebe5fb72cb357b..130e0fd84b5cd56627778e1757e6027e90fc32e9 100644 (file)
@@ -109,7 +109,7 @@ public final class TestEscherGraphics2d {
 
        @Test
     public void testSetFont() {
-               Font f = new Font("Helvetica", 0, 12);
+               Font f = new Font("Helvetica", Font.PLAIN, 12);
                graphics.setFont(f);
                assertEquals(f, graphics.getFont());
        }
@@ -133,7 +133,7 @@ public final class TestEscherGraphics2d {
 
        private boolean isDialogPresent() {
                String fontDebugStr = graphics.getFont().toString();
-               return fontDebugStr.indexOf("dialog") != -1 || fontDebugStr.indexOf("Dialog") != -1;
+               return fontDebugStr.contains("dialog") || fontDebugStr.contains("Dialog");
        }
 
        @Test
index 1a8975c9b45d01f39e6166102b2f8853aa66b510..d1a5f02101344eebe51b09b1f59f9f175414f609 100644 (file)
@@ -72,7 +72,7 @@ public class TestMissingWorkbook extends TestCase {
                        evaluator.evaluateFormulaCell(lA1Cell);
                        fail("Missing external workbook reference exception expected!");
                }catch(RuntimeException re) {
-                       assertTrue("Unexpected exception: " + re, re.getMessage().indexOf(SOURCE_DUMMY_WORKBOOK_FILENAME) != -1);
+                       assertTrue("Unexpected exception: " + re, re.getMessage().contains(SOURCE_DUMMY_WORKBOOK_FILENAME));
                }
        }