KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > web > webmail > MboxMessage


1 /*
2  * Copyright (c) 1998-2001 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.web.webmail;
30
31 import java.util.ArrayList JavaDoc;
32
33 /*
34  * Represents a single mbox message.
35  */

36 public class MboxMessage {
37   private int index;
38
39   private String JavaDoc messageId;
40   
41   private String JavaDoc from;
42   private String JavaDoc subject;
43   private String JavaDoc dateString;
44   private long date;
45
46   private MboxMessage parent;
47   private MboxMessage root;
48
49   private ArrayList JavaDoc children;
50   private ArrayList JavaDoc descendants;
51
52   public MboxMessage(int index)
53   {
54     this.index = index;
55
56     this.root = this;
57   }
58
59   public int getIndex()
60   {
61     return index;
62   }
63
64   public void setMessageId(String JavaDoc id)
65   {
66     this.messageId = id;
67   }
68
69   public String JavaDoc getMessageId()
70   {
71     return messageId;
72   }
73
74   public void setFrom(String JavaDoc from)
75   {
76     this.from = from;
77   }
78
79   public String JavaDoc getFrom()
80   {
81     return from;
82   }
83
84   public void setSubject(String JavaDoc subject)
85   {
86     this.subject = subject;
87   }
88
89   public String JavaDoc getSubject()
90   {
91     return subject;
92   }
93
94   public void setDateString(String JavaDoc date)
95   {
96     dateString = date;
97   }
98
99   public String JavaDoc getDateString()
100   {
101     return dateString;
102   }
103
104   public void setDate(long date)
105   {
106     this.date = date;
107   }
108
109   public long getDate()
110   {
111     return date;
112   }
113
114   public void setParent(MboxMessage parent)
115   {
116     this.parent = parent;
117     this.root = parent.root;
118
119     parent.addChild(this);
120   }
121
122   public void addChild(MboxMessage child)
123   {
124     if (children == null)
125       children = new ArrayList JavaDoc();
126     
127     children.add(child);
128     
129     if (root.descendants == null)
130       root.descendants = new ArrayList JavaDoc();
131
132     root.descendants.add(child);
133   }
134
135   public ArrayList JavaDoc getChildren()
136   {
137     return children;
138   }
139
140   public int getChildSize()
141   {
142     if (children == null)
143       return 0;
144     else
145       return children.size();
146   }
147
148   public MboxMessage getChild(int index)
149   {
150     return (MboxMessage) children.get(index);
151   }
152
153   public ArrayList JavaDoc getDescendants()
154   {
155     return descendants;
156   }
157 }
158
Popular Tags