diff options
author | Dominik Stadler <centic@apache.org> | 2020-03-08 08:28:11 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2020-03-08 08:28:11 +0000 |
commit | af4751b2604105f0add7e6db551a3ca5e18b9197 (patch) | |
tree | a30269f18f06465d249ae8c9a47571ceceb8e2f0 /src/ooxml/java/org | |
parent | da4c9cc7061ca436ef1ec4d9ffed52f27d32fcf4 (diff) | |
download | poi-af4751b2604105f0add7e6db551a3ca5e18b9197.tar.gz poi-af4751b2604105f0add7e6db551a3ca5e18b9197.zip |
Update JavaDoc for logging and marshalling
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874965 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org')
4 files changed, 26 insertions, 12 deletions
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 1b04417ee2..0fdacdd214 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java @@ -466,7 +466,7 @@ public abstract class PackagePart implements RelationshipSource, Comparable<Pack /** * Get the PackagePart that is the target of a relationship. * - * @param rel A relationship from this part to another one + * @param rel A relationship from this part to another one * @return The target part of the relationship * @throws InvalidFormatException * If the specified URI is not valid. @@ -698,7 +698,8 @@ public abstract class PackagePart implements RelationshipSource, Comparable<Pack * * @param zos * Output stream to save this part. - * @return boolean flag that shows if the save succeeded + * @return true if the content has been successfully stored, false otherwise. + * More information about errors may be logged via {@link org.apache.poi.util.POILogger} * @throws OpenXML4JException * If any exception occur. */ @@ -709,8 +710,8 @@ public abstract class PackagePart implements RelationshipSource, Comparable<Pack * * @param ios * The input stream of the content to load. - * @return <b>true</b> if the content has been successfully loaded, else - * <b>false</b>. + * @return true if the content has been successfully loaded, false otherwise. + * More information about errors may be logged via {@link org.apache.poi.util.POILogger} * @throws InvalidFormatException * Throws if the content format is invalid. */ 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 a1a8910456..5cd3a14598 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -539,8 +539,9 @@ public final class ZipPackage extends OPCPackage { final PartMarshaller pm = (marshaller != null) ? marshaller : defaultPartMarshaller; if (!pm.marshall(part, zos)) { - String errMsg = "The part " + ppn.getURI() + " failed to be saved in the stream with marshaller "; - throw new OpenXML4JException(errMsg + pm); + String errMsg = "The part " + ppn.getURI() + " failed to be saved in the stream with marshaller " + pm + + ". Enable logging via POILogger for more details."; + throw new OpenXML4JException(errMsg); } } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java index 8cd2f7d245..16a5917ad3 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/DefaultMarshaller.java @@ -33,8 +33,12 @@ import org.apache.poi.openxml4j.opc.internal.PartMarshaller; public final class DefaultMarshaller implements PartMarshaller { /** - * Save part in the output stream by using the save() method of the part. + * Save the given part in the output stream by using the save() method of the part. * + * @param part The {@link PackagePart} to store. + * @param out Output stream to save this part. + * @return true if the content has been successfully stored, false otherwise. + * More information about errors may be logged via {@link org.apache.poi.util.POILogger} * @throws OpenXML4JException * If any error occur. */ diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java index a1ba382ff8..7ff1c74abd 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/ZipPartMarshaller.java @@ -50,10 +50,15 @@ public final class ZipPartMarshaller implements PartMarshaller { private final static POILogger logger = POILogFactory.getLogger(ZipPartMarshaller.class); /** - * Save the specified part. + * Save the specified part to the given stream. * + * @param part The {@link PackagePart} to save + * @param os The stream to write the data to + * @return true if saving was successful or there was nothing to save, + * false if an error occurred. + * In case of errors, logging via the {@link POILogger} is used to provide more information. * @throws OpenXML4JException - * Throws if an internal exception is thrown. + * Throws if the stream cannot be written to or an internal exception is thrown. */ @Override public boolean marshall(PackagePart part, OutputStream os) @@ -61,10 +66,10 @@ public final class ZipPartMarshaller implements PartMarshaller { if (!(os instanceof ZipArchiveOutputStream)) { logger.log(POILogger.ERROR,"Unexpected class " + os.getClass().getName()); throw new OpenXML4JException("ZipOutputStream expected !"); - // Normally should happen only in developement phase, so just throw + // Normally should happen only in development phase, so just throw // exception } - + // check if there is anything to save for some parts. We don't do this for all parts as some code // might depend on empty parts being saved, e.g. some unit tests verify this currently. if(part.getSize() == 0 && part.getPartName().getName().equals(XSSFRelation.SHARED_STRINGS.getDefaultFileName())) { @@ -98,8 +103,8 @@ public final class ZipPartMarshaller implements PartMarshaller { marshallRelationshipPart(part.getRelationships(), relationshipPartName, zos); - } + return true; } @@ -113,6 +118,9 @@ public final class ZipPartMarshaller implements PartMarshaller { * @param zos * Zip output stream in which to save the XML content of the * relationships serialization. + * @return true if saving was successful, + * false if an error occurred. + * In case of errors, logging via the {@link POILogger} is used to provide more information. */ public static boolean marshallRelationshipPart( PackageRelationshipCollection rels, PackagePartName relPartName, |