001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.message;
019:
020: import org.columba.ristretto.io.Source;
021: import org.columba.ristretto.message.Header;
022: import org.columba.ristretto.message.Message;
023: import org.columba.ristretto.message.MimePart;
024: import org.columba.ristretto.message.MimeTree;
025:
026: /**
027: * Adds Columba-specific features to the default {@link Message}object found in
028: * the Ristretto API.
029: * <p>
030: *
031: * @author fdietz, tstich
032: */
033: public class ColumbaMessage implements IColumbaMessage {
034:
035: protected IColumbaHeader columbaHeader;
036:
037: protected Message message;
038:
039: protected MimePart bodyPart;
040:
041: public ColumbaMessage() {
042: this (new ColumbaHeader());
043: }
044:
045: public ColumbaMessage(IColumbaHeader header) {
046: columbaHeader = header;
047: message = new Message();
048:
049: }
050:
051: public ColumbaMessage(Message m) {
052: columbaHeader = new ColumbaHeader(m.getHeader());
053: message = m;
054:
055: }
056:
057: public ColumbaMessage(Header header) {
058: columbaHeader = new ColumbaHeader(header);
059: message = new Message();
060: message.setHeader(header);
061:
062: }
063:
064: public ColumbaMessage(IColumbaHeader h, Message m) {
065: columbaHeader = h;
066:
067: columbaHeader.setHeader(m.getHeader());
068: message = m;
069: }
070:
071: public ColumbaMessage(ColumbaMessage m) {
072: this .columbaHeader = m.columbaHeader;
073:
074: this .message = m.message;
075: this .bodyPart = m.bodyPart;
076: }
077:
078: public void setBodyPart(MimePart body) {
079: bodyPart = body;
080: }
081:
082: public void setUID(Object o) {
083: if (o != null) {
084: columbaHeader.getAttributes().put("columba.uid", o);
085: } else {
086: columbaHeader.getAttributes().put("columba.uid", "");
087: }
088:
089: //uid = o;
090: }
091:
092: public Object getUID() {
093: return getHeader().getAttributes().get("columba.uid");
094: }
095:
096: public MimeTree getMimePartTree() {
097: return message.getMimePartTree();
098: }
099:
100: public void setMimePartTree(MimeTree ac) {
101: message.setMimePartTree(ac);
102: }
103:
104: public void freeMemory() {
105: }
106:
107: /*
108: * (non-Javadoc)
109: *
110: * @see org.columba.ristretto.message.Message#getHeader()
111: */
112: public IColumbaHeader getHeader() {
113: return columbaHeader;
114: }
115:
116: /*
117: * (non-Javadoc)
118: *
119: * @see org.columba.ristretto.message.Message#setHeader(org.columba.ristretto.message.Header)
120: */
121: public void setHeader(IColumbaHeader h) {
122: columbaHeader = h;
123: }
124:
125: /*
126: * (non-Javadoc)
127: *
128: * @see org.columba.ristretto.message.Message#getBodyPart()
129: */
130: public MimePart getBodyPart() {
131: return bodyPart;
132: }
133:
134: /*
135: * (non-Javadoc)
136: *
137: * @see org.columba.ristretto.message.Message#getMimePart(int)
138: */
139: public MimePart getMimePart(int number) {
140: return message.getMimePart(number);
141: }
142:
143: /*
144: * (non-Javadoc)
145: *
146: * @see org.columba.ristretto.message.Message#getMimePartCount()
147: */
148: public int getMimePartCount() {
149: return message.getMimePartCount();
150: }
151:
152: /*
153: * (non-Javadoc)
154: *
155: * @see org.columba.ristretto.message.Message#getSource()
156: */
157: public Source getSource() {
158: return message.getSource();
159: }
160:
161: /*
162: * (non-Javadoc)
163: *
164: * @see org.columba.ristretto.message.Message#setHeader(org.columba.ristretto.message.Header)
165: */
166: public void setHeader(Header h) {
167: message.setHeader(h);
168: }
169:
170: /*
171: * (non-Javadoc)
172: *
173: * @see org.columba.ristretto.message.Message#setSource(org.columba.ristretto.message.io.Source)
174: */
175: public void setSource(Source source) {
176: message.setSource(source);
177: }
178:
179: public void close() {
180: message.close();
181: }
182: }
|