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