\r
protected ReferenceRelationship(POIXMLDocumentPart container, URI targetUri, boolean isExternal, String relationshipType, String id) {\r
if (targetUri == null) {\r
- throw new IllegalArgumentException("targetUri");\r
+ throw new NullPointerException("targetUri cannot be null");\r
}\r
\r
this.container = container;\r
if (this.partList.containsKey(partName)) {
this.partList.get(partName).setDeleted(true);
this.removePartImpl(partName);
- this.partList.remove(partName);
} else {
this.removePartImpl(partName);
}
*
* @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.
/**
* 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;
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 {
}
}
- /**
- * 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.
*/