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");
}
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;
}
/*
}
*/
}
+
/*
public static class Boundary implements Stream.Transformer {
private final String boundary;