mirror of https://github.com/apache/poi.git
sonar fix
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
84d15fdcb7
commit
25902c6428
|
@ -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,7 +417,8 @@ 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.
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException {
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
if (this.packageAccess == PackageAccess.READ) {
|
if (this.packageAccess == PackageAccess.READ) {
|
||||||
logger.log(POILogger.WARN,
|
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 !");
|
"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);
|
String name = path.substring(path.lastIndexOf(File.separatorChar) + 1);
|
||||||
|
|
||||||
FileInputStream is = new FileInputStream(path);
|
FileInputStream is = new FileInputStream(path);
|
||||||
addThumbnail(name, is);
|
try {
|
||||||
is.close();
|
addThumbnail(name, is);
|
||||||
|
} finally {
|
||||||
|
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
|
||||||
|
@ -1150,7 +1151,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||||
* ID of the relationship.
|
* ID of the relationship.
|
||||||
* @see PackageRelationshipTypes
|
* @see PackageRelationshipTypes
|
||||||
*/
|
*/
|
||||||
public PackageRelationship addRelationship(PackagePartName targetPartName,
|
@Override
|
||||||
|
public PackageRelationship addRelationship(PackagePartName targetPartName,
|
||||||
TargetMode targetMode, String relationshipType, String relID) {
|
TargetMode targetMode, String relationshipType, String relID) {
|
||||||
/* Check OPC compliance */
|
/* Check OPC compliance */
|
||||||
|
|
||||||
|
@ -1197,7 +1199,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||||
* Relationship type.
|
* Relationship type.
|
||||||
* @see PackageRelationshipTypes
|
* @see PackageRelationshipTypes
|
||||||
*/
|
*/
|
||||||
public PackageRelationship addRelationship(PackagePartName targetPartName,
|
@Override
|
||||||
|
public PackageRelationship addRelationship(PackagePartName targetPartName,
|
||||||
TargetMode targetMode, String relationshipType) {
|
TargetMode targetMode, String relationshipType) {
|
||||||
return this.addRelationship(targetPartName, targetMode,
|
return this.addRelationship(targetPartName, targetMode,
|
||||||
relationshipType, null);
|
relationshipType, null);
|
||||||
|
@ -1218,7 +1221,8 @@ 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)
|
||||||
*/
|
*/
|
||||||
public PackageRelationship addExternalRelationship(String target,
|
@Override
|
||||||
|
public PackageRelationship addExternalRelationship(String target,
|
||||||
String relationshipType) {
|
String relationshipType) {
|
||||||
return addExternalRelationship(target, relationshipType, null);
|
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,
|
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String,
|
||||||
* java.lang.String)
|
* java.lang.String)
|
||||||
*/
|
*/
|
||||||
public PackageRelationship addExternalRelationship(String target,
|
@Override
|
||||||
|
public PackageRelationship addExternalRelationship(String target,
|
||||||
String relationshipType, String id) {
|
String relationshipType, String id) {
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
throw new IllegalArgumentException("target");
|
throw new IllegalArgumentException("target");
|
||||||
|
@ -1269,7 +1274,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||||
* @param id
|
* @param id
|
||||||
* Id of the relationship to delete.
|
* Id of the relationship to delete.
|
||||||
*/
|
*/
|
||||||
public void removeRelationship(String id) {
|
@Override
|
||||||
|
public void removeRelationship(String id) {
|
||||||
if (relationships != null) {
|
if (relationships != null) {
|
||||||
relationships.removeRelationship(id);
|
relationships.removeRelationship(id);
|
||||||
this.isDirty = true;
|
this.isDirty = true;
|
||||||
|
@ -1283,7 +1289,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||||
* @throws OpenXML4JException
|
* @throws OpenXML4JException
|
||||||
* @see #getRelationshipsHelper(String)
|
* @see #getRelationshipsHelper(String)
|
||||||
*/
|
*/
|
||||||
public PackageRelationshipCollection getRelationships() {
|
@Override
|
||||||
|
public PackageRelationshipCollection getRelationships() {
|
||||||
return getRelationshipsHelper(null);
|
return getRelationshipsHelper(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1294,7 +1301,8 @@ 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.
|
||||||
*/
|
*/
|
||||||
public PackageRelationshipCollection getRelationshipsByType(
|
@Override
|
||||||
|
public PackageRelationshipCollection getRelationshipsByType(
|
||||||
String relationshipType) {
|
String relationshipType) {
|
||||||
throwExceptionIfWriteOnly();
|
throwExceptionIfWriteOnly();
|
||||||
if (relationshipType == null) {
|
if (relationshipType == null) {
|
||||||
|
@ -1319,7 +1327,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||||
/**
|
/**
|
||||||
* Clear package relationships.
|
* Clear package relationships.
|
||||||
*/
|
*/
|
||||||
public void clearRelationships() {
|
@Override
|
||||||
|
public void clearRelationships() {
|
||||||
if (relationships != null) {
|
if (relationships != null) {
|
||||||
relationships.clear();
|
relationships.clear();
|
||||||
this.isDirty = true;
|
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)
|
* @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);
|
return this.relationships.getRelationshipByID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships()
|
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships()
|
||||||
*/
|
*/
|
||||||
public boolean hasRelationships() {
|
@Override
|
||||||
|
public boolean hasRelationships() {
|
||||||
return (relationships.size() > 0);
|
return (relationships.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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)
|
||||||
*/
|
*/
|
||||||
public boolean isRelationshipExists(PackageRelationship rel) {
|
@Override
|
||||||
|
public boolean isRelationshipExists(PackageRelationship rel) {
|
||||||
for (PackageRelationship r : this.getRelationships()) {
|
for (PackageRelationship r : this.getRelationships()) {
|
||||||
if (r == rel) {
|
if (r == rel) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue