01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //limitations under the License.
10: //
11: //The Original Code is "The Columba Project"
12: //
13: //The Initial Developers of the Original Code are Frederik Dietz and Timo
14: // Stich.
15: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16: //
17: //All Rights Reserved.
18: package org.columba.mail.folder.outbox;
19:
20: import java.util.ArrayList;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: import org.columba.mail.folder.headercache.DefaultHeaderBinding;
25: import org.columba.mail.message.IColumbaHeader;
26:
27: import com.sleepycat.bind.tuple.TupleInput;
28: import com.sleepycat.bind.tuple.TupleOutput;
29:
30: public class OutboxHeaderBinding extends DefaultHeaderBinding {
31:
32: public Object entryToObject(TupleInput in) {
33: IColumbaHeader header = (IColumbaHeader) super
34: .entryToObject(in);
35:
36: Integer accountUid = new Integer(in.readInt());
37: header.getAttributes().put("columba.accountuid", accountUid);
38:
39: int listSize = in.readInt();
40: List recipients = new ArrayList(listSize);
41: for (int i = 0; i < listSize; i++) {
42: recipients.add(i, in.readString());
43: }
44:
45: header.getAttributes().put("columba.recipients", recipients);
46:
47: return header;
48: }
49:
50: public void objectToEntry(Object arg0, TupleOutput out) {
51: super .objectToEntry(arg0, out);
52: IColumbaHeader header = (IColumbaHeader) arg0;
53:
54: out.writeInt(((Integer) header.getAttributes().get(
55: "columba.accountuid")).intValue());
56:
57: List recipients = (List) header.getAttributes().get(
58: "columba.recipients");
59: out.writeInt(recipients.size());
60: for (Iterator it = recipients.iterator(); it.hasNext();) {
61: out.writeString((String) it.next());
62: }
63:
64: }
65:
66: }
|