From fb2f23678fd1fe93207133e258823f5f520790ec Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 4 Mar 2018 13:33:31 +0000 Subject: [PATCH] Some IntelliJ and Javadoc fixes git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825817 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/openxml4j/opc/PackagingURIHelper.java | 4 ++-- .../apache/poi/openxml4j/opc/internal/ZipHelper.java | 12 ++++-------- .../apache/poi/xwpf/usermodel/TestXWPFFootnotes.java | 2 +- .../poi/hssf/usermodel/TestEscherGraphics2d.java | 4 ++-- .../apache/poi/ss/formula/TestMissingWorkbook.java | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java index 1c7f29cf6..83f37ef91 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java @@ -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('\\', '/'); } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java index b913196e4..a5c741e28 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java @@ -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 diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java index 7025a266c..08e439310 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java @@ -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++; } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java index b0b4293a7..130e0fd84 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java @@ -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 diff --git a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java b/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java index 1a8975c9b..d1a5f0210 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java +++ b/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java @@ -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)); } }