commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r501739 - /jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java
Date Wed, 31 Jan 2007 06:03:57 GMT
Author: bayard
Date: Tue Jan 30 22:03:55 2007
New Revision: 501739

URL: http://svn.apache.org/viewvc?view=rev&rev=501739
Log:
Applying performance enhancement requested in EMAIL-60

Modified:
    jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java

Modified: jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java?view=diff&rev=501739&r1=501738&r2=501739
==============================================================================
--- jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java (original)
+++ jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java Tue
Jan 30 22:03:55 2007
@@ -72,6 +72,10 @@
     /** Embedded images */
     protected List inlineImages = new ArrayList();
 
+    /** HTML prefix and suffix for default HTML mail */
+    private static final String HTML_MESSAGE_START = "<html><body><pre>";
+    private static final String HTML_MESSAGE_END = "</pre></body></html>";
+
     /**
      * Set the text content.
      *
@@ -136,12 +140,17 @@
 
         setTextMsg(msg);
 
-        setHtmlMsg(
-            new StringBuffer()
-                .append("<html><body><pre>")
-                .append(msg)
-                .append("</pre></body></html>")
-                .toString());
+        StringBuffer htmlMsgBuf = new StringBuffer(
+            msg.length()
+            + HTML_MESSAGE_START.length()
+            + HTML_MESSAGE_END.length()
+        );
+
+        htmlMsgBuf.append(HTML_MESSAGE_START)
+            .append(msg)
+            .append(HTML_MESSAGE_END);
+
+        setHtmlMsg(htmlMsgBuf.toString());
 
         return this;
     }
@@ -162,7 +171,7 @@
     		throw new EmailException("Invalid URL", e);
     	}
     }
-    
+
     /**
      * Embeds an URL in the HTML.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message