01: package org.columba.mail.gui.message.util;
02:
03: import java.io.BufferedInputStream;
04: import java.io.File;
05: import java.io.FileInputStream;
06: import java.io.IOException;
07: import java.io.InputStream;
08: import java.nio.charset.Charset;
09:
10: import org.columba.mail.gui.attachment.IAttachmentContext;
11: import org.columba.ristretto.message.MimeHeader;
12:
13: public class AttachmentContext implements IAttachmentContext {
14:
15: private File file;
16:
17: private MimeHeader header;
18:
19: public AttachmentContext(final File file, final MimeHeader header) {
20: this .file = file;
21: this .header = header;
22: }
23:
24: public InputStream getContent() throws IOException {
25: return new BufferedInputStream(new FileInputStream(file));
26: }
27:
28: public String getFileName() {
29: return header.getFileName();
30: }
31:
32: public String getContentType() {
33: return header.getMimeType().getType();
34: }
35:
36: public String getContentSubtype() {
37: return header.getMimeType().getSubtype();
38: }
39:
40: public Charset getCharset() {
41: return header.getCharset();
42: }
43:
44: public String getContentParameter(String key) {
45: return header.getContentParameter(key);
46: }
47:
48: public String getContentId() {
49: return header.getContentID();
50: }
51:
52: public String getContentDescription() {
53: return header.getContentDescription();
54: }
55:
56: public String getDispositionParameter(String key) {
57: return header.getDispositionParameter(key);
58: }
59:
60: }
|