sonar fix

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-06-22 22:27:53 +00:00
parent 84d15fdcb7
commit 25902c6428
1 changed files with 29 additions and 17 deletions

View File

@ -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,6 +417,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @throws IOException
* If an IO exception occur during the saving process.
*/
@Override
public void close() throws IOException {
if (this.packageAccess == PackageAccess.READ) {
logger.log(POILogger.WARN,
@ -484,9 +482,12 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
String name = path.substring(path.lastIndexOf(File.separatorChar) + 1);
FileInputStream is = new FileInputStream(path);
try {
addThumbnail(name, is);
} finally {
is.close();
}
}
/**
* Add a thumbnail to the package. This method is provided to make easier
* the addition of a thumbnail in a package. You can do the same work by
@ -1150,6 +1151,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* ID of the relationship.
* @see PackageRelationshipTypes
*/
@Override
public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode, String relationshipType, String relID) {
/* Check OPC compliance */
@ -1197,6 +1199,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* Relationship type.
* @see PackageRelationshipTypes
*/
@Override
public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode, String relationshipType) {
return this.addRelationship(targetPartName, targetMode,
@ -1218,6 +1221,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String,
* java.lang.String)
*/
@Override
public PackageRelationship addExternalRelationship(String target,
String relationshipType) {
return addExternalRelationship(target, relationshipType, null);
@ -1240,6 +1244,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String,
* java.lang.String)
*/
@Override
public PackageRelationship addExternalRelationship(String target,
String relationshipType, String id) {
if (target == null) {
@ -1269,6 +1274,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @param id
* Id of the relationship to delete.
*/
@Override
public void removeRelationship(String id) {
if (relationships != null) {
relationships.removeRelationship(id);
@ -1283,6 +1289,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @throws OpenXML4JException
* @see #getRelationshipsHelper(String)
*/
@Override
public PackageRelationshipCollection getRelationships() {
return getRelationshipsHelper(null);
}
@ -1294,6 +1301,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* The filter specifying the relationship type.
* @return All relationships with the specified relationship type.
*/
@Override
public PackageRelationshipCollection getRelationshipsByType(
String relationshipType) {
throwExceptionIfWriteOnly();
@ -1319,6 +1327,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* Clear package relationships.
*/
@Override
public void clearRelationships() {
if (relationships != null) {
relationships.clear();
@ -1342,6 +1351,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationship(java.lang.String)
*/
@Override
public PackageRelationship getRelationship(String id) {
return this.relationships.getRelationshipByID(id);
}
@ -1349,6 +1359,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships()
*/
@Override
public boolean hasRelationships() {
return (relationships.size() > 0);
}
@ -1356,6 +1367,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* @see org.apache.poi.openxml4j.opc.RelationshipSource#isRelationshipExists(org.apache.poi.openxml4j.opc.PackageRelationship)
*/
@Override
public boolean isRelationshipExists(PackageRelationship rel) {
for (PackageRelationship r : this.getRelationships()) {
if (r == rel) {