minor cleanup in MIME.java
authoradam <adam@megacz.com>
Sat, 17 Mar 2007 10:33:35 +0000 (10:33 +0000)
committeradam <adam@megacz.com>
Sat, 17 Mar 2007 10:33:35 +0000 (10:33 +0000)
darcs-hash:20070317103335-5007d-62f4bbcc5ea1c05b8f9b5c97b470c5ac3147c124.gz

src/org/ibex/mail/MIME.java

index 36d125b..e17dd8c 100644 (file)
@@ -33,18 +33,6 @@ public class MIME {
         public long getLength()     { return all.getLength(); }
         public Fountain getBody()   { return body; }
 
-        private class BodyFountain implements Fountain {
-            public int getNumLines()  { return Stream.countLines(getStream()); }
-            public long getLength()   { return Part.this.getLength() - headers.getLength() - 2 /*FIXME: correct?*/; }
-            public Stream getStream() {
-                return /*
-                         "quoted-printable".equals(encoding) ? Encode.QuotedPrintable.decode(body.toString(),false) :
-                         "base64".equals(encoding)           ? Encode.fromBase64(body.toString()) :
-                       */
-                    Headers.Original.skip(all.getStream());
-            }
-        }
-
         public Part(Fountain all) {
             this.headers     = new Headers(all);
             String ctype     = headers.get("content-type");
@@ -58,7 +46,17 @@ public class MIME {
             }
             this.contentType = new ContentType(ctype, headers.get("content-description"), headers.get("content-id"), encoding);
             this.all = all;
-            this.body = new BodyFountain();
+            this.body = new Fountain() {
+                    public int getNumLines()  { return Stream.countLines(getStream()); }
+                    public long getLength()   { return Part.this.getLength() - headers.getLength() - 2 /*CRLF*/; }
+                    public Stream getStream() { return transformBodyStream(Headers.skip(Part.this.all.getStream())); }
+                };
+        }
+
+        private Stream transformBodyStream(Stream body) {
+            //"quoted-printable".equals(encoding) ? Encode.QuotedPrintable.decode(body.toString(),false) :
+            //"base64".equals(encoding)           ? Encode.fromBase64(body.toString()) :
+            return body;
         }
 
         /*
@@ -78,6 +76,7 @@ public class MIME {
         }
         */
     }
+
     /*
     public static class Boundary implements Stream.Transformer {
         private final String boundary;