aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2009-08-18 05:29:53 +0000
committerJosh Micich <josh@apache.org>2009-08-18 05:29:53 +0000
commita8957e80fae34eb8143f67bd9d01901b56f31cbc (patch)
tree3defe1dd290f85cdc71c765983c5ad4d0227a4ad /src/ooxml/java/org
parente918a0cd0d50a3891a707f03dadee849fc7184f7 (diff)
downloadpoi-a8957e80fae34eb8143f67bd9d01901b56f31cbc.tar.gz
poi-a8957e80fae34eb8143f67bd9d01901b56f31cbc.zip
Fixing compiler warnings - unnecessary typecasts
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805284 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org')
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java146
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java166
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java12
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java42
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java31
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java2
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java16
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java36
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java26
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java10
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java5
-rwxr-xr-xsrc/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java2
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java21
13 files changed, 256 insertions, 259 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 4efe6bdd89..5952d9122d 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
@@ -52,7 +52,7 @@ import org.apache.poi.util.POILogFactory;
/**
* Represents a container that can store multiple data objects.
- *
+ *
* @author Julien Chable, CDubet
* @version 0.1
*/
@@ -125,7 +125,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Constructor.
- *
+ *
* @param access
* Package access.
*/
@@ -166,7 +166,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Open a package with read/write permission.
- *
+ *
* @param path
* The document path.
* @return A Package object, else <b>null</b>.
@@ -180,7 +180,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Open a package.
- *
+ *
* @param path
* The document path.
* @param access
@@ -206,11 +206,11 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Open a package.
- *
+ *
* Note - uses quite a bit more memory than {@link #open(String)}, which
* doesn't need to hold the whole zip file in memory, and can take advantage
* of native methods
- *
+ *
* @param in
* The InputStream to read the package from
* @return A PackageBase object
@@ -226,7 +226,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Opens a package if it exists, else it creates one.
- *
+ *
* @param file
* The file to open or to create.
* @return A newly created package if the specified file does not exist,
@@ -246,7 +246,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Creates a new package.
- *
+ *
* @param path
* Path of the document.
* @return A newly created PackageBase ready to use.
@@ -257,7 +257,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Creates a new package.
- *
+ *
* @param file
* Path of the document.
* @return A newly created PackageBase ready to use.
@@ -292,7 +292,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Configure the package.
- *
+ *
* @param pkg
*/
private static void configurePackage(OPCPackage pkg) {
@@ -324,7 +324,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Flush the package : save all.
- *
+ *
* @see #close()
*/
public void flush() {
@@ -339,7 +339,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Close the package and save its content.
- *
+ *
* @throws IOException
* If an IO exception occur during the saving process.
*/
@@ -391,7 +391,7 @@ public abstract class OPCPackage implements RelationshipSource {
* 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
* using the traditionnal relationship and part mechanism.
- *
+ *
* @param path
* The full path to the image file.
*/
@@ -443,7 +443,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Throws an exception if the package access mode is in read only mode
* (PackageAccess.Read).
- *
+ *
* @throws InvalidOperationException
* Throws if a writing operation is done on a read only package.
* @see org.apache.poi.openxml4j.opc.PackageAccess
@@ -458,7 +458,7 @@ public abstract class OPCPackage implements RelationshipSource {
* Throws an exception if the package access mode is in write only mode
* (PackageAccess.Write). This method is call when other methods need write
* right.
- *
+ *
* @throws InvalidOperationException
* Throws if a read operation is done on a write only package.
* @see org.apache.poi.openxml4j.opc.PackageAccess
@@ -471,7 +471,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieves or creates if none exists, core package property part.
- *
+ *
* @return The PackageProperties part of this package.
*/
public PackageProperties getPackageProperties()
@@ -487,7 +487,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieve a part identified by its name.
- *
+ *
* @param partName
* Part name of the part to retrieve.
* @return The part with the specified name, else <code>null</code>.
@@ -511,7 +511,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieve parts by content type.
- *
+ *
* @param contentType
* The content type criteria.
* @return All part associated to the specified content type.
@@ -527,7 +527,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieve parts by relationship type.
- *
+ *
* @param relationshipType
* Relationship type.
* @return All parts which are the target of a relationship with the
@@ -547,7 +547,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Get the target part from the specified relationship.
- *
+ *
* @param partRel
* The part relationship uses to retrieve the part.
*/
@@ -571,7 +571,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Load the parts of the archive if it has not been done yet The
* relationships of each part are not loaded
- *
+ *
* @return All this package's parts.
*/
public ArrayList<PackagePart> getParts() throws InvalidFormatException {
@@ -588,10 +588,10 @@ public abstract class OPCPackage implements RelationshipSource {
PackagePart[] parts = this.getPartsImpl();
this.partList = new PackagePartCollection();
for (PackagePart part : parts) {
- if (partList.containsKey(part.partName))
+ if (partList.containsKey(part._partName))
throw new InvalidFormatException(
"A part with the name '"
- + part.partName
+ + part._partName
+ "' already exist : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]");
// Check OPC compliance rule M4.1
@@ -605,29 +605,29 @@ public abstract class OPCPackage implements RelationshipSource {
}
PartUnmarshaller partUnmarshaller = partUnmarshallers
- .get(part.contentType);
+ .get(part._contentType);
if (partUnmarshaller != null) {
UnmarshallContext context = new UnmarshallContext(this,
- part.partName);
+ part._partName);
try {
PackagePart unmarshallPart = partUnmarshaller
.unmarshall(context, part.getInputStream());
- partList.put(unmarshallPart.partName, unmarshallPart);
+ partList.put(unmarshallPart._partName, unmarshallPart);
// Core properties case
if (unmarshallPart instanceof PackagePropertiesPart)
this.packageProperties = (PackagePropertiesPart) unmarshallPart;
} catch (IOException ioe) {
logger.log(POILogger.WARN, "Unmarshall operation : IOException for "
- + part.partName);
+ + part._partName);
continue;
} catch (InvalidOperationException invoe) {
throw new InvalidFormatException(invoe.getMessage());
}
} else {
try {
- partList.put(part.partName, part);
+ partList.put(part._partName, part);
} catch (InvalidOperationException e) {
throw new InvalidFormatException(e.getMessage());
}
@@ -640,7 +640,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Create and add a part, with the specified name and content type, to the
* package.
- *
+ *
* @param partName
* Part name.
* @param contentType
@@ -650,7 +650,7 @@ public abstract class OPCPackage implements RelationshipSource {
* If rule M1.12 is not verified : Packages shall not contain
* equivalent part names and package implementers shall neither
* create nor recognize packages with equivalent part names.
- * @see #createPartImpl(PackagePartName, String, boolean)
+ * @see #createPartImpl(PackagePartName, String, boolean)
*/
public PackagePart createPart(PackagePartName partName, String contentType) {
return this.createPart(partName, contentType, true);
@@ -660,7 +660,7 @@ public abstract class OPCPackage implements RelationshipSource {
* Create and add a part, with the specified name and content type, to the
* package. For general purpose, prefer the overload version of this method
* without the 'loadRelationships' parameter.
- *
+ *
* @param partName
* Part name.
* @param contentType
@@ -721,7 +721,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Add a part to the package.
- *
+ *
* @param partName
* Part name of the part to create.
* @param contentType
@@ -730,7 +730,7 @@ public abstract class OPCPackage implements RelationshipSource {
* the contents to add. In order to have faster operation in
* document merge, the data are stored in memory not on a hard
* disk
- *
+ *
* @return The new part.
* @see #createPart(PackagePartName, String)
*/
@@ -764,7 +764,7 @@ public abstract class OPCPackage implements RelationshipSource {
* Add the specified part to the package. If a part already exists in the
* package with the same name as the one specified, then we replace the old
* part by the specified part.
- *
+ *
* @param part
* The part to add (or replace).
* @return The part added to the package, the same as the one specified.
@@ -779,20 +779,20 @@ public abstract class OPCPackage implements RelationshipSource {
throw new IllegalArgumentException("part");
}
- if (partList.containsKey(part.partName)) {
- if (!partList.get(part.partName).isDeleted()) {
+ if (partList.containsKey(part._partName)) {
+ if (!partList.get(part._partName).isDeleted()) {
throw new InvalidOperationException(
"A part with the name '"
- + part.partName.getName()
+ + part._partName.getName()
+ "' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]");
}
// If the specified partis flagged as deleted, we make it
// available
part.setDeleted(false);
// and delete the old part to replace it thereafeter
- this.partList.remove(part.partName);
+ this.partList.remove(part._partName);
}
- this.partList.put(part.partName, part);
+ this.partList.put(part._partName, part);
this.isDirty = true;
return part;
}
@@ -800,7 +800,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Remove the specified part in this package. If this part is relationship
* part, then delete all relationships in the source part.
- *
+ *
* @param part
* The part to remove. If <code>null</code>, skip the action.
* @see #removePart(PackagePartName)
@@ -814,7 +814,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Remove a part in this package. If this part is relationship part, then
* delete all relationships in the source part.
- *
+ *
* @param partName
* The part name of the part to remove.
*/
@@ -867,7 +867,7 @@ public abstract class OPCPackage implements RelationshipSource {
* Remove a part from this package as well as its relationship part, if one
* exists, and all parts listed in the relationship part. Be aware that this
* do not delete relationships which target the specified part.
- *
+ *
* @param partName
* The name of the part to delete.
* @throws InvalidFormatException
@@ -893,11 +893,11 @@ public abstract class OPCPackage implements RelationshipSource {
}
// Finally delete its relationship part if one exists
- this.removePart(relPart.partName);
+ this.removePart(relPart._partName);
}
// Delete the specified part
- this.removePart(partToRemove.partName);
+ this.removePart(partToRemove._partName);
}
/**
@@ -905,7 +905,7 @@ public abstract class OPCPackage implements RelationshipSource {
* part if one exists. Prefer the use of this method to delete a part in the
* package, compare to the remove() methods that don't remove associated
* relationships part.
- *
+ *
* @param partName
* Name of the part to delete
*/
@@ -925,7 +925,7 @@ public abstract class OPCPackage implements RelationshipSource {
* apply to all parts in the relationships part of the specified part.
* Prefer the use of this method to delete a part in the package, compare to
* the remove() methods that don't remove associated relationships part.
- *
+ *
* @param partName
* Name of the part to delete
*/
@@ -961,7 +961,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Check if a part already exists in this package from its name.
- *
+ *
* @param partName
* Part name to check.
* @return <i>true</i> if the part is logically added to this package, else
@@ -973,18 +973,18 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Add a relationship to the package (except relationships part).
- *
+ *
* Check rule M4.1 : The format designer shall specify and the format
* producer shall create at most one core properties relationship for a
* package. A format consumer shall consider more than one core properties
* relationship for a package to be an error. If present, the relationship
* shall target the Core Properties part.
- *
+ *
* Check rule M1.25: The Relationships part shall not have relationships to
* any other part. Package implementers shall enforce this requirement upon
* the attempt to create such a relationship and shall treat any such
* relationship as invalid.
- *
+ *
* @param targetPartName
* Target part name.
* @param targetMode
@@ -1032,7 +1032,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Add a package relationship.
- *
+ *
* @param targetPartName
* Target part name.
* @param targetMode
@@ -1049,11 +1049,11 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Adds an external relationship to a part (except relationships part).
- *
+ *
* The targets of external relationships are not subject to the same
* validity checks that internal ones are, as the contents is potentially
* any file, URL or similar.
- *
+ *
* @param target
* External target of the relationship
* @param relationshipType
@@ -1069,11 +1069,11 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Adds an external relationship to a part (except relationships part).
- *
+ *
* The targets of external relationships are not subject to the same
* validity checks that internal ones are, as the contents is potentially
* any file, URL or similar.
- *
+ *
* @param target
* External target of the relationship
* @param relationshipType
@@ -1109,7 +1109,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Delete a relationship from this package.
- *
+ *
* @param id
* Id of the relationship to delete.
*/
@@ -1122,7 +1122,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieves all package relationships.
- *
+ *
* @return All package relationships of this package.
* @throws OpenXML4JException
* @see #getRelationshipsHelper(String)
@@ -1133,7 +1133,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieves all relationships with the specified type.
- *
+ *
* @param relationshipType
* The filter specifying the relationship type.
* @return All relationships with the specified relationship type.
@@ -1150,7 +1150,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Retrieves all relationships with specified id (normally just ine because
* a relationship id is supposed to be unique).
- *
+ *
* @param id
* Id of the wanted relationship.
*/
@@ -1214,7 +1214,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Add a marshaller.
- *
+ *
* @param contentType
* The content type to bind to the specified marshaller.
* @param marshaller
@@ -1231,7 +1231,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Add an unmarshaller.
- *
+ *
* @param contentType
* The content type to bind to the specified unmarshaller.
* @param unmarshaller
@@ -1250,7 +1250,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Remove a marshaller by its content type.
- *
+ *
* @param contentType
* The content type associated with the marshaller to remove.
*/
@@ -1260,7 +1260,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Remove an unmarshaller by its content type.
- *
+ *
* @param contentType
* The content type associated with the unmarshaller to remove.
*/
@@ -1272,7 +1272,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Get the package access mode.
- *
+ *
* @return the packageAccess The current package access.
*/
public PackageAccess getPackageAccess() {
@@ -1281,7 +1281,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Validates the package compliance with the OPC specifications.
- *
+ *
* @return <b>true</b> if the package is valid else <b>false</b>
*/
public boolean validatePackage(OPCPackage pkg) throws InvalidFormatException {
@@ -1290,7 +1290,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Save the document in the specified file.
- *
+ *
* @param targetFile
* Destination file.
* @throws IOException
@@ -1313,7 +1313,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Save the document in the specified output stream.
- *
+ *
* @param outputStream
* The stream to save the package.
* @see #saveImpl(OutputStream)
@@ -1326,7 +1326,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Core method to create a package part. This method must be implemented by
* the subclass.
- *
+ *
* @param partName
* URI of the part to create.
* @param contentType
@@ -1339,7 +1339,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Core method to delete a package part. This method must be implemented by
* the subclass.
- *
+ *
* @param partName
* The URI of the part to delete.
*/
@@ -1352,7 +1352,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Close the package and cause a save of the package.
- *
+ *
*/
protected abstract void closeImpl() throws IOException;
@@ -1364,7 +1364,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Save the package into the specified output stream.
- *
+ *
* @param outputStream
* The output stream use to save this package.
*/
@@ -1373,7 +1373,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Get the package part mapped to the specified URI.
- *
+ *
* @param partName
* The URI of the part to retrieve.
* @return The package part located by the specified URI, else <b>null</b>.
@@ -1382,7 +1382,7 @@ public abstract class OPCPackage implements RelationshipSource {
/**
* Get all parts link to the package.
- *
+ *
* @return A list of the part owned by the package.
*/
protected abstract PackagePart[] getPartsImpl()
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
index 928e0a783f..2b49cb21ec 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
@@ -30,7 +30,7 @@ import org.apache.poi.openxml4j.opc.internal.ContentType;
/**
* Provides a base class for parts stored in a Package.
- *
+ *
* @author Julien Chable
* @version 0.9
*/
@@ -39,36 +39,36 @@ public abstract class PackagePart implements RelationshipSource {
/**
* This part's container.
*/
- protected OPCPackage container;
+ protected OPCPackage _container;
/**
* The part name. (required by the specification [M1.1])
*/
- protected PackagePartName partName;
+ protected PackagePartName _partName;
/**
* The type of content of this part. (required by the specification [M1.2])
*/
- protected ContentType contentType;
+ protected ContentType _contentType;
/**
* Flag to know if this part is a relationship.
*/
- private boolean isRelationshipPart;
+ private boolean _isRelationshipPart;
/**
* Flag to know if this part has been logically deleted.
*/
- private boolean isDeleted;
+ private boolean _isDeleted;
/**
* This part's relationships.
*/
- private PackageRelationshipCollection relationships;
+ private PackageRelationshipCollection _relationships;
/**
* Constructor.
- *
+ *
* @param pack
* Parent package.
* @param partName
@@ -85,7 +85,7 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Constructor.
- *
+ *
* @param pack
* Parent package.
* @param partName
@@ -100,12 +100,12 @@ public abstract class PackagePart implements RelationshipSource {
protected PackagePart(OPCPackage pack, PackagePartName partName,
ContentType contentType, boolean loadRelationships)
throws InvalidFormatException {
- this.partName = partName;
- this.contentType = contentType;
- this.container = (ZipPackage) pack; // TODO - enforcing ZipPackage here - perhaps should change constructor signature
+ _partName = partName;
+ _contentType = contentType;
+ _container = pack;
// Check if this part is a relationship part
- isRelationshipPart = this.partName.isRelationshipPartURI();
+ _isRelationshipPart = this._partName.isRelationshipPartURI();
// Load relationships if any
if (loadRelationships)
@@ -114,7 +114,7 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Constructor.
- *
+ *
* @param pack
* Parent package.
* @param partName
@@ -130,11 +130,11 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Adds an external relationship to a part (except relationships part).
- *
+ *
* The targets of external relationships are not subject to the same
* validity checks that internal ones are, as the contents is potentially
* any file, URL or similar.
- *
+ *
* @param target
* External target of the relationship
* @param relationshipType
@@ -150,11 +150,11 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Adds an external relationship to a part (except relationships part).
- *
+ *
* The targets of external relationships are not subject to the same
* validity checks that internal ones are, as the contents is potentially
* any file, URL or similar.
- *
+ *
* @param target
* External target of the relationship
* @param relationshipType
@@ -174,8 +174,8 @@ public abstract class PackagePart implements RelationshipSource {
throw new IllegalArgumentException("relationshipType");
}
- if (relationships == null) {
- relationships = new PackageRelationshipCollection();
+ if (_relationships == null) {
+ _relationships = new PackageRelationshipCollection();
}
URI targetURI;
@@ -185,13 +185,13 @@ public abstract class PackagePart implements RelationshipSource {
throw new IllegalArgumentException("Invalid target - " + e);
}
- return relationships.addRelationship(targetURI, TargetMode.EXTERNAL,
+ return _relationships.addRelationship(targetURI, TargetMode.EXTERNAL,
relationshipType, id);
}
/**
* Add a relationship to a part (except relationships part).
- *
+ *
* @param targetPartName
* Name of the target part. This one must be relative to the
* source root directory of the part.
@@ -227,7 +227,7 @@ public abstract class PackagePart implements RelationshipSource {
* @param id
* Relationship unique id.
* @return The newly created and added relationship
- *
+ *
* @throws InvalidFormatException
* If the URI point to a relationship part URI.
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addRelationship(org.apache.poi.openxml4j.opc.PackagePartName,
@@ -235,7 +235,7 @@ public abstract class PackagePart implements RelationshipSource {
*/
public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode, String relationshipType, String id) {
- container.throwExceptionIfReadOnly();
+ _container.throwExceptionIfReadOnly();
if (targetPartName == null) {
throw new IllegalArgumentException("targetPartName");
@@ -247,22 +247,22 @@ public abstract class PackagePart implements RelationshipSource {
throw new IllegalArgumentException("relationshipType");
}
- if (this.isRelationshipPart || targetPartName.isRelationshipPartURI()) {
+ if (this._isRelationshipPart || targetPartName.isRelationshipPartURI()) {
throw new InvalidOperationException(
"Rule M1.25: The Relationships part shall not have relationships to any other part.");
}
- if (relationships == null) {
- relationships = new PackageRelationshipCollection();
+ if (_relationships == null) {
+ _relationships = new PackageRelationshipCollection();
}
- return relationships.addRelationship(targetPartName.getURI(),
+ return _relationships.addRelationship(targetPartName.getURI(),
targetMode, relationshipType, id);
}
/**
* Add a relationship to a part (except relationships part).
- *
+ *
* @param targetURI
* URI the target part. Must be relative to the source root
* directory of the part.
@@ -297,7 +297,7 @@ public abstract class PackagePart implements RelationshipSource {
* @param id
* Relationship unique id.
* @return The newly created and added relationship
- *
+ *
* @throws InvalidFormatException
* If the URI point to a relationship part URI.
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addRelationship(org.apache.poi.openxml4j.opc.PackagePartName,
@@ -305,7 +305,7 @@ public abstract class PackagePart implements RelationshipSource {
*/
public PackageRelationship addRelationship(URI targetURI,
TargetMode targetMode, String relationshipType, String id) {
- container.throwExceptionIfReadOnly();
+ _container.throwExceptionIfReadOnly();
if (targetURI == null) {
throw new IllegalArgumentException("targetPartName");
@@ -319,17 +319,17 @@ public abstract class PackagePart implements RelationshipSource {
// Try to retrieve the target part
- if (this.isRelationshipPart
+ if (this._isRelationshipPart
|| PackagingURIHelper.isRelationshipPartURI(targetURI)) {
throw new InvalidOperationException(
"Rule M1.25: The Relationships part shall not have relationships to any other part.");
}
- if (relationships == null) {
- relationships = new PackageRelationshipCollection();
+ if (_relationships == null) {
+ _relationships = new PackageRelationshipCollection();
}
- return relationships.addRelationship(targetURI,
+ return _relationships.addRelationship(targetURI,
targetMode, relationshipType, id);
}
@@ -337,27 +337,27 @@ public abstract class PackagePart implements RelationshipSource {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#clearRelationships()
*/
public void clearRelationships() {
- if (relationships != null) {
- relationships.clear();
+ if (_relationships != null) {
+ _relationships.clear();
}
}
/**
* Delete the relationship specified by its id.
- *
+ *
* @param id
* The ID identified the part to delete.
* @see org.apache.poi.openxml4j.opc.RelationshipSource#removeRelationship(java.lang.String)
*/
public void removeRelationship(String id) {
- this.container.throwExceptionIfReadOnly();
- if (this.relationships != null)
- this.relationships.removeRelationship(id);
+ this._container.throwExceptionIfReadOnly();
+ if (this._relationships != null)
+ this._relationships.removeRelationship(id);
}
/**
* Retrieve all the relationships attached to this part.
- *
+ *
* @return This part's relationships.
* @throws OpenXML4JException
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationships()
@@ -369,20 +369,20 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Retrieves a package relationship from its id.
- *
+ *
* @param id
* ID of the package relationship to retrieve.
* @return The package relationship
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationship(java.lang.String)
*/
public PackageRelationship getRelationship(String id) {
- return this.relationships.getRelationshipByID(id);
+ return this._relationships.getRelationshipByID(id);
}
/**
* Retrieve all relationships attached to this part which have the specified
* type.
- *
+ *
* @param relationshipType
* Relationship type filter.
* @return All relationships from this part that have the specified type.
@@ -394,14 +394,14 @@ public abstract class PackagePart implements RelationshipSource {
*/
public PackageRelationshipCollection getRelationshipsByType(
String relationshipType) throws InvalidFormatException {
- container.throwExceptionIfWriteOnly();
+ _container.throwExceptionIfWriteOnly();
return getRelationshipsCore(relationshipType);
}
/**
* Implementation of the getRelationships method().
- *
+ *
* @param filter
* Relationship type filter. If <i>null</i> then the filter is
* disabled and return all the relationships.
@@ -415,29 +415,29 @@ public abstract class PackagePart implements RelationshipSource {
*/
private PackageRelationshipCollection getRelationshipsCore(String filter)
throws InvalidFormatException {
- this.container.throwExceptionIfWriteOnly();
- if (relationships == null) {
+ this._container.throwExceptionIfWriteOnly();
+ if (_relationships == null) {
this.throwExceptionIfRelationship();
- relationships = new PackageRelationshipCollection(this);
+ _relationships = new PackageRelationshipCollection(this);
}
- return new PackageRelationshipCollection(relationships, filter);
+ return new PackageRelationshipCollection(_relationships, filter);
}
/**
* Knows if the part have any relationships.
- *
+ *
* @return <b>true</b> if the part have at least one relationship else
* <b>false</b>.
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships()
*/
public boolean hasRelationships() {
- return (!this.isRelationshipPart && (relationships != null && relationships
+ return (!this._isRelationshipPart && (_relationships != null && _relationships
.size() > 0));
}
/**
* Checks if the specified relationship is part of this package part.
- *
+ *
* @param rel
* The relationship to check.
* @return <b>true</b> if the specified relationship exists in this part,
@@ -458,7 +458,7 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Get the input stream of this part to read its content.
- *
+ *
* @return The input stream of the content of this part, else
* <code>null</code>.
*/
@@ -466,9 +466,9 @@ public abstract class PackagePart implements RelationshipSource {
InputStream inStream = this.getInputStreamImpl();
if (inStream == null) {
throw new IOException("Can't obtain the input stream from "
- + partName.getName());
- } else
- return inStream;
+ + _partName.getName());
+ }
+ return inStream;
}
/**
@@ -476,7 +476,7 @@ public abstract class PackagePart implements RelationshipSource {
* Zip package, it'll be transform intot a <i>MemoryPackagePart</i> in
* order to write inside (the standard Java API doesn't allow to write in
* the file)
- *
+ *
* @see org.apache.poi.openxml4j.opc.internal.MemoryPackagePart
*/
public OutputStream getOutputStream() {
@@ -485,12 +485,12 @@ public abstract class PackagePart implements RelationshipSource {
// this part into a MemoryPackagePart instance for write purpose.
if (this instanceof ZipPackagePart) {
// Delete logically this part
- this.container.removePart(this.partName);
+ _container.removePart(this._partName);
// Create a memory part
- PackagePart part = container.createPart(this.partName,
- this.contentType.toString(), false);
- part.relationships = this.relationships;
+ PackagePart part = _container.createPart(this._partName,
+ this._contentType.toString(), false);
+ part._relationships = this._relationships;
if (part == null) {
throw new InvalidOperationException(
"Can't create a temporary part !");
@@ -504,27 +504,27 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Throws an exception if this package part is a relationship part.
- *
+ *
* @throws InvalidOperationException
* If this part is a relationship part.
*/
private void throwExceptionIfRelationship()
throws InvalidOperationException {
- if (this.isRelationshipPart)
+ if (this._isRelationshipPart)
throw new InvalidOperationException(
"Can do this operation on a relationship part !");
}
/**
* Ensure the package relationships collection instance is built.
- *
+ *
* @throws InvalidFormatException
* Throws if
*/
private void loadRelationships() throws InvalidFormatException {
- if (this.relationships == null && !this.isRelationshipPart) {
+ if (this._relationships == null && !this._isRelationshipPart) {
this.throwExceptionIfRelationship();
- relationships = new PackageRelationshipCollection(this);
+ _relationships = new PackageRelationshipCollection(this);
}
}
@@ -536,22 +536,22 @@ public abstract class PackagePart implements RelationshipSource {
* @return the uri
*/
public PackagePartName getPartName() {
- return partName;
+ return _partName;
}
/**
* @return the contentType
*/
public String getContentType() {
- return contentType.toString();
+ return _contentType.toString();
}
/**
* Set the content type.
- *
+ *
* @param contentType
* the contentType to set
- *
+ *
* @throws InvalidFormatException
* Throws if the content type is not valid.
* @throws InvalidOperationException
@@ -560,29 +560,29 @@ public abstract class PackagePart implements RelationshipSource {
*/
public void setContentType(String contentType)
throws InvalidFormatException {
- if (container == null)
- this.contentType = new ContentType(contentType);
+ if (_container == null)
+ this._contentType = new ContentType(contentType);
else
throw new InvalidOperationException(
"You can't change the content type of a part.");
}
public OPCPackage getPackage() {
- return container;
+ return _container;
}
/**
* @return true if this part is a relationship
*/
public boolean isRelationshipPart() {
- return this.isRelationshipPart;
+ return this._isRelationshipPart;
}
/**
* @return true if this part has been logically deleted
*/
public boolean isDeleted() {
- return isDeleted;
+ return _isDeleted;
}
/**
@@ -590,20 +590,20 @@ public abstract class PackagePart implements RelationshipSource {
* the isDeleted to set
*/
public void setDeleted(boolean isDeleted) {
- this.isDeleted = isDeleted;
+ this._isDeleted = isDeleted;
}
@Override
public String toString() {
- return "Name: " + this.partName + " - Content Type: "
- + this.contentType.toString();
+ return "Name: " + this._partName + " - Content Type: "
+ + this._contentType.toString();
}
/*-------------- Abstract methods ------------- */
/**
* Abtract method that get the input stream of this part.
- *
+ *
* @exception IOException
* Throws if an IO Exception occur in the implementation
* method.
@@ -619,7 +619,7 @@ public abstract class PackagePart implements RelationshipSource {
* Save the content of this part and the associated relationships part (if
* this part own at least one relationship) into the specified output
* stream.
- *
+ *
* @param zos
* Output stream to save this part.
* @throws OpenXML4JException
@@ -629,7 +629,7 @@ public abstract class PackagePart implements RelationshipSource {
/**
* Load the content of this part.
- *
+ *
* @param ios
* The input stream of the content to load.
* @return <b>true</b> if the content has been successfully loaded, else
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
index 03bd296294..f43fa1b62f 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
@@ -22,7 +22,7 @@ import java.net.URISyntaxException;
/**
* A part relationship.
- *
+ *
* @author Julien Chable
* @version 1.0
*/
@@ -86,7 +86,7 @@ public final class PackageRelationship {
/**
* Constructor.
- *
+ *
* @param pkg
* @param sourcePart
* @param targetUri
@@ -171,19 +171,19 @@ public final class PackageRelationship {
}
/**
- *
+ *
* @return URL of the source part of this relationship
*/
public URI getSourceURI() {
if (source == null) {
return PackagingURIHelper.PACKAGE_ROOT_URI;
}
- return source.partName.getURI();
+ return source._partName.getURI();
}
/**
* public URI getSourceUri(){ }
- *
+ *
* @return the targetMode
*/
public TargetMode getTargetMode() {
@@ -199,7 +199,7 @@ public final class PackageRelationship {
if(targetMode == TargetMode.EXTERNAL) {
return targetUri;
}
-
+
// Internal target
// If it isn't absolute, resolve it relative
// to ourselves
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
index 8a11738711..990a3bf4cb 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
@@ -34,7 +34,7 @@ import org.apache.poi.util.POILogFactory;
/**
* Represents a collection of PackageRelationship elements that are owned by a
* given PackagePart or the Package.
- *
+ *
* @author Julien Chable, CDubettier
* @version 0.1
*/
@@ -83,11 +83,11 @@ public final class PackageRelationshipCollection implements
/**
* Copy constructor.
- *
+ *
* This collection will contain only elements from the specified collection
* for which the type is compatible with the specified relationship type
* filter.
- *
+ *
* @param coll
* Collection to import.
* @param filter
@@ -112,21 +112,21 @@ public final class PackageRelationshipCollection implements
/**
* Constructor.
- *
+ *
* @throws InvalidFormatException
* Throws if the format of the content part is invalid.
- *
+ *
* @throws InvalidOperationException
* Throws if the specified part is a relationship part.
*/
public PackageRelationshipCollection(PackagePart part)
throws InvalidFormatException {
- this(part.container, part);
+ this(part._container, part);
}
/**
* Constructor. Parse the existing package relationship part if one exists.
- *
+ *
* @param container
* The parent package.
* @param part
@@ -159,7 +159,7 @@ public final class PackageRelationshipCollection implements
/**
* Get the relationship part name of the specified part.
- *
+ *
* @param part
* The part .
* @return The relationship part name of the specified part. Be careful,
@@ -181,7 +181,7 @@ public final class PackageRelationshipCollection implements
/**
* Add the specified relationship to the collection.
- *
+ *
* @param relPart
* The relationship to add.
*/
@@ -192,7 +192,7 @@ public final class PackageRelationshipCollection implements
/**
* Add a relationship to the collection.
- *
+ *
* @param targetUri
* Target URI.
* @param targetMode
@@ -224,7 +224,7 @@ public final class PackageRelationshipCollection implements
/**
* Remove a relationship by its ID.
- *
+ *
* @param id
* The relationship ID to remove.
*/
@@ -240,7 +240,7 @@ public final class PackageRelationshipCollection implements
/**
* Remove a relationship by its reference.
- *
+ *
* @param rel
* The relationship to delete.
*/
@@ -254,7 +254,7 @@ public final class PackageRelationshipCollection implements
/**
* Retrieves a relationship by its index in the collection.
- *
+ *
* @param index
* Must be a value between [0-relationships_count-1]
*/
@@ -273,7 +273,7 @@ public final class PackageRelationshipCollection implements
/**
* Retrieves a package relationship based on its id.
- *
+ *
* @param id
* ID of the package relationship to retrieve.
* @return The package relationship identified by the specified id.
@@ -291,7 +291,7 @@ public final class PackageRelationshipCollection implements
/**
* Parse the relationship part and add all relationship in this collection.
- *
+ *
* @param relPart
* The package part to parse.
* @throws InvalidFormatException
@@ -376,7 +376,7 @@ public final class PackageRelationshipCollection implements
/**
* Retrieves all relations with the specified type.
- *
+ *
* @param typeFilter
* Relationship type filter. If <b>null</b> then all
* relationships are returned.
@@ -398,7 +398,7 @@ public final class PackageRelationshipCollection implements
/**
* Get an iterator of a collection with all relationship with the specified
* type.
- *
+ *
* @param typeFilter
* Type filter.
* @return An iterator to a collection containing all relationships with the
@@ -429,15 +429,15 @@ public final class PackageRelationshipCollection implements
} else {
str = relationshipsByID.size() + " relationship(s) = [";
}
- if ((relationshipPart != null) && (relationshipPart.partName != null)) {
- str = str + "," + relationshipPart.partName;
+ if ((relationshipPart != null) && (relationshipPart._partName != null)) {
+ str = str + "," + relationshipPart._partName;
} else {
str = str + ",relationshipPart=null";
}
// Source of this relationship
- if ((sourcePart != null) && (sourcePart.partName != null)) {
- str = str + "," + sourcePart.partName;
+ if ((sourcePart != null) && (sourcePart._partName != null)) {
+ str = str + "," + sourcePart._partName;
} else {
str = str + ",sourcePart=null";
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java
index 018f76c667..87c424df54 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java
@@ -24,7 +24,7 @@ public interface RelationshipSource {
/**
* Add a relationship to a part (except relationships part).
- *
+ *
* @param targetPartName
* Name of the target part. This one must be relative to the
* source root directory of the part.
@@ -56,7 +56,7 @@ public interface RelationshipSource {
* @param id
* Relationship unique id.
* @return The newly created and added relationship
- *
+ *
* @throws InvalidFormatException
* If the URI point to a relationship part URI.
*/
@@ -67,28 +67,28 @@ public interface RelationshipSource {
/**
* Adds an external relationship to a part
* (except relationships part).
- *
+ *
* The targets of external relationships are not
* subject to the same validity checks that internal
* ones are, as the contents is potentially
* any file, URL or similar.
- *
+ *
* @param target External target of the relationship
* @param relationshipType Type of relationship.
* @return The newly created and added relationship
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String)
*/
public PackageRelationship addExternalRelationship(String target, String relationshipType);
-
+
/**
* Adds an external relationship to a part
* (except relationships part).
- *
+ *
* The targets of external relationships are not
* subject to the same validity checks that internal
* ones are, as the contents is potentially
* any file, URL or similar.
- *
+ *
* @param target External target of the relationship
* @param relationshipType Type of relationship.
* @param id Relationship unique id.
@@ -96,7 +96,7 @@ public interface RelationshipSource {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String)
*/
public PackageRelationship addExternalRelationship(String target, String relationshipType, String id);
-
+
/**
* Delete all the relationships attached to this.
*/
@@ -104,7 +104,7 @@ public interface RelationshipSource {
/**
* Delete the relationship specified by its id.
- *
+ *
* @param id
* The ID identified the part to delete.
*/
@@ -112,7 +112,7 @@ public interface RelationshipSource {
/**
* Retrieve all the relationships attached to this.
- *
+ *
* @return This part's relationships.
* @throws OpenXML4JException
*/
@@ -121,7 +121,7 @@ public interface RelationshipSource {
/**
* Retrieves a package relationship from its id.
- *
+ *
* @param id
* ID of the package relationship to retrieve.
* @return The package relationship
@@ -131,7 +131,7 @@ public interface RelationshipSource {
/**
* Retrieve all relationships attached to this part which have the specified
* type.
- *
+ *
* @param relationshipType
* Relationship type filter.
* @return All relationships from this part that have the specified type.
@@ -141,12 +141,12 @@ public interface RelationshipSource {
* If the package is open in write only mode.
*/
public abstract PackageRelationshipCollection getRelationshipsByType(
- String relationshipType) throws InvalidFormatException,
+ String relationshipType) throws InvalidFormatException,
IllegalArgumentException, OpenXML4JException;
/**
* Knows if the part have any relationships.
- *
+ *
* @return <b>true</b> if the part have at least one relationship else
* <b>false</b>.
*/
@@ -154,13 +154,12 @@ public interface RelationshipSource {
/**
* Checks if the specified relationship is part of this package part.
- *
+ *
* @param rel
* The relationship to check.
* @return <b>true</b> if the specified relationship exists in this part,
* else returns <b>false</b>
*/
- @SuppressWarnings("finally")
public abstract boolean isRelationshipExists(PackageRelationship rel);
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
index 6e676cc9b2..a394f59583 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java
@@ -423,7 +423,7 @@ public final class ZipPackage extends Package {
+ ZipHelper.getZipItemNameFromOPCName(part
.getPartName().getName()) + "'");
PartMarshaller marshaller = partMarshallers
- .get(part.contentType);
+ .get(part._contentType);
if (marshaller != null) {
if (!marshaller.marshall(part, zos)) {
throw new OpenXML4JException(
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java
index a4e50ba0a8..e20311787b 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java
@@ -29,7 +29,7 @@ import org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller;
/**
* Zip implementation of a PackagePart.
- *
+ *
* @author Julien Chable
* @version 1.0
* @see PackagePart
@@ -43,7 +43,7 @@ public class ZipPackagePart extends PackagePart {
/**
* Constructor.
- *
+ *
* @param container
* The container package.
* @param partName
@@ -60,7 +60,7 @@ public class ZipPackagePart extends PackagePart {
/**
* Constructor.
- *
+ *
* @param container
* The container package.
* @param zipEntry
@@ -81,7 +81,7 @@ public class ZipPackagePart extends PackagePart {
/**
* Get the zip entry of this part.
- *
+ *
* @return The zip entry in the zip structure coresponding to this part.
*/
public ZipEntry getZipArchive() {
@@ -91,21 +91,21 @@ public class ZipPackagePart extends PackagePart {
/**
* Implementation of the getInputStream() which return the inputStream of
* this part zip entry.
- *
+ *
* @return Input stream of this part zip entry.
*/
@Override
protected InputStream getInputStreamImpl() throws IOException {
// We use the getInputStream() method from java.util.zip.ZipFile
// class which return an InputStream to this part zip entry.
- return ((ZipPackage) container).getZipArchive()
+ return ((ZipPackage) _container).getZipArchive()
.getInputStream(zipEntry);
}
/**
* Implementation of the getOutputStream(). Return <b>null</b>. Normally
* will never be called since the MemoryPackage is use instead.
- *
+ *
* @return <b>null</b>
*/
@Override
@@ -119,7 +119,7 @@ public class ZipPackagePart extends PackagePart {
}
@Override
- public boolean load(InputStream ios) throws InvalidFormatException {
+ public boolean load(InputStream ios) {
throw new InvalidOperationException("Method not implemented !");
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
index f36bf068ff..b8c30df930 100755
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
@@ -43,9 +43,8 @@ import org.dom4j.io.SAXReader;
/**
* Manage package content types ([Content_Types].xml part).
- *
+ *
* @author Julien Chable
- * @version 1.0
*/
public abstract class ContentTypeManager {
@@ -90,7 +89,7 @@ public abstract class ContentTypeManager {
/**
* Constructor. Parses the content of the specified input stream.
- *
+ *
* @param in
* If different of <i>null</i> then the content types part is
* retrieve and parse.
@@ -161,7 +160,7 @@ public abstract class ContentTypeManager {
/**
* Add an override content type for a specific part.
- *
+ *
* @param partName
* Name of the part.
* @param contentType
@@ -176,7 +175,7 @@ public abstract class ContentTypeManager {
/**
* Add a content type associated with the specified extension.
- *
+ *
* @param extension
* The part name extension to bind to a content type.
* @param contentType
@@ -267,7 +266,7 @@ public abstract class ContentTypeManager {
/**
* Check if the specified content type is already register.
- *
+ *
* @param contentType
* The content type to check.
* @return <code>true</code> if the specified content type is already
@@ -315,7 +314,7 @@ public abstract class ContentTypeManager {
* @return The content type associated with the URI (in case of an override
* content type) or the extension (in case of default content type),
* else <code>null</code>.
- *
+ *
* @exception OpenXML4JRuntimeException
* Throws if the content type manager is not able to find the
* content from an existing part.
@@ -342,9 +341,8 @@ public abstract class ContentTypeManager {
if (this.container != null && this.container.getPart(partName) != null) {
throw new OpenXML4JRuntimeException(
"Rule M2.4 exception : this error should NEVER happen, if so please send a mail to the developers team, thanks !");
- } else {
- return null;
}
+ return null;
}
/**
@@ -358,7 +356,7 @@ public abstract class ContentTypeManager {
/**
* Clear all override content types.
- *
+ *
*/
public void clearOverrideContentTypes() {
if (this.overrideContentType != null)
@@ -367,7 +365,7 @@ public abstract class ContentTypeManager {
/**
* Parse the content types part.
- *
+ *
* @throws InvalidFormatException
* Throws if the content type doesn't exist or the XML format is
* invalid.
@@ -414,7 +412,7 @@ public abstract class ContentTypeManager {
/**
* Save the contents type part.
- *
+ *
* @param outStream
* The output stream use to save the XML content of the content
* types part.
@@ -448,7 +446,7 @@ public abstract class ContentTypeManager {
/**
* Use to append specific type XML elements, use by the save() method.
- *
+ *
* @param root
* XML parent element use to append this override type element.
* @param entry
@@ -459,13 +457,13 @@ public abstract class ContentTypeManager {
Entry<PackagePartName, String> entry) {
root.addElement(OVERRIDE_TAG_NAME).addAttribute(
PART_NAME_ATTRIBUTE_NAME,
- ((PackagePartName) entry.getKey()).getName()).addAttribute(
- CONTENT_TYPE_ATTRIBUTE_NAME, (String) entry.getValue());
+ entry.getKey().getName()).addAttribute(
+ CONTENT_TYPE_ATTRIBUTE_NAME, entry.getValue());
}
/**
* Use to append default types XML elements, use by the save() metid.
- *
+ *
* @param root
* XML parent element use to append this default type element.
* @param entry
@@ -474,16 +472,16 @@ public abstract class ContentTypeManager {
*/
private void appendDefaultType(Element root, Entry<String, String> entry) {
root.addElement(DEFAULT_TAG_NAME).addAttribute(
- EXTENSION_ATTRIBUTE_NAME, (String) entry.getKey())
+ EXTENSION_ATTRIBUTE_NAME, entry.getKey())
.addAttribute(CONTENT_TYPE_ATTRIBUTE_NAME,
- (String) entry.getValue());
+ entry.getValue());
}
/**
* Specific implementation of the save method. Call by the save() method,
* call before exiting.
- *
+ *
* @param out
* The output stream use to write the content type XML.
*/
diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java
index 8a17cf5d8b..382f5c1547 100644
--- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java
+++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java
@@ -41,7 +41,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
private boolean formulasNotResults = false;
private boolean includeCellComments = false;
private boolean includeHeadersFooters = true;
-
+
public XSSFExcelExtractor(String path) throws XmlException, OpenXML4JException, IOException {
this(new XSSFWorkbook(path));
}
@@ -52,14 +52,14 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
super(workbook);
this.workbook = workbook;
}
-
+
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Use:");
System.err.println(" HXFExcelExtractor <filename.xlsx>");
System.exit(1);
}
- POIXMLTextExtractor extractor =
+ POIXMLTextExtractor extractor =
new XSSFExcelExtractor(args[0]);
System.out.println(extractor.getText());
}
@@ -89,19 +89,19 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
public void setIncludeHeadersFooters(boolean includeHeadersFooters) {
this.includeHeadersFooters = includeHeadersFooters;
}
-
+
/**
* Retreives the text contents of the file
*/
public String getText() {
StringBuffer text = new StringBuffer();
-
+
for(int i=0; i<workbook.getNumberOfSheets(); i++) {
- XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(i);
+ XSSFSheet sheet = workbook.getSheetAt(i);
if(includeSheetNames) {
text.append(workbook.getSheetName(i) + "\n");
}
-
+
// Header(s), if present
if(includeHeadersFooters) {
text.append(
@@ -120,7 +120,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
Row row = (Row)rawR;
for(Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
Cell cell = ri.next();
-
+
// Is it a formula one?
if(cell.getCellType() == Cell.CELL_TYPE_FORMULA && formulasNotResults) {
text.append(cell.getCellFormula());
@@ -130,7 +130,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
XSSFCell xc = (XSSFCell)cell;
text.append(xc.getRawValue());
}
-
+
// Output the comment, if requested and exists
Comment comment = cell.getCellComment();
if(includeCellComments && comment != null) {
@@ -139,13 +139,13 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
String commentText = comment.getString().getString().replace('\n', ' ');
text.append(" Comment by "+comment.getAuthor()+": "+commentText);
}
-
+
if(ri.hasNext())
text.append("\t");
}
text.append("\n");
}
-
+
// Finally footer(s), if present
if(includeHeadersFooters) {
text.append(
@@ -159,10 +159,10 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
);
}
}
-
+
return text.toString();
}
-
+
private String extractHeaderFooter(HeaderFooter hf) {
return ExcelExtractor._extractHeaderFooter(hf);
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index f6615b73e8..f9c2bdf2bd 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -585,9 +585,11 @@ public final class XSSFCell implements Cell {
*/
public byte getErrorCellValue() {
String code = getErrorCellString();
- if(code == null) return 0;
+ if (code == null) {
+ return 0;
+ }
- return (byte)FormulaError.forString(code).getCode();
+ return FormulaError.forString(code).getCode();
}
/**
@@ -778,7 +780,7 @@ public final class XSSFCell implements Cell {
SpreadsheetVersion v = SpreadsheetVersion.EXCEL2007;
int maxcol = SpreadsheetVersion.EXCEL2007.getLastColumnIndex();
if (cellIndex < 0 || cellIndex > maxcol) {
- throw new IllegalArgumentException("Invalid column index (" + cellIndex
+ throw new IllegalArgumentException("Invalid column index (" + cellIndex
+ "). Allowable column range for " + v.name() + " is (0.."
+ maxcol + ") or ('A'..'" + v.getLastColumnName() + "')");
}
@@ -848,7 +850,7 @@ public final class XSSFCell implements Cell {
*/
private boolean convertCellValueToBoolean() {
int cellType = getCellType();
-
+
if (cellType == CELL_TYPE_FORMULA) {
cellType = getBaseCellType(false);
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
index 17f267b7cb..5ce05a176d 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
@@ -145,9 +145,8 @@ public class XSSFCellStyle implements CellStyle {
CTCellAlignment align = cellXf.getAlignment();
if(align != null && align.isSetHorizontal()) {
return HorizontalAlignment.values()[align.getHorizontal().intValue()-1];
- } else {
- return HorizontalAlignment.GENERAL;
}
+ return HorizontalAlignment.GENERAL;
}
/**
@@ -865,7 +864,7 @@ public class XSSFCellStyle implements CellStyle {
*/
public void setDataFormat(short fmt) {
cellXf.setApplyNumberFormat(true);
- cellXf.setNumFmtId((long)fmt);
+ cellXf.setNumFmtId(fmt);
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
index 2905228204..47a27b6a63 100755
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPrintSetup.java
@@ -285,7 +285,7 @@ public class XSSFPrintSetup implements PrintSetup {
* @see PaperSize
*/
public PaperSize getPaperSizeEnum() {
- return PaperSize.values()[((int) getPaperSize() - 1)];
+ return PaperSize.values()[getPaperSize() - 1];
}
/**
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index 81d8c3ebc8..77d4b5c34e 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -255,7 +255,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
/**
* Returns the name of this sheet
- *
+ *
* @return the name of this sheet
*/
public String getSheetName() {
@@ -358,7 +358,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
public void createFreezePane(int colSplit, int rowSplit) {
createFreezePane( colSplit, rowSplit, colSplit, rowSplit );
}
-
+
/**
* Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
* @param colSplit Horizonatal position of split.
@@ -533,7 +533,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
worksheet.getSheetFormatPr() :
worksheet.addNewSheetFormatPr();
}
-
+
/**
* Returns the CellStyle that applies to the given
* (0 based) column, or null if no style has been
@@ -571,7 +571,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
/**
* Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
* When false, cells with zero value appear blank instead of showing the number zero.
- *
+ *
* @return whether all zero values on the worksheet are displayed
*/
public boolean isDisplayZeros(){
@@ -1333,7 +1333,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
.getOutlineLevel(), true);
// write collapse field
- setColumn((int) (lastColMax + 1), null, 0, null, null, Boolean.TRUE);
+ setColumn(lastColMax + 1, null, 0, null, null, Boolean.TRUE);
}
@@ -1433,7 +1433,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
/**
* Sets all adjacent columns of the same outline level to the specified
* hidden status.
- *
+ *
* @param pIdx
* the col info index of the start of the outline group
* @return the column index of the last column in the outline group
@@ -1626,7 +1626,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
/**
* 'Collapsed' state is stored in a single column col info record
* immediately after the outline group
- *
+ *
* @param idx
* @return a boolean represented if the column is collapsed
*/
@@ -1764,7 +1764,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
* outline level collapsed, thus hiding all the child rows. Note that in
* this case, if the lowest level were expanded, the middle level would
* remain collapsed.
- *
+ *
* @param rowIndex -
* the row involved, 0 based
* @param collapse -
@@ -1895,8 +1895,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
endLevel = 0;
endHidden = false;
} else {
- endLevel = (int) (getRow(endOfOutlineGroupIdx).getCTRow()
- .getOutlineLevel());
+ endLevel = getRow(endOfOutlineGroupIdx).getCTRow().getOutlineLevel();
endHidden = getRow(endOfOutlineGroupIdx).getCTRow().getHidden();
}
@@ -1931,7 +1930,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
else
return getRow(collapseRow).getCTRow().getCollapsed();
}
-
+
/**
* Sets the zoom magnication for the sheet. The zoom is expressed as a
* fraction. For example to express a zoom of 75% use 3 for the numerator