diff options
author | Yegor Kozlov <yegor@apache.org> | 2009-02-20 13:53:32 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2009-02-20 13:53:32 +0000 |
commit | 66ed25a0496e611ac179c517643d95e08454a7b9 (patch) | |
tree | b91992f69295eed17fd4fe5d3d71449248638508 | |
parent | 7ee091d4d0e0d4058bc14112e679dd3c260618d9 (diff) | |
download | poi-66ed25a0496e611ac179c517643d95e08454a7b9.tar.gz poi-66ed25a0496e611ac179c517643d95e08454a7b9.zip |
replaced log4j with POILogger in openxml4j, also converted non-ascii characters into unicode to keep javadoc quiet
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@746241 13f79535-47bb-0310-9956-ffa450edef68
17 files changed, 115 insertions, 111 deletions
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java index b05d7903e5..9671d3a67a 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java @@ -85,7 +85,8 @@ public class ContentTypes { /**
* TIFF image format.
*
- * @see http://partners.adobe.com/public/developer/tiff/index.html#spec
+ * @see <a href="http://partners.adobe.com/public/developer/tiff/index.html#spec">
+ * http://partners.adobe.com/public/developer/tiff/index.html#spec</a>
*/
public static final String IMAGE_TIFF = "image/tiff";
@@ -94,7 +95,8 @@ public class ContentTypes { /**
* Pict image format.
*
- * @see http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html
+ * @see <a href="http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html">
+ * http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html</a>
*/
public static final String IMAGE_PICT = "image/pict";
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java index 663ab266f9..918337178f 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java @@ -32,7 +32,6 @@ import java.util.Date; import java.util.Hashtable;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -48,6 +47,8 @@ import org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMar import org.apache.poi.openxml4j.opc.internal.unmarshallers.PackagePropertiesUnmarshaller;
import org.apache.poi.openxml4j.opc.internal.unmarshallers.UnmarshallContext;
import org.apache.poi.openxml4j.util.Nullable;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Represents a container that can store multiple data objects.
@@ -60,7 +61,7 @@ public abstract class Package implements RelationshipSource { /**
* Logger.
*/
- protected static Logger logger = Logger.getLogger("org.openxml4j.opc");
+ private static POILogger logger = POILogFactory.getLogger(Package.class);
/**
* Default package access.
@@ -340,7 +341,7 @@ public abstract class Package implements RelationshipSource { public void close() throws IOException {
if (this.packageAccess == PackageAccess.READ) {
logger
- .warn("The close() method is intended to SAVE a package. This package is open in READ ONLY mode, use the revert() method instead !");
+ .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 !");
return;
}
@@ -539,7 +540,7 @@ public abstract class Package implements RelationshipSource { }
} catch (OpenXML4JException e) {
logger
- .warn("Can't retrieve parts by relationship type: an exception has been thrown by getRelationshipsByType method");
+ .log(POILogger.WARN, "Can't retrieve parts by relationship type: an exception has been thrown by getRelationshipsByType method");
return null;
}
return retArr;
@@ -619,7 +620,7 @@ public abstract class Package implements RelationshipSource { if (unmarshallPart instanceof PackagePropertiesPart)
this.packageProperties = (PackagePropertiesPart) unmarshallPart;
} catch (IOException ioe) {
- logger.warn("Unmarshall operation : IOException for "
+ logger.log(POILogger.WARN, "Unmarshall operation : IOException for "
+ part.partName);
continue;
} catch (InvalidOperationException invoe) {
@@ -650,7 +651,7 @@ public abstract class Package 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 {@link#createPartImpl(URI, String)}
+ * @see #createPartImpl(PackagePartName, String, boolean)
*/
public PackagePart createPart(PackagePartName partName, String contentType) {
return this.createPart(partName, contentType, true);
@@ -732,7 +733,7 @@ public abstract class Package implements RelationshipSource { * disk
*
* @return The new part.
- * @see {@link #createPart(PackagePartName, String)}
+ * @see #createPart(PackagePartName, String)
*/
public PackagePart createPart(PackagePartName partName, String contentType,
ByteArrayOutputStream content) {
@@ -846,7 +847,7 @@ public abstract class Package implements RelationshipSource { sourcePartName = PackagingURIHelper.createPartName(sourceURI);
} catch (InvalidFormatException e) {
logger
- .error("Part name URI '"
+ .log(POILogger.ERROR, "Part name URI '"
+ sourceURI
+ "' is not valid ! This message is not intended to be displayed !");
return;
@@ -947,7 +948,7 @@ public abstract class Package implements RelationshipSource { this.deletePartRecursive(targetPartName);
}
} catch (InvalidFormatException e) {
- logger.warn("An exception occurs while deleting part '"
+ logger.log(POILogger.WARN, "An exception occurs while deleting part '"
+ partName.getName()
+ "'. Some parts may remain in the package. - "
+ e.getMessage());
@@ -1126,7 +1127,7 @@ public abstract class Package implements RelationshipSource { *
* @return All package relationships of this package.
* @throws OpenXML4JException
- * @see {@link #getRelationshipsHelper(String)}
+ * @see #getRelationshipsHelper(String)
*/
public PackageRelationshipCollection getRelationships()
throws OpenXML4JException {
@@ -1230,7 +1231,7 @@ public abstract class Package implements RelationshipSource { try {
partMarshallers.put(new ContentType(contentType), marshaller);
} catch (InvalidFormatException e) {
- logger.warn("The specified content type is not valid: '"
+ logger.log(POILogger.WARN, "The specified content type is not valid: '"
+ e.getMessage() + "'. The marshaller will not be added !");
}
}
@@ -1248,7 +1249,7 @@ public abstract class Package implements RelationshipSource { try {
partUnmarshallers.put(new ContentType(contentType), unmarshaller);
} catch (InvalidFormatException e) {
- logger.warn("The specified content type is not valid: '"
+ logger.log(POILogger.WARN, "The specified content type is not valid: '"
+ e.getMessage()
+ "'. The unmarshaller will not be added !");
}
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 34f26821f5..c30e6d9869 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java @@ -211,12 +211,12 @@ public abstract class PackagePart implements RelationshipSource { /**
* Add a relationship to a part (except relationships part).
- *
+ * <p>
* 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.
- *
+ * </p>
* @param targetPartName
* Name of the target part. This one must be relative to the
* source root directory of the part.
@@ -281,12 +281,12 @@ public abstract class PackagePart implements RelationshipSource { /**
* Add a relationship to a part (except relationships part).
- *
+ * <p>
* 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.
- *
+ * </p>
* @param targetURI
* URI of the target part. Must be relative to the source root
* directory of the part.
@@ -572,14 +572,14 @@ public abstract class PackagePart implements RelationshipSource { }
/**
- * @return
+ * @return true if this part is a relationship
*/
public boolean isRelationshipPart() {
return this.isRelationshipPart;
}
/**
- * @return
+ * @return true if this part has been logically deleted
*/
public boolean isDeleted() {
return isDeleted;
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java index 414fd41aaa..f1cc7fdaad 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java @@ -29,7 +29,7 @@ import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException; * @author Julien Chable
* @version 0.1
*
- * @see http://www.ietf.org/rfc/rfc3986.txt
+ * @see <a href="http://www.ietf.org/rfc/rfc3986.txt">http://www.ietf.org/rfc/rfc3986.txt</a>
*/
public final class PackagePartName implements Comparable<PackagePartName> {
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 efaa093245..b8f525a806 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationship.java @@ -60,7 +60,7 @@ public final class PackageRelationship { private String id;
/**
- * R�f�rence vers le package.
+ * Reference to the package.
*/
private Package container;
@@ -87,7 +87,7 @@ public final class PackageRelationship { /**
* Constructor.
*
- * @param packageParent
+ * @param pkg
* @param sourcePart
* @param targetUri
* @param targetMode
@@ -170,7 +170,7 @@ public final class PackageRelationship { /**
*
- * @return
+ * @return URL of the source part of this relationship
*/
public URI getSourceURI() {
if (source == null) {
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 daf2e7e090..09f3280df2 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java @@ -22,13 +22,14 @@ import java.util.ArrayList; import java.util.Iterator;
import java.util.TreeMap;
-import org.apache.log4j.Logger;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Represents a collection of PackageRelationship elements that are owned by a
@@ -40,7 +41,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidOperationException; public final class PackageRelationshipCollection implements
Iterable<PackageRelationship> {
- private static Logger logger = Logger.getLogger("org.openxml4j.opc");
+ private static POILogger logger = POILogFactory.getLogger(PackageRelationshipCollection.class);
/**
* Package relationships ordered by ID.
@@ -300,7 +301,7 @@ public final class PackageRelationshipCollection implements throws InvalidFormatException {
try {
SAXReader reader = new SAXReader();
- logger.debug("Parsing relationship: " + relPart.getPartName());
+ logger.log(POILogger.DEBUG, "Parsing relationship: " + relPart.getPartName());
Document xmlRelationshipsDoc = reader
.read(relPart.getInputStream());
@@ -352,7 +353,7 @@ public final class PackageRelationshipCollection implements if (value.indexOf("\\") != -1) {
logger
- .info("target contains \\ therefore not a valid URI"
+ .log(POILogger.INFO, "target contains \\ therefore not a valid URI"
+ value + " replaced by /");
value = value.replaceAll("\\\\", "/");
// word can save external relationship with a \ instead
@@ -361,14 +362,14 @@ public final class PackageRelationshipCollection implements target = new URI(value);
} catch (URISyntaxException e) {
- logger.error("Cannot convert " + value
+ logger.log(POILogger.ERROR, "Cannot convert " + value
+ " in a valid relationship URI-> ignored", e);
continue;
}
addRelationship(target, targetMode, type, id);
}
} catch (Exception e) {
- logger.error(e);
+ logger.log(POILogger.ERROR, e);
throw new InvalidFormatException(e.getMessage());
}
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java index 2a63f47bcf..58f6066aad 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java @@ -218,13 +218,12 @@ public final class PackagingURIHelper { }
/**
- * Combine les deux URI.
+ * Combine two URIs.
*
- * @param prefix
- * L'URI de pr�fixe.
- * @param suffix
- * L'URI de suffixe.
- * @return
+ * @param prefix the prefix URI
+ * @param suffix the suffix URI
+ *
+ * @return the combined URI
*/
public static URI combine(URI prefix, URI suffix) {
URI retUri = null;
@@ -406,11 +405,11 @@ public final class PackagingURIHelper { URI relationshipPartUri) {
if (relationshipPartUri == null)
throw new IllegalArgumentException(
- "Le param�tre relationshipPartUri ne doit pas �tre null !");
+ "Must not be null");
if (!isRelationshipPartURI(relationshipPartUri))
throw new IllegalArgumentException(
- "L'URI ne doit pas �tre celle d'une partie de type relation.");
+ "Must be a relationship part");
if (relationshipPartUri.compareTo(PACKAGE_RELATIONSHIPS_ROOT_URI) == 0)
return PACKAGE_ROOT_URI;
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 ce9d1159c7..018f76c667 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/RelationshipSource.java @@ -40,12 +40,12 @@ public interface RelationshipSource { /** * Add a relationship to a part (except relationships part). - * + * <p> * 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. - * + * </p> * @param targetPartName * Name of the target part. This one must be relative to the * source root directory of the part. 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 4f463e0df8..f3e9a578ce 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -28,7 +28,6 @@ import java.util.zip.ZipFile; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -43,6 +42,8 @@ import org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller; import org.apache.poi.openxml4j.util.ZipEntrySource;
import org.apache.poi.openxml4j.util.ZipFileZipEntrySource;
import org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Physical zip package.
@@ -52,7 +53,7 @@ import org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource; */
public final class ZipPackage extends Package {
- private static Logger logger = Logger.getLogger("org.openxml4j");
+ private static POILogger logger = POILogFactory.getLogger(ZipPackage.class);
/**
* Zip archive, as either a file on disk,
@@ -220,7 +221,7 @@ public final class ZipPackage extends Package { }
} catch (Exception e) {
// We assume we can continue, even in degraded mode ...
- logger.warn("Entry "
+ logger.log(POILogger.WARN,"Entry "
+ entry.getName()
+ " is not valid, so this part won't be add to the package.");
return null;
@@ -308,7 +309,7 @@ public final class ZipPackage extends Package { // temporary file
if (!tempFile.delete()) {
logger
- .warn("The temporary file: '"
+ .log(POILogger.WARN,"The temporary file: '"
+ targetFile.getAbsolutePath()
+ "' cannot be deleted ! Make sure that no other application use it.");
}
@@ -353,7 +354,7 @@ public final class ZipPackage extends Package { * current package
*
*
- * @see #getPart(URI)
+ * @see #getPart(PackageRelationship)
*/
@Override
protected PackagePart getPartImpl(PackagePartName partName) {
@@ -371,7 +372,6 @@ public final class ZipPackage extends Package { * The stream use to save this package.
*
* @see #save(OutputStream)
- * @see #saveInZip(ZipOutputStream)
*/
@Override
public void saveImpl(OutputStream outputStream) {
@@ -389,7 +389,7 @@ public final class ZipPackage extends Package { // we save it as well
if (this.getPartsByRelationshipType(
PackageRelationshipTypes.CORE_PROPERTIES).size() == 0) {
- logger.debug("Save core properties part");
+ logger.log(POILogger.DEBUG,"Save core properties part");
// We have to save the core properties part ...
new ZipPackagePropertiesMarshaller().marshall(
@@ -408,13 +408,13 @@ public final class ZipPackage extends Package { }
// Save package relationships part.
- logger.debug("Save package relationships");
+ logger.log(POILogger.DEBUG,"Save package relationships");
ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
zos);
// Save content type part.
- logger.debug("Save content types part");
+ logger.log(POILogger.DEBUG,"Save content types part");
this.contentTypeManager.save(zos);
// Save parts.
@@ -424,7 +424,7 @@ public final class ZipPackage extends Package { if (part.isRelationshipPart())
continue;
- logger.debug("Save part '"
+ logger.log(POILogger.DEBUG,"Save part '"
+ ZipHelper.getZipItemNameFromOPCName(part
.getPartName().getName()) + "'");
PartMarshaller marshaller = partMarshallers
@@ -449,7 +449,7 @@ public final class ZipPackage extends Package { zos.close();
} catch (Exception e) {
logger
- .error("Fail to save: an error occurs while saving the package : "
+ .log(POILogger.ERROR,"Fail to save: an error occurs while saving the package : "
+ e.getMessage());
}
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java index 18a6ca4ab4..5f40940b47 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentType.java @@ -25,28 +25,28 @@ import java.util.regex.Pattern; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
/**
- * Represents a immutable MIME ContentType value (RFC 2616 �3.7)
- *
+ * Represents a immutable MIME ContentType value (RFC 2616 §3.7)
+ * <p>
* media-type = type "/" subtype *( ";" parameter ) type = token<br>
* subtype = token<br>
- *
+ * </p><p>
* Rule M1.13 : Package implementers shall only create and only recognize parts
* with a content type; format designers shall specify a content type for each
* part included in the format. Content types for package parts shall fit the
- * definition and syntax for media types as specified in RFC 2616,��3.7.
- *
+ * definition and syntax for media types as specified in RFC 2616, \§3.7.
+ * </p><p>
* Rule M1.14: Content types shall not use linear white space either between the
* type and subtype or between an attribute and its value. Content types also
* shall not have leading or trailing white spaces. Package implementers shall
* create only such content types and shall require such content types when
* retrieving a part from a package; format designers shall specify only such
* content types for inclusion in the format.
- *
+ * </p>
* @author Julien Chable
* @version 0.1
*
- * @see http://www.ietf.org/rfc/rfc2045.txt
- * @see http://www.ietf.org/rfc/rfc2616.txt
+ * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">http://www.ietf.org/rfc/rfc2045.txt</a>
+ * @see <a href="http://www.ietf.org/rfc/rfc2616.txt">http://www.ietf.org/rfc/rfc2616.txt</a>
*/
public final class ContentType {
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 5f96d180e4..927102d6db 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 @@ -27,7 +27,6 @@ import java.util.TreeMap; import java.util.Map.Entry;
import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
@@ -42,6 +41,8 @@ import org.apache.poi.openxml4j.opc.Package; import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Manage package content types ([Content_Types].xml part).
@@ -51,7 +52,7 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper; */
public abstract class ContentTypeManager {
- protected static Logger logger = Logger.getLogger("org.openxml4j");
+ private static POILogger logger = POILogFactory.getLogger(ContentTypeManager.class);
/**
* Reference to the package using this content type manager.
@@ -95,7 +96,7 @@ public abstract class ContentTypeManager { /**
* Constructor. Parses the content of the specified input stream.
*
- * @param archive
+ * @param in
* If different of <i>null</i> then the content types part is
* retrieve and parse.
* @throws InvalidFormatException
@@ -118,43 +119,39 @@ public abstract class ContentTypeManager { /**
* Build association extention-> content type (will be stored in
* [Content_Types].xml) for example ContentType="image/png" Extension="png"
- *
+ * <p>
* [M2.8]: When adding a new part to a package, the package implementer
* shall ensure that a content type for that part is specified in the
* Content Types stream; the package implementer shall perform the steps
- * described in��9.1.2.3:
- *
+ * described in §9.1.2.3:
+ * </p><p>
* 1. Get the extension from the part name by taking the substring to the
* right of the rightmost occurrence of the dot character (.) from the
* rightmost segment.
- *
+ * </p><p>
* 2. If a part name has no extension, a corresponding Override element
* shall be added to the Content Types stream.
- *
+ * </p><p>
* 3. Compare the resulting extension with the values specified for the
* Extension attributes of the Default elements in the Content Types stream.
* The comparison shall be case-insensitive ASCII.
- *
+ * </p><p>
* 4. If there is a Default element with a matching Extension attribute,
* then the content type of the new part shall be compared with the value of
* the ContentType attribute. The comparison might be case-sensitive and
* include every character regardless of the role it plays in the
* content-type grammar of RFC 2616, or it might follow the grammar of RFC
* 2616.
- *
+ * </p><p>
* a. If the content types match, no further action is required.
- *
+ * </p><p>
* b. If the content types do not match, a new Override element shall be
* added to the Content Types stream. .
- *
+ * </p><p>
* 5. If there is no Default element with a matching Extension attribute, a
* new Default element or Override element shall be added to the Content
* Types stream.
- *
- *
- * @param partUri
- * the uri that will be stored
- * @return <b>false</b> if an error occured.
+ * </p>
*/
public void addContentType(PackagePartName partName, String contentType) {
boolean defaultCTExists = false;
@@ -197,18 +194,19 @@ public abstract class ContentTypeManager { }
/**
+ * <p>
* Delete a content type based on the specified part name. If the specified
* part name is register with an override content type, then this content
* type is remove, else the content type is remove in the default content
* type list if it exists and if no part is associated with it yet.
- *
+ * </p><p>
* Check rule M2.4: The package implementer shall require that the Content
* Types stream contain one of the following for every part in the package:
* One matching Default element One matching Override element Both a
* matching Default element and a matching Override element, in which case
* the Override element takes precedence.
- *
- * @param partUri
+ * </p>
+ * @param partName
* The part URI associated with the override content type to
* delete.
* @exception InvalidOperationException
@@ -290,34 +288,34 @@ public abstract class ContentTypeManager { /**
* Get the content type for the specified part, if any.
- *
+ * <p>
* Rule [M2.9]: To get the content type of a part, the package implementer
- * shall perform the steps described in��9.1.2.4:
- *
+ * shall perform the steps described in §9.1.2.4:
+ * </p><p>
* 1. Compare the part name with the values specified for the PartName
* attribute of the Override elements. The comparison shall be
* case-insensitive ASCII.
- *
+ * </p><p>
* 2. If there is an Override element with a matching PartName attribute,
* return the value of its ContentType attribute. No further action is
* required.
- *
+ * </p><p>
* 3. If there is no Override element with a matching PartName attribute,
* then a. Get the extension from the part name by taking the substring to
* the right of the rightmost occurrence of the dot character (.) from the
* rightmost segment. b. Check the Default elements of the Content Types
* stream, comparing the extension with the value of the Extension
* attribute. The comparison shall be case-insensitive ASCII.
- *
+ * </p><p>
* 4. If there is a Default element with a matching Extension attribute,
* return the value of its ContentType attribute. No further action is
* required.
- *
+ * </p><p>
* 5. If neither Override nor Default elements with matching attributes are
* found for the specified part name, the implementation shall not map this
* part name to a part.
- *
- * @param partUri
+ * </p>
+ * @param partName
* The URI part to check.
* @return The content type associated with the URI (in case of an override
* content type) or the extension (in case of default content type),
@@ -460,7 +458,7 @@ public abstract class ContentTypeManager { * XML parent element use to append this override type element.
* @param entry
* The values to append.
- * @see #save(ZipOutputStream)
+ * @see #save(java.io.OutputStream)
*/
private void appendSpecificTypes(Element root,
Entry<PackagePartName, String> entry) {
@@ -477,7 +475,7 @@ public abstract class ContentTypeManager { * XML parent element use to append this default type element.
* @param entry
* The values to append.
- * @see #save(ZipOutputStream)
+ * @see #save(java.io.OutputStream)
*/
private void appendDefaultType(Element root, Entry<String, String> entry) {
root.addElement(DEFAULT_TAG_NAME).addAttribute(
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java index 5f894f2510..d732357b22 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipContentTypeManager.java @@ -29,6 +29,8 @@ import org.dom4j.Document; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.Package;
import org.apache.poi.openxml4j.opc.StreamHelper;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Zip implementation of the ContentTypeManager.
@@ -38,6 +40,7 @@ import org.apache.poi.openxml4j.opc.StreamHelper; * @see ContentTypeManager
*/
public class ZipContentTypeManager extends ContentTypeManager {
+ private static POILogger logger = POILogFactory.getLogger(ZipContentTypeManager.class);
/**
* Delegate constructor to the super constructor.
@@ -81,7 +84,7 @@ public class ZipContentTypeManager extends ContentTypeManager { }
zos.closeEntry();
} catch (IOException ioe) {
- logger.error("Cannot write: " + CONTENT_TYPES_PART_NAME
+ logger.log(POILogger.ERROR, "Cannot write: " + CONTENT_TYPES_PART_NAME
+ " in Zip !", ioe);
return false;
}
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 a54bef5745..c226ba5a42 100755 --- 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 @@ -24,7 +24,6 @@ import java.net.URI; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -41,6 +40,8 @@ import org.apache.poi.openxml4j.opc.StreamHelper; import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.openxml4j.opc.internal.PartMarshaller;
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
/**
* Zip part marshaller. This marshaller is use to save any part in a zip stream.
@@ -49,7 +50,7 @@ import org.apache.poi.openxml4j.opc.internal.ZipHelper; * @version 0.1
*/
public class ZipPartMarshaller implements PartMarshaller {
- private static Logger logger = Logger.getLogger("org.openxml4j");
+ private static POILogger logger = POILogFactory.getLogger(ZipPartMarshaller.class);
/**
* Save the specified part.
@@ -60,7 +61,7 @@ public class ZipPartMarshaller implements PartMarshaller { public boolean marshall(PackagePart part, OutputStream os)
throws OpenXML4JException {
if (!(os instanceof ZipOutputStream)) {
- logger.error("Unexpected class " + os.getClass().getName());
+ logger.log(POILogger.ERROR,"Unexpected class " + os.getClass().getName());
throw new OpenXML4JException("ZipOutputStream expected !");
// Normally should happen only in developpement phase, so just throw
// exception
@@ -88,7 +89,7 @@ public class ZipPartMarshaller implements PartMarshaller { }
zos.closeEntry();
} catch (IOException ioe) {
- logger.error("Cannot write: " + part.getPartName() + ": in ZIP",
+ logger.log(POILogger.ERROR,"Cannot write: " + part.getPartName() + ": in ZIP",
ioe);
return false;
}
@@ -110,7 +111,7 @@ public class ZipPartMarshaller implements PartMarshaller { *
* @param rels
* The relationships collection to marshall.
- * @param relPartURI
+ * @param relPartName
* Part name of the relationship part to marshall.
* @param zos
* Zip output stream in which to save the XML content of the
@@ -137,19 +138,19 @@ public class ZipPartMarshaller implements PartMarshaller { .getSourcePartUriFromRelationshipPartUri(relPartName.getURI());
for (PackageRelationship rel : rels) {
- // L'�l�ment de la relation
+ // the relationship element
Element relElem = root
.addElement(PackageRelationship.RELATIONSHIP_TAG_NAME);
- // L'attribut ID
+ // the relationship ID
relElem.addAttribute(PackageRelationship.ID_ATTRIBUTE_NAME, rel
.getId());
- // L'attribut Type
+ // the relationship Type
relElem.addAttribute(PackageRelationship.TYPE_ATTRIBUTE_NAME, rel
.getRelationshipType());
- // L'attribut Target
+ // the relationship Target
String targetValue;
URI uri = rel.getTargetURI();
if (rel.getTargetMode() == TargetMode.EXTERNAL) {
@@ -157,7 +158,7 @@ public class ZipPartMarshaller implements PartMarshaller { // alter it etc
targetValue = uri.toString();
- // add TargetMode attribut (as it is external link external)
+ // add TargetMode attribute (as it is external link external)
relElem.addAttribute(
PackageRelationship.TARGET_MODE_ATTRIBUTE_NAME,
"External");
@@ -178,14 +179,13 @@ public class ZipPartMarshaller implements PartMarshaller { ZipEntry ctEntry = new ZipEntry(ZipHelper.getZipURIFromOPCName(
relPartName.getURI().toASCIIString()).getPath());
try {
- // Cr�ation de l'entr�e dans le fichier ZIP
zos.putNextEntry(ctEntry);
if (!StreamHelper.saveXmlInStream(xmlOutDoc, zos)) {
return false;
}
zos.closeEntry();
} catch (IOException e) {
- logger.error("Cannot create zip entry " + relPartName, e);
+ logger.log(POILogger.ERROR,"Cannot create zip entry " + relPartName, e);
return false;
}
return true; // success
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java index 0cb1fba941..bce033e3e3 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/signature/DigitalCertificatePart.java @@ -75,5 +75,4 @@ public final class DigitalCertificatePart extends PackagePart { return false;
}
- // TODO Introduire le concept de partie typ�e d�s cette partie
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java index f11b969c00..fc03b022ff 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java @@ -310,25 +310,26 @@ public class PackagePropertiesUnmarshaller implements PartUnmarshaller { /**
* Check the element for the following OPC compliance rules:
- *
+ * <p>
* Rule M4.2: A format consumer shall consider the use of the Markup
* Compatibility namespace to be an error.
- *
+ * </p><p>
* Rule M4.3: Producers shall not create a document element that contains
* refinements to the Dublin Core elements, except for the two specified in
* the schema: <dcterms:created> and <dcterms:modified> Consumers shall
* consider a document element that violates this constraint to be an error.
- *
+ * </p><p>
* Rule M4.4: Producers shall not create a document element that contains
* the xml:lang attribute. Consumers shall consider a document element that
* violates this constraint to be an error.
- *
+ * </p><p>
* Rule M4.5: Producers shall not create a document element that contains
* the xsi:type attribute, except for a <dcterms:created> or
* <dcterms:modified> element where the xsi:type attribute shall be present
* and shall hold the value dcterms:W3CDTF, where dcterms is the namespace
* prefix of the Dublin Core namespace. Consumers shall consider a document
* element that violates this constraint to be an error.
+ * </p>
*/
public void checkElementForOPCCompliance(Element el)
throws InvalidFormatException {
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java b/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java index 45374dcf7c..9bcea2e3ce 100755 --- a/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java @@ -46,7 +46,7 @@ public final class Nullable<E> { /**
* Get the store value if any.
*
- * @return
+ * @return the store value
*/
public E getValue() {
return value;
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java index 9f70f6f023..dfd3d38396 100755 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestContentType.java @@ -34,7 +34,7 @@ public class TestContentType extends TestCase { * recognize parts with a content type; format designers shall specify a
* content type for each part included in the format. Content types for
* package parts shall fit the definition and syntax for media types as
- * specified in RFC 2616, §3.7.
+ * specified in RFC 2616, \u00A73.7.
*/
public void testContentTypeValidation() throws InvalidFormatException {
String[] contentTypesToTest = new String[] { "text/xml",
@@ -50,7 +50,7 @@ public class TestContentType extends TestCase { * recognize parts with a content type; format designers shall specify a
* content type for each part included in the format. Content types for
* package parts shall fit the definition and syntax for media types as
- * specified in RFC 2616, §3.7.
+ * specified in RFC 2616, \u00A3.7.
*
* Check rule M1.14: Content types shall not use linear white space either
* between the type and subtype or between an attribute and its value.
|