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

Revision 6785, 4.2 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 org.apache.james.mime4j.util.ByteSequence;
23import org.apache.james.mime4j.util.ContentUtil;
24
25/**
26 * Represents a MIME multipart body (see RFC 2045).A multipart body has a
27 * ordered list of body parts. The multipart body also has a preamble and
28 * epilogue. The preamble consists of whatever characters appear before the
29 * first body part while the epilogue consists of whatever characters come after
30 * the last body part.
31 */
32public class MultipartImpl extends AbstractMultipart {
33
34    private ByteSequence preamble;
35    private transient String preambleStrCache;
36    private transient boolean preambleComputed = false;
37    private ByteSequence epilogue;
38    private transient String epilogueStrCache;
39    private transient boolean epilogueComputed = false;
40
41    /**
42     * Creates a new empty <code>Multipart</code> instance.
43     */
44    public MultipartImpl(String subType) {
45        super(subType);
46        preamble = null;
47        preambleStrCache = null;
48        preambleComputed = true;
49        epilogue = null;
50        epilogueStrCache = null;
51        epilogueComputed = true;
52    }
53
54    // package private for now; might become public someday
55    public ByteSequence getPreambleRaw() {
56        return preamble;
57    }
58
59    public void setPreambleRaw(ByteSequence preamble) {
60        this.preamble = preamble;
61        this.preambleStrCache = null;
62        this.preambleComputed = false;
63    }
64
65    /**
66     * Gets the preamble.
67     *
68     * @return the preamble.
69     */
70    @Override
71    public String getPreamble() {
72        if (!preambleComputed) {
73            preambleStrCache = preamble != null ? ContentUtil.decode(preamble) : null;
74            preambleComputed = true;
75        }
76        return preambleStrCache;
77    }
78
79    /**
80     * Sets the preamble.
81     *
82     * @param preamble
83     *            the preamble.
84     */
85    @Override
86    public void setPreamble(String preamble) {
87        this.preamble = preamble != null ? ContentUtil.encode(preamble) : null;
88        this.preambleStrCache = preamble;
89        this.preambleComputed = true;
90    }
91
92    // package private for now; might become public someday
93    public ByteSequence getEpilogueRaw() {
94        return epilogue;
95    }
96
97    public void setEpilogueRaw(ByteSequence epilogue) {
98        this.epilogue = epilogue;
99        this.epilogueStrCache = null;
100        this.epilogueComputed = false;
101    }
102
103    /**
104     * Gets the epilogue.
105     *
106     * @return the epilogue.
107     */
108    @Override
109    public String getEpilogue() {
110        if (!epilogueComputed) {
111            epilogueStrCache = epilogue != null ? ContentUtil.decode(epilogue) : null;
112            epilogueComputed = true;
113        }
114        return epilogueStrCache;
115    }
116
117    /**
118     * Sets the epilogue.
119     *
120     * @param epilogue
121     *            the epilogue.
122     */
123    @Override
124    public void setEpilogue(String epilogue) {
125        this.epilogue = epilogue != null ? ContentUtil.encode(epilogue) : null;
126        this.epilogueStrCache = epilogue;
127        this.epilogueComputed = true;
128    }
129
130}
Note: See TracBrowser for help on using the repository browser.