1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.mercury.maildir.util;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
18 import java.util.Date;
19 import java.util.Enumeration;
20 import javax.activation.DataHandler;
21 import javax.mail.Address;
22 import javax.mail.Folder;
23 import javax.mail.Message;
24 import javax.mail.MessagingException;
25 import javax.mail.Multipart;
26 import javax.mail.internet.InternetHeaders;
27 import javax.mail.internet.MimeMessage;
28 import javax.mail.search.SearchTerm;
29
30
31
32
33
34
35
36
37 public class LazyParsingMessage extends MessageBase {
38
39
40 protected boolean parsed;
41
42
43 protected InputStream inputStream;
44
45
46
47
48
49
50
51 protected LazyParsingMessage(Folder folder, int msgnum) throws MessagingException {
52 super(folder, msgnum);
53 }
54
55
56
57
58
59
60 public LazyParsingMessage(MimeMessage message) throws MessagingException {
61 super(message);
62 }
63
64
65
66
67
68 protected boolean isParsed() {
69 return parsed;
70 }
71
72
73
74
75
76
77 protected void parse(InputStream is) throws MessagingException {
78 inputStream = is;
79 }
80
81
82
83
84
85
86 protected synchronized void parseImpl() throws MessagingException {
87 if (!parsed) {
88 super.parse(inputStream);
89 parsed = true;
90 }
91 }
92
93
94
95
96
97
98
99 protected InternetHeaders createInternetHeaders(InputStream inputStream) throws MessagingException {
100 return new InternetHeadersImpl(inputStream);
101 }
102
103
104
105
106
107
108
109
110 public void addFrom(Address[] addresses) throws MessagingException {
111 if (!parsed) { parseImpl(); }
112 super.addFrom(addresses);
113 }
114
115
116
117
118
119
120
121 public void addHeader(String name, String value) throws MessagingException {
122 if (!parsed) { parseImpl(); }
123 super.addHeader(name, value);
124 }
125
126
127
128
129
130
131 public void addHeaderLine(String line) throws MessagingException {
132 if (!parsed) { parseImpl(); }
133 super.addHeaderLine(line);
134 }
135
136
137
138
139
140
141
142 public void addRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
143 if (!parsed) { parseImpl(); }
144 super.addRecipients(type, addresses);
145 }
146
147
148
149
150
151
152
153 public void addRecipients(Message.RecipientType type, String addresses) throws MessagingException {
154 if (!parsed) { parseImpl(); }
155 super.addRecipients(type, addresses);
156 }
157
158
159
160
161
162
163 public Enumeration<?> getAllHeaderLines() throws MessagingException {
164 if (!parsed) { parseImpl(); }
165 return super.getAllHeaderLines();
166 }
167
168
169
170
171
172
173 public Enumeration<?> getAllHeaders() throws MessagingException {
174 if (!parsed) { parseImpl(); }
175 return super.getAllHeaders();
176 }
177
178
179
180
181
182
183 public Address[] getAllRecipients() throws MessagingException {
184 if (!parsed) { parseImpl(); }
185 return super.getAllRecipients();
186 }
187
188
189
190
191
192
193
194 public Object getContent() throws IOException, MessagingException {
195 if (!parsed) { parseImpl(); }
196 return super.getContent();
197 }
198
199
200
201
202
203
204 public String getContentID() throws MessagingException {
205 if (!parsed) { parseImpl(); }
206 return super.getContentID();
207 }
208
209
210
211
212
213
214 public String[] getContentLanguage() throws MessagingException {
215 if (!parsed) { parseImpl(); }
216 return super.getContentLanguage();
217 }
218
219
220
221
222
223
224 public String getContentMD5() throws MessagingException {
225 if (!parsed) { parseImpl(); }
226 return super.getContentMD5();
227 }
228
229
230
231
232
233
234 protected InputStream getContentStream() throws MessagingException {
235 if (!parsed) { parseImpl(); }
236 return super.getContentStream();
237 }
238
239
240
241
242
243
244 public String getContentType() throws MessagingException {
245 if (!parsed) { parseImpl(); }
246 return super.getContentType();
247 }
248
249
250
251
252
253
254 public DataHandler getDataHandler() throws MessagingException {
255 if (!parsed) { parseImpl(); }
256 return super.getDataHandler();
257 }
258
259
260
261
262
263
264 public String getDescription() throws MessagingException {
265 if (!parsed) { parseImpl(); }
266 return super.getDescription();
267 }
268
269
270
271
272
273
274 public String getDisposition() throws MessagingException {
275 if (!parsed) { parseImpl(); }
276 return super.getDisposition();
277 }
278
279
280
281
282
283
284 public String getEncoding() throws MessagingException {
285 if (!parsed) { parseImpl(); }
286 return super.getEncoding();
287 }
288
289
290
291
292
293
294 public String getFileName() throws MessagingException {
295 if (!parsed) { parseImpl(); }
296 return super.getFileName();
297 }
298
299
300
301
302
303
304 public Address[] getFrom() throws MessagingException {
305 if (!parsed) { parseImpl(); }
306 return super.getFrom();
307 }
308
309
310
311
312
313
314
315 public String[] getHeader(String name) throws MessagingException {
316 if (!parsed) { parseImpl(); }
317 return super.getHeader(name);
318 }
319
320
321
322
323
324
325
326
327 public String getHeader(String name, String delimiter) throws MessagingException {
328 if (!parsed) { parseImpl(); }
329 return super.getHeader(name, delimiter);
330 }
331
332
333
334
335
336
337
338 public InputStream getInputStream() throws IOException, MessagingException {
339 if (!parsed) { parseImpl(); }
340 return super.getInputStream();
341 }
342
343
344
345
346
347
348 public int getLineCount() throws MessagingException {
349 if (!parsed) { parseImpl(); }
350 return super.getLineCount();
351 }
352
353
354
355
356
357
358
359 public Enumeration<?> getMatchingHeaderLines(String[] names) throws MessagingException {
360 if (!parsed) { parseImpl(); }
361 return super.getMatchingHeaderLines(names);
362 }
363
364
365
366
367
368
369
370 public Enumeration<?> getMatchingHeaders(String[] names) throws MessagingException {
371 if (!parsed) { parseImpl(); }
372 return super.getMatchingHeaders(names);
373 }
374
375
376
377
378
379
380 public String getMessageID() throws MessagingException {
381 if (!parsed) { parseImpl(); }
382 return super.getMessageID();
383 }
384
385
386
387
388
389
390
391 public Enumeration<?> getNonMatchingHeaderLines(String[] names) throws MessagingException {
392 if (!parsed) { parseImpl(); }
393 return super.getNonMatchingHeaderLines(names);
394 }
395
396
397
398
399
400
401
402 public Enumeration<?> getNonMatchingHeaders(String[] names) throws MessagingException {
403 if (!parsed) { parseImpl(); }
404 return super.getNonMatchingHeaders(names);
405 }
406
407
408
409
410
411
412 public InputStream getRawInputStream() throws MessagingException {
413 if (!parsed) { parseImpl(); }
414 return super.getRawInputStream();
415 }
416
417
418
419
420
421
422
423 public Address[] getRecipients(Message.RecipientType type) throws MessagingException {
424 if (!parsed) { parseImpl(); }
425 return super.getRecipients(type);
426 }
427
428
429
430
431
432
433 public Address[] getReplyTo() throws MessagingException {
434 if (!parsed) { parseImpl(); }
435 return super.getReplyTo();
436 }
437
438
439
440
441
442
443 public Address getSender() throws MessagingException {
444 if (!parsed) { parseImpl(); }
445 return super.getSender();
446 }
447
448
449
450
451
452
453 public Date getSentDate() throws MessagingException {
454 if (!parsed) { parseImpl(); }
455 return super.getSentDate();
456 }
457
458
459
460
461
462
463 public int getSize() throws MessagingException {
464 if (!parsed) { parseImpl(); }
465 return super.getSize();
466 }
467
468
469
470
471
472
473 public String getSubject() throws MessagingException {
474 if (!parsed) { parseImpl(); }
475 return super.getSubject();
476 }
477
478
479
480
481
482
483
484 public boolean isMimeType(String mimeType) throws MessagingException {
485 if (!parsed) { parseImpl(); }
486 return super.isMimeType(mimeType);
487 }
488
489
490
491
492
493
494 public void removeHeader(String name) throws MessagingException {
495 if (!parsed) { parseImpl(); }
496 super.removeHeader(name);
497 }
498
499
500
501
502
503
504
505 public Message reply(boolean replyToAll) throws MessagingException {
506 if (!parsed) { parseImpl(); }
507 return super.reply(replyToAll);
508 }
509
510
511
512
513
514 public void saveChanges() throws MessagingException {
515 if (!parsed) { parseImpl(); }
516 super.saveChanges();
517 }
518
519
520
521
522
523
524 public void setContent(Multipart mp) throws MessagingException {
525 if (!parsed) { parseImpl(); }
526 super.setContent(mp);
527 }
528
529
530
531
532
533
534
535 public void setContent(Object o, String type) throws MessagingException {
536 if (!parsed) { parseImpl(); }
537 super.setContent(o, type);
538 }
539
540
541
542
543
544
545 public void setContentID(String cid) throws MessagingException {
546 if (!parsed) { parseImpl(); }
547 super.setContentID(cid);
548 }
549
550
551
552
553
554
555 public void setContentLanguage(String[] languages) throws MessagingException {
556 if (!parsed) { parseImpl(); }
557 super.setContentLanguage(languages);
558 }
559
560
561
562
563
564
565 public void setContentMD5(String md5) throws MessagingException {
566 if (!parsed) { parseImpl(); }
567 super.setContentMD5(md5);
568 }
569
570
571
572
573
574
575 public void setDataHandler(DataHandler dh) throws MessagingException {
576 if (!parsed) { parseImpl(); }
577 super.setDataHandler(dh);
578 }
579
580
581
582
583
584
585 public void setDescription(String description) throws MessagingException {
586 if (!parsed) { parseImpl(); }
587 super.setDescription(description);
588 }
589
590
591
592
593
594
595
596 public void setDescription(String description, String charset) throws MessagingException {
597 if (!parsed) { parseImpl(); }
598 super.setDescription(description, charset);
599 }
600
601
602
603
604
605
606 public void setDisposition(String disposition) throws MessagingException {
607 if (!parsed) { parseImpl(); }
608 super.setDisposition(disposition);
609 }
610
611
612
613
614
615
616 public void setFileName(String filename) throws MessagingException {
617 if (!parsed) { parseImpl(); }
618 super.setFileName(filename);
619 }
620
621
622
623
624
625 public void setFrom() throws MessagingException {
626 if (!parsed) { parseImpl(); }
627 super.setFrom();
628 }
629
630
631
632
633
634
635 public void setFrom(Address address) throws MessagingException {
636 if (!parsed) { parseImpl(); }
637 super.setFrom(address);
638 }
639
640
641
642
643
644
645
646 public void setHeader(String name, String value) throws MessagingException {
647 if (!parsed) { parseImpl(); }
648 super.setHeader(name, value);
649 }
650
651
652
653
654
655
656
657 public void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
658 if (!parsed) { parseImpl(); }
659 super.setRecipients(type, addresses);
660 }
661
662
663
664
665
666
667
668 public void setRecipients(Message.RecipientType type, String addresses) throws MessagingException {
669 if (!parsed) { parseImpl(); }
670 super.setRecipients(type, addresses);
671 }
672
673
674
675
676
677
678 public void setReplyTo(Address[] addresses) throws MessagingException {
679 if (!parsed) { parseImpl(); }
680 super.setReplyTo(addresses);
681 }
682
683
684
685
686
687
688 public void setSender(Address address) throws MessagingException {
689 if (!parsed) { parseImpl(); }
690 super.setSender(address);
691 }
692
693
694
695
696
697
698 public void setSentDate(Date d) throws MessagingException {
699 if (!parsed) { parseImpl(); }
700 super.setSentDate(d);
701 }
702
703
704
705
706
707
708 public void setSubject(String subject) throws MessagingException {
709 if (!parsed) { parseImpl(); }
710 super.setSubject(subject);
711 }
712
713
714
715
716
717
718
719 public void setSubject(String subject, String charset) throws MessagingException {
720 if (!parsed) { parseImpl(); }
721 super.setSubject(subject, charset);
722 }
723
724
725
726
727
728
729 public void setText(String text) throws MessagingException {
730 if (!parsed) { parseImpl(); }
731 super.setText(text);
732 }
733
734
735
736
737
738
739
740 public void setText(String text, String charset) throws MessagingException {
741 if (!parsed) { parseImpl(); }
742 super.setText(text, charset);
743 }
744
745
746
747
748
749 protected void updateHeaders() throws MessagingException {
750 if (!parsed) { parseImpl(); }
751 super.updateHeaders();
752 }
753
754
755
756
757
758
759
760 public void writeTo(OutputStream os) throws IOException, MessagingException {
761 if (!parsed) { parseImpl(); }
762 super.writeTo(os);
763 }
764
765
766
767
768
769
770
771
772 public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
773 if (!parsed) { parseImpl(); }
774 super.writeTo(os, ignoreList);
775 }
776
777
778
779
780
781
782
783 public void addRecipient(Message.RecipientType type, Address address) throws MessagingException {
784 if (!parsed) { parseImpl(); }
785 super.addRecipient(type, address);
786 }
787
788
789
790
791
792
793
794 public boolean match(SearchTerm term) throws MessagingException {
795 if (!parsed) { parseImpl(); }
796 return super.match(term);
797 }
798
799
800
801
802
803
804
805 public void setRecipient(Message.RecipientType type, Address address) throws MessagingException {
806 if (!parsed) { parseImpl(); }
807 super.setRecipient(type, address);
808 }
809
810
811
812
813
814 public boolean isExpunged() {
815 return super.isExpunged();
816 }
817
818 }