Author: fanningpj
Date: Fri Apr 19 14:12:13 2024
New Revision: 1917154
URL: http://svn.apache.org/viewvc?rev=1917154&view=rev
Log:
refactor code that removes parts
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/ReferenceRelationship.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/ReferenceRelationship.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/ReferenceRelationship.java?rev=1917154&r1=1917153&r2=1917154&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/ReferenceRelationship.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/ooxml/ReferenceRelationship.java
Fri Apr 19 14:12:13 2024
@@ -47,7 +47,7 @@ public abstract class ReferenceRelations
protected ReferenceRelationship(POIXMLDocumentPart container, URI
targetUri, boolean isExternal, String relationshipType, String id) {
if (targetUri == null) {
- throw new IllegalArgumentException("targetUri");
+ throw new NullPointerException("targetUri cannot be null");
}
this.container = container;
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java?rev=1917154&r1=1917153&r2=1917154&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
Fri Apr 19 14:12:13 2024
@@ -1025,7 +1025,6 @@ public abstract class OPCPackage impleme
if (this.partList.containsKey(partName)) {
this.partList.get(partName).setDeleted(true);
this.removePartImpl(partName);
- this.partList.remove(partName);
} else {
this.removePartImpl(partName);
}
@@ -1551,8 +1550,16 @@ public abstract class OPCPackage impleme
*
* @param partName
* The URI of the part to delete.
+ * @throws IllegalArgumentException if the partName is null.
+ * @throws InvalidOperationException if the package is in read-only mode.
*/
- protected abstract void removePartImpl(PackagePartName partName);
+ protected void removePartImpl(PackagePartName partName) {
+ if (partName == null) {
+ throw new IllegalArgumentException("partName cannot be null");
+ }
+ throwExceptionIfReadOnly();
+ this.partList.remove(partName);
+ }
/**
* Flush the package but not save.
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java?rev=1917154&r1=1917153&r2=1917154&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
Fri Apr 19 14:12:13 2024
@@ -85,18 +85,20 @@ public final class PackageRelationship {
/**
* Constructor.
+ *
+ * @throws NullPointerException if inputs are null
*/
public PackageRelationship(OPCPackage pkg, PackagePart sourcePart,
URI targetUri, TargetMode targetMode, String relationshipType,
String id) {
if (pkg == null)
- throw new IllegalArgumentException("pkg");
+ throw new NullPointerException("pkg cannot be null");
if (targetUri == null)
- throw new IllegalArgumentException("targetUri");
+ throw new NullPointerException("targetUri cannot be null");
if (relationshipType == null)
- throw new IllegalArgumentException("relationshipType");
+ throw new NullPointerException("relationshipType cannot be null");
if (id == null)
- throw new IllegalArgumentException("id");
+ throw new NullPointerException("id cannot be null");
this.container = pkg;
this.source = sourcePart;
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java?rev=1917154&r1=1917153&r2=1917154&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
Fri Apr 19 14:12:13 2024
@@ -401,11 +401,11 @@ public final class ZipPackage extends OP
protected PackagePart createPartImpl(PackagePartName partName,
String contentType, boolean loadRelationships) {
if (contentType == null) {
- throw new IllegalArgumentException("contentType");
+ throw new IllegalArgumentException("contentType cannot be null");
}
if (partName == null) {
- throw new IllegalArgumentException("partName");
+ throw new IllegalArgumentException("partName cannot be null");
}
try {
@@ -424,19 +424,6 @@ public final class ZipPackage extends OP
}
}
- /**
- * Delete a part from the package
- *
- * @throws IllegalArgumentException
- * Throws if the part URI is null or invalid.
- */
- @Override
- protected void removePartImpl(PackagePartName partName) {
- if (partName == null) {
- throw new IllegalArgumentException("partUri");
- }
- }
-
/**
* Flush the package. Do nothing.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]