KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > folder > outbox > OutboxHeaderBinding


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//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 JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
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 JavaDoc entryToObject(TupleInput in) {
33         IColumbaHeader header = (IColumbaHeader) super.entryToObject(in);
34         
35         Integer JavaDoc accountUid = new Integer JavaDoc(in.readInt());
36         header.getAttributes().put("columba.accountuid", accountUid);
37
38         int listSize = in.readInt();
39         List JavaDoc recipients = new ArrayList JavaDoc(listSize);
40         for( int i=0; i<listSize; i++) {
41             recipients.add(i,in.readString());
42         }
43         
44         header.getAttributes().put("columba.recipients", recipients);
45         
46         return header;
47     }
48
49     public void objectToEntry(Object JavaDoc arg0, TupleOutput out) {
50         super.objectToEntry(arg0, out);
51         IColumbaHeader header = (IColumbaHeader) arg0;
52             
53         out.writeInt(((Integer JavaDoc)header.getAttributes().get("columba.accountuid")).intValue());
54         
55         List JavaDoc recipients = (List JavaDoc)header.getAttributes().get("columba.recipients");
56         out.writeInt(recipients.size());
57         for( Iterator JavaDoc it=recipients.iterator(); it.hasNext();) {
58             out.writeString((String JavaDoc) it.next());
59         }
60
61     }
62
63 }
64
Popular Tags