source: contrib/MailArchiver/sources/vendor/mime4j/custom/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java @ 6785

Revision 6785, 3.7 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado codigo do MailArchiver?. Documentação na subpasta DOCS.

Line 
1/****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one   *
3 * or more contributor license agreements.  See the NOTICE file *
4 * distributed with this work for additional information        *
5 * regarding copyright ownership.  The ASF licenses this file   *
6 * to you under the Apache License, Version 2.0 (the            *
7 * "License"); you may not use this file except in compliance   *
8 * with the License.  You may obtain a copy of the License at   *
9 *                                                              *
10 *   http://www.apache.org/licenses/LICENSE-2.0                 *
11 *                                                              *
12 * Unless required by applicable law or agreed to in writing,   *
13 * software distributed under the License is distributed on an  *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15 * KIND, either express or implied.  See the License for the    *
16 * specific language governing permissions and limitations      *
17 * under the License.                                           *
18 ****************************************************************/
19
20package org.apache.james.mime4j.message;
21
22import java.io.IOException;
23import java.io.InputStream;
24
25import org.apache.james.mime4j.MimeException;
26import org.apache.james.mime4j.codec.DecodeMonitor;
27import org.apache.james.mime4j.dom.Message;
28import org.apache.james.mime4j.dom.MessageBuilder;
29import org.apache.james.mime4j.stream.MimeEntityConfig;
30import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
31
32/**
33 * Default MessageBuilder implementation delegating Message parsing to the "legacy"
34 * MessageImpl object.
35 */
36public class MessageBuilderImpl implements MessageBuilder {
37
38    private MimeBuilder mimeBuilder = null;
39    private BodyFactory bodyFactory = null;
40    private MimeEntityConfig mimeEntityConfig = null;
41    private MutableBodyDescriptorFactory mutableBodyDescriptorFactory = null;
42    private boolean contentDecoding = true;
43    private boolean flatMode = false;
44    private DecodeMonitor decodeMonitor = null;
45
46    public MessageBuilderImpl() {
47    }
48
49    public Message newMessage() {
50        return new MessageImpl();
51    }
52
53    private MimeBuilder getMimeBuilder() {
54        if (this.mimeBuilder != null) {
55            return this.mimeBuilder;
56        } else {
57            return MimeBuilder.DEFAULT;
58        }
59       
60    }
61   
62    public Message newMessage(Message source) {
63        return getMimeBuilder().copy(source);
64    }
65
66    public Message parse(InputStream source) throws MimeException, IOException {
67        return getMimeBuilder().parse(source,
68                mimeEntityConfig,
69                decodeMonitor,
70                bodyFactory,
71                mutableBodyDescriptorFactory,
72                contentDecoding,
73                flatMode);
74    }
75   
76    public void setBodyFactory(BodyFactory bodyFactory) {
77        this.bodyFactory = bodyFactory;
78    }
79
80    public void setMimeEntityConfig(MimeEntityConfig mimeEntityConfig) {
81        this.mimeEntityConfig = mimeEntityConfig;
82    }
83
84    public void setMutableBodyDescriptorFactory(
85            MutableBodyDescriptorFactory mutableBodyDescriptorFactory) {
86        this.mutableBodyDescriptorFactory  = mutableBodyDescriptorFactory;
87    }
88
89    public void setMimeBuilder(MimeBuilder mimeBuilder) {
90        this.mimeBuilder = mimeBuilder;
91    }
92
93    public void setDecodeMonitor(DecodeMonitor decodeMonitor) {
94        this.decodeMonitor = decodeMonitor;
95    }
96
97    public void setContentDecoding(boolean contentDecoding) {
98        this.contentDecoding = contentDecoding;
99    }
100
101    public void setFlatMode(boolean flatMode) {
102        this.flatMode = flatMode;
103    }
104   
105}
Note: See TracBrowser for help on using the repository browser.