jeremias 2004/04/02 01:14:52 Modified: src/java/org/apache/fop/pdf PDFTTFStream.java PDFT1Stream.java PDFFactory.java PDFDocument.java PDFOutline.java PDFObject.java PDFInfo.java PDFEncryptionJCE.java Log: Changed logging to use "static" loggers from Jakarta Commons Logging (via LogFactory). Revision Changes Path 1.4 +2 -3 xml-fop/src/java/org/apache/fop/pdf/PDFTTFStream.java Index: PDFTTFStream.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFTTFStream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PDFTTFStream.java 27 Feb 2004 17:50:31 -0000 1.3 +++ PDFTTFStream.java 2 Apr 2004 09:14:51 -0000 1.4 @@ -43,11 +43,10 @@ */ protected int output(java.io.OutputStream stream) throws java.io.IOException { - getDocumentSafely().getLogger().debug("Writing " - + origLength + " bytes of TTF font data"); + log.debug("Writing " + origLength + " bytes of TTF font data"); int length = super.output(stream); - getDocumentSafely().getLogger().debug("Embedded TrueType/OpenType font"); + log.debug("Embedded TrueType/OpenType font"); return length; } 1.4 +2 -3 xml-fop/src/java/org/apache/fop/pdf/PDFT1Stream.java Index: PDFT1Stream.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFT1Stream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PDFT1Stream.java 27 Feb 2004 17:50:31 -0000 1.3 +++ PDFT1Stream.java 2 Apr 2004 09:14:51 -0000 1.4 @@ -53,11 +53,10 @@ if (pfb == null) { throw new IllegalStateException("pfb must not be null at this point"); } - getDocumentSafely().getLogger().debug("Writing " - + pfb.getLength() + " bytes of Type 1 font data"); + log.debug("Writing " + pfb.getLength() + " bytes of Type 1 font data"); int length = super.output(stream); - getDocumentSafely().getLogger().debug("Embedded Type1 font"); + log.debug("Embedded Type1 font"); return length; } 1.10 +7 -5 xml-fop/src/java/org/apache/fop/pdf/PDFFactory.java Index: PDFFactory.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFFactory.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PDFFactory.java 31 Mar 2004 10:55:06 -0000 1.9 +++ PDFFactory.java 2 Apr 2004 09:14:51 -0000 1.10 @@ -28,6 +28,8 @@ // Apache libs import org.apache.avalon.framework.container.ContainerUtil; import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; // FOP import org.apache.fop.fonts.CIDFont; @@ -50,6 +52,8 @@ private PDFDocument document; + private Log log = LogFactory.getLog("org.apache.fop.pdf"); + /** * Creates a new PDFFactory. * @param document the parent PDFDocument needed to register the generated @@ -1103,7 +1107,7 @@ try { in = getDocument().resolveURI(font.getEmbedFileName()); } catch (Exception e) { - getDocument().getLogger().error("Failed to embed fontfile: " + log.error("Failed to embed fontfile: " + font.getEmbedFileName() + "(" + e.getMessage() + ")"); } @@ -1116,7 +1120,7 @@ this.getClass().getResourceAsStream( font.getEmbedResourceName())); } catch (Exception e) { - getDocument().getLogger().error( + log.error( "Failed to embed fontresource: " + font.getEmbedResourceName() + "(" + e.getMessage() + ")"); @@ -1133,8 +1137,6 @@ FontFileReader reader = new FontFileReader(in); TTFSubSetFile subset = new TTFSubSetFile(); - subset.setLogger(getDocument().getLogger()); - byte[] subsetFont = subset.readFont(reader, mbfont.getTTCName(), mbfont.getUsedGlyphs()); // Only TrueType CID fonts are supported now @@ -1166,7 +1168,7 @@ } } } catch (IOException ioe) { - getDocument().getLogger().error( + log.error( "Failed to embed font [" + desc + "] " + desc.getFontName(), ioe); return (PDFStream) null; 1.9 +3 -21 xml-fop/src/java/org/apache/fop/pdf/PDFDocument.java Index: PDFDocument.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFDocument.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- PDFDocument.java 31 Mar 2004 10:55:06 -0000 1.8 +++ PDFDocument.java 2 Apr 2004 09:14:51 -0000 1.9 @@ -29,6 +29,7 @@ import java.util.Iterator; import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /* image support modified from work of BoBoGi */ /* font support based on work by Takayuki Takeuchi */ @@ -67,7 +68,7 @@ */ public static final String ENCODING = "ISO-8859-1"; - private Log logger; + private Log log = LogFactory.getLog("org.apache.fop.pdf"); /** * the current character position @@ -234,14 +235,6 @@ } /** - * Sets the Commons-Logging instance for this class - * @param logger The Commons-Logging instance - */ - public void setLogger(Log logger) { - this.logger = logger; - } - - /** * Returns the factory for PDF objects. * @return PDFFactory the factory */ @@ -260,17 +253,6 @@ } /** - * Helper method to allow sub-classes to aquire logger. - * - * <p>There is no performance penalty as this is a final method - * and will be inlined by the JVM.</p> - * @return the Logger - */ - protected final Log getLogger() { - return this.logger; - } - - /** * Converts text to a byte array for writing to a PDF file. * @param text text to convert/encode * @return byte[] the resulting byte array @@ -485,7 +467,7 @@ /[EMAIL PROTECTED] this cast is ugly. PDFObject should be transformed to an interface. */ addTrailerObject((PDFObject)this.encryption); } else { - getLogger().warn( + log.warn( "PDF encryption is unavailable. PDF will be " + "generated without encryption."); } 1.4 +3 -3 xml-fop/src/java/org/apache/fop/pdf/PDFOutline.java Index: PDFOutline.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFOutline.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PDFOutline.java 27 Feb 2004 17:50:31 -0000 1.3 +++ PDFOutline.java 2 Apr 2004 09:14:51 -0000 1.4 @@ -92,8 +92,8 @@ */ public void addOutline(PDFOutline outline) { if (subentries.size() > 0) { - outline.prev = - (PDFOutline)subentries.get(subentries.size() - 1); + outline.prev + = (PDFOutline)subentries.get(subentries.size() - 1); outline.prev.next = outline; } else { first = outline; @@ -163,7 +163,7 @@ } bout.write(encode(">> endobj\n")); } catch (IOException ioe) { - getDocumentSafely().getLogger().error("Ignored I/O exception", ioe); + log.error("Ignored I/O exception", ioe); } return bout.toByteArray(); } 1.4 +7 -2 xml-fop/src/java/org/apache/fop/pdf/PDFObject.java Index: PDFObject.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PDFObject.java 27 Feb 2004 17:50:31 -0000 1.3 +++ PDFObject.java 2 Apr 2004 09:14:51 -0000 1.4 @@ -22,6 +22,9 @@ import java.io.IOException; import java.io.OutputStream; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * generic PDF object. * @@ -31,6 +34,9 @@ */ public abstract class PDFObject { + /** logger for all PDFObjects (and descendants) */ + protected static Log log = LogFactory.getLog(PDFObject.class.getPackage().getName()); + /** * the object's number */ @@ -60,7 +66,6 @@ public int getObjectNumber() { if (this.objnum == 0) { throw new IllegalStateException("Object has no number assigned: " + this.toString()); - //System.out.println("Object has no number assigned: " + this.toString()); } return this.objnum; } @@ -80,7 +85,7 @@ */ public void setObjectNumber(int objnum) { this.objnum = objnum; - //System.out.println("Assigning "+this+" object number "+objnum); + log.trace("Assigning " + this + " object number " + objnum); } /** 1.5 +2 -2 xml-fop/src/java/org/apache/fop/pdf/PDFInfo.java Index: PDFInfo.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFInfo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PDFInfo.java 27 Feb 2004 17:50:31 -0000 1.4 +++ PDFInfo.java 2 Apr 2004 09:14:51 -0000 1.5 @@ -153,7 +153,7 @@ bout.write(encode("\n")); // creation date in form (D:YYYYMMDDHHmmSSOHH'mm') - if(creationDate==null) { + if (creationDate == null) { creationDate = new Date(); } final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -162,7 +162,7 @@ bout.write(encodeString("D:" + str)); bout.write(encode("\n>>\nendobj\n")); } catch (IOException ioe) { - getDocumentSafely().getLogger().error("Ignored I/O exception", ioe); + log.error("Ignored I/O exception", ioe); } return bout.toByteArray(); } 1.5 +8 -8 xml-fop/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java Index: PDFEncryptionJCE.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PDFEncryptionJCE.java 27 Feb 2004 17:50:31 -0000 1.4 +++ PDFEncryptionJCE.java 2 Apr 2004 09:14:51 -0000 1.5 @@ -57,8 +57,8 @@ this.encryption = encryption; this.number = number; this.generation = generation; - //System.out.println("new encryption filter for number " - // +number+" and generation "+generation); + log.debug("new encryption filter for number " + + number + " and generation " + generation); } /** @@ -108,11 +108,11 @@ } - private static final char [] PAD = - { 0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, - 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, - 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, - 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A }; + private static final char [] PAD + = {0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, + 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, + 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, + 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A}; /** Value of PRINT permission */ public static final int PERMISSION_PRINT = 4; @@ -357,7 +357,7 @@ if (this.encryptionKey == null) { throw new IllegalStateException("PDF Encryption has not been initialized"); } - //getDocument().getLogger().debug("encrypting with for "+number+" "+generation); + log.debug("encrypting with for " + number + " " + generation); byte[] hash = calcHash(number, generation); return encryptWithHash(data, hash, hash.length);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]