diff --git a/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java b/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java index d6a7c46d7e..2497eb43cf 100644 --- a/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java @@ -35,10 +35,8 @@ import org.apache.poi.extractor.POITextExtractor; import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor; import org.apache.poi.hssf.extractor.EventBasedExcelExtractor; import org.apache.poi.ooxml.POIXMLException; -import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.ss.extractor.ExcelExtractor; import org.apache.poi.util.IOUtils; -import org.apache.xmlbeans.XmlException; /** * Base class with things that can be run for any supported file handler @@ -161,7 +159,7 @@ public abstract class AbstractFileHandler implements FileHandler { } } - private void handleExtractingAsStream(File file) throws IOException, OpenXML4JException, XmlException { + private void handleExtractingAsStream(File file) throws IOException { try (InputStream stream = new FileInputStream(file)) { try (POITextExtractor streamExtractor = ExtractorFactory.createExtractor(stream)) { assertNotNull(streamExtractor); diff --git a/src/java/org/apache/poi/common/usermodel/Hyperlink.java b/src/java/org/apache/poi/common/usermodel/Hyperlink.java index 0673ab3950..708f08df5d 100644 --- a/src/java/org/apache/poi/common/usermodel/Hyperlink.java +++ b/src/java/org/apache/poi/common/usermodel/Hyperlink.java @@ -16,45 +16,43 @@ ==================================================================== */ package org.apache.poi.common.usermodel; -import org.apache.poi.util.Removal; - /** * Represents a hyperlink. */ public interface Hyperlink { - + /** * Hyperlink address. Depending on the hyperlink type it can be URL, e-mail, path to a file, etc. * * @return the address of this hyperlink */ - public String getAddress(); + String getAddress(); /** * Hyperlink address. Depending on the hyperlink type it can be URL, e-mail, path to a file, etc. * * @param address the address of this hyperlink */ - public void setAddress(String address); + void setAddress(String address); /** * Return text label for this hyperlink * * @return text to display */ - public String getLabel(); + String getLabel(); /** * Sets text label for this hyperlink * * @param label text label for this hyperlink */ - public void setLabel(String label); + void setLabel(String label); /** * Return the type of this hyperlink * * @return the type of this hyperlink */ - public HyperlinkType getType(); + HyperlinkType getType(); } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java index 6a95fcee5f..203d5c18f2 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java @@ -1668,4 +1668,15 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { * Has close been called already? */ public abstract boolean isClosed(); + + @Override + public String toString() { + return "OPCPackage{" + + "packageAccess=" + packageAccess + + ", relationships=" + relationships + + ", packageProperties=" + packageProperties + + ", isDirty=" + isDirty + + //", originalPackagePath='" + originalPackagePath + '\'' + + '}'; + } } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java index 0fdacdd214..4956032f67 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java @@ -51,7 +51,7 @@ public abstract class PackagePart implements RelationshipSource, Comparable - OPCPackage.open(POIDataSamples.getOpenXML4JInstance().openResourceAsStream(filename)), - "A package implementer shall neither create nor recognize a part with a part name derived from another" + - " part name by appending segments to it. [M1.11]" + OPCPackage.open(POIDataSamples.getOpenXML4JInstance().openResourceAsStream(filename)), + "A package implementer shall neither create nor recognize a part with a part name derived from another" + + " part name by appending segments to it. [M1.11]" ); } @@ -107,8 +108,8 @@ class TestOPCCompliancePackageModel { pkg.createPart(name1, ContentTypes.XML); assertThrows(PartAlreadyExistsException.class, () -> pkg.createPart(name2, ContentTypes.XML), - "Packages shall not contain equivalent part names and package implementers shall neither create nor " + - "recognize packages with equivalent part names. [M1.12]" + "Packages shall not contain equivalent part names and package implementers shall neither create nor " + + "recognize packages with equivalent part names. [M1.12]" ); pkg.revert(); } @@ -125,8 +126,8 @@ class TestOPCCompliancePackageModel { PackagePartName partName = PackagingURIHelper.createPartName("/word/document.xml"); pkg.createPart(partName, ContentTypes.XML); assertThrows(InvalidOperationException.class, () -> pkg.createPart(partName, ContentTypes.XML), - "Packages shall not contain equivalent part names and package implementers shall neither create nor " + - "recognize packages with equivalent part names. [M1.12]" + "Packages shall not contain equivalent part names and package implementers shall neither create nor " + + "recognize packages with equivalent part names. [M1.12]" ); pkg.revert(); } @@ -134,7 +135,7 @@ class TestOPCCompliancePackageModel { /** * Try to add a relationship to a relationship part. - * + *

* Check rule M1.25: The Relationships part shall not have relationships to * any other part. Package implementers shall enforce this requirement upon * the attempt to create such a relationship and shall treat any such @@ -146,10 +147,21 @@ class TestOPCCompliancePackageModel { PackagePartName name1 = PackagingURIHelper.createPartName("/test/_rels/document.xml.rels"); assertThrows(InvalidOperationException.class, - () -> pkg.addRelationship(name1, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT), - "The Relationships part shall not have relationships to any other part [M1.25]" + () -> pkg.addRelationship(name1, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT), + "The Relationships part shall not have relationships to any other part [M1.25]" ); pkg.revert(); } } + + @Test + void testToString() throws IOException { + try (OPCPackage pkg = OPCPackage.create(TESTFILE)) { + assertEquals("OPCPackage{" + + "packageAccess=READ_WRITE, " + + "relationships=null, " + + "packageProperties=Name: /docProps/core.xml - Content Type: application/vnd.openxmlformats-package.core-properties+xml, " + + "isDirty=false}", pkg.toString()); + } + } }