james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1094130 - /james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeWriter.java
Date Sun, 17 Apr 2011 10:41:47 GMT
Author: olegk
Date: Sun Apr 17 10:41:46 2011
New Revision: 1094130

URL: http://svn.apache.org/viewvc?rev=1094130&view=rev
Log:
MIME4J-191: Added MimeWriter#writeField method

Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeWriter.java

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeWriter.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeWriter.java?rev=1094130&r1=1094129&r2=1094130&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeWriter.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeWriter.java Sun
Apr 17 10:41:46 2011
@@ -184,6 +184,36 @@ public class MimeWriter {
     }
 
     /**
+     * Write the specified <code>Field</code> to the specified
+     * <code>OutputStream</code>.
+     * 
+     * @param field
+     *            the <code>Field</code> to write.
+     * @param out
+     *            the OutputStream to write to.
+     * @throws IOException
+     *             if an I/O error occurs.
+     */
+    public void writeField(Field field, OutputStream out) throws IOException {
+        ByteSequence raw = null;
+        if (field instanceof FieldRawData) {
+            raw = ((FieldRawData) field).getRaw();
+        }
+        if (raw == null) {
+            StringBuilder buf = new StringBuilder();
+            buf.append(field.getName());
+            buf.append(": ");
+            String body = field.getBody();
+            if (body != null) {
+                buf.append(body);
+            }
+            raw = ContentUtil.encode(MimeUtil.fold(buf.toString(), 0));
+        }
+        writeBytes(raw, out);
+        out.write(CRLF);
+    }
+
+    /**
      * Write the specified <code>Header</code> to the specified
      * <code>OutputStream</code>.
      * 
@@ -196,22 +226,7 @@ public class MimeWriter {
      */
     public void writeHeader(Header header, OutputStream out) throws IOException {
         for (Field field : header) {
-            ByteSequence raw = null;
-            if (field instanceof FieldRawData) {
-                raw = ((FieldRawData) field).getRaw();
-            }
-            if (raw == null) {
-                StringBuilder buf = new StringBuilder();
-                buf.append(field.getName());
-                buf.append(": ");
-                String body = field.getBody();
-                if (body != null) {
-                    buf.append(body);
-                }
-                raw = ContentUtil.encode(MimeUtil.fold(buf.toString(), 0));
-            }
-            writeBytes(raw, out);
-            out.write(CRLF);
+            writeField(field, out);
         }
 
         out.write(CRLF);



Mime
View raw message