aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/openxml4j
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-06-22 22:27:53 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-06-22 22:27:53 +0000
commit25902c642893c07fcc857f4586c1afec3f6f4c9b (patch)
treed20aae288999d7ee31dbbfee06352841fae10358 /src/ooxml/java/org/apache/poi/openxml4j
parent84d15fdcb7d21bb7f1a2758156ab1a40d2de079a (diff)
downloadpoi-25902c642893c07fcc857f4586c1afec3f6f4c9b.tar.gz
poi-25902c642893c07fcc857f4586c1afec3f6f4c9b.zip
sonar fix
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749795 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/openxml4j')
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java46
1 files changed, 29 insertions, 17 deletions
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 d5f5d03ae2..1b15c407d1 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
@@ -59,9 +59,6 @@ import org.apache.poi.util.POILogger;
/**
* Represents a container that can store multiple data objects.
- *
- * @author Julien Chable, CDubet
- * @version 0.1
*/
public abstract class OPCPackage implements RelationshipSource, Closeable {
@@ -420,7 +417,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @throws IOException
* If an IO exception occur during the saving process.
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
if (this.packageAccess == PackageAccess.READ) {
logger.log(POILogger.WARN,
"The close() method is intended to SAVE a package. This package is open in READ ONLY mode, use the revert() method instead !");
@@ -484,8 +482,11 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
String name = path.substring(path.lastIndexOf(File.separatorChar) + 1);
FileInputStream is = new FileInputStream(path);
- addThumbnail(name, is);
- is.close();
+ try {
+ addThumbnail(name, is);
+ } finally {
+ is.close();
+ }
}
/**
* Add a thumbnail to the package. This method is provided to make easier
@@ -1150,7 +1151,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* ID of the relationship.
* @see PackageRelationshipTypes
*/
- public PackageRelationship addRelationship(PackagePartName targetPartName,
+ @Override
+ public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode, String relationshipType, String relID) {
/* Check OPC compliance */
@@ -1197,7 +1199,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* Relationship type.
* @see PackageRelationshipTypes
*/
- public PackageRelationship addRelationship(PackagePartName targetPartName,
+ @Override
+ public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode, String relationshipType) {
return this.addRelationship(targetPartName, targetMode,
relationshipType, null);
@@ -1218,7 +1221,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String,
* java.lang.String)
*/
- public PackageRelationship addExternalRelationship(String target,
+ @Override
+ public PackageRelationship addExternalRelationship(String target,
String relationshipType) {
return addExternalRelationship(target, relationshipType, null);
}
@@ -1240,7 +1244,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String,
* java.lang.String)
*/
- public PackageRelationship addExternalRelationship(String target,
+ @Override
+ public PackageRelationship addExternalRelationship(String target,
String relationshipType, String id) {
if (target == null) {
throw new IllegalArgumentException("target");
@@ -1269,7 +1274,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @param id
* Id of the relationship to delete.
*/
- public void removeRelationship(String id) {
+ @Override
+ public void removeRelationship(String id) {
if (relationships != null) {
relationships.removeRelationship(id);
this.isDirty = true;
@@ -1283,7 +1289,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @throws OpenXML4JException
* @see #getRelationshipsHelper(String)
*/
- public PackageRelationshipCollection getRelationships() {
+ @Override
+ public PackageRelationshipCollection getRelationships() {
return getRelationshipsHelper(null);
}
@@ -1294,7 +1301,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* The filter specifying the relationship type.
* @return All relationships with the specified relationship type.
*/
- public PackageRelationshipCollection getRelationshipsByType(
+ @Override
+ public PackageRelationshipCollection getRelationshipsByType(
String relationshipType) {
throwExceptionIfWriteOnly();
if (relationshipType == null) {
@@ -1319,7 +1327,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* Clear package relationships.
*/
- public void clearRelationships() {
+ @Override
+ public void clearRelationships() {
if (relationships != null) {
relationships.clear();
this.isDirty = true;
@@ -1342,21 +1351,24 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationship(java.lang.String)
*/
- public PackageRelationship getRelationship(String id) {
+ @Override
+ public PackageRelationship getRelationship(String id) {
return this.relationships.getRelationshipByID(id);
}
/**
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships()
*/
- public boolean hasRelationships() {
+ @Override
+ public boolean hasRelationships() {
return (relationships.size() > 0);
}
/**
* @see org.apache.poi.openxml4j.opc.RelationshipSource#isRelationshipExists(org.apache.poi.openxml4j.opc.PackageRelationship)
*/
- public boolean isRelationshipExists(PackageRelationship rel) {
+ @Override
+ public boolean isRelationshipExists(PackageRelationship rel) {
for (PackageRelationship r : this.getRelationships()) {
if (r == rel) {
return true;