OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / packages / apps / Email / src / org / apache / james / mime4j / field / address / Group.java
1 /****************************************************************\r
2  * Licensed to the Apache Software Foundation (ASF) under one   *\r
3  * or more contributor license agreements.  See the NOTICE file *\r
4  * distributed with this work for additional information        *\r
5  * regarding copyright ownership.  The ASF licenses this file   *\r
6  * to you under the Apache License, Version 2.0 (the            *\r
7  * "License"); you may not use this file except in compliance   *\r
8  * with the License.  You may obtain a copy of the License at   *\r
9  *                                                              *\r
10  *   http://www.apache.org/licenses/LICENSE-2.0                 *\r
11  *                                                              *\r
12  * Unless required by applicable law or agreed to in writing,   *\r
13  * software distributed under the License is distributed on an  *\r
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *\r
15  * KIND, either express or implied.  See the License for the    *\r
16  * specific language governing permissions and limitations      *\r
17  * under the License.                                           *\r
18  ****************************************************************/\r
19 \r
20 package org.apache.james.mime4j.field.address;\r
21 \r
22 import java.util.ArrayList;\r
23 \r
24 /**\r
25  * A named group of zero or more mailboxes.  \r
26  *\r
27  * \r
28  */\r
29 public class Group extends Address {\r
30         private String name;\r
31         private MailboxList mailboxList;\r
32         \r
33         /**\r
34          * @param name The group name.\r
35          * @param mailboxes The mailboxes in this group.\r
36          */\r
37         public Group(String name, MailboxList mailboxes) {\r
38                 this.name = name;\r
39                 this.mailboxList = mailboxes;\r
40         }\r
41 \r
42         /**\r
43          * Returns the group name.\r
44          */\r
45         public String getName() {\r
46                 return name;\r
47         }\r
48         \r
49         /**\r
50          * Returns the mailboxes in this group.\r
51          */\r
52         public MailboxList getMailboxes() {\r
53                 return mailboxList;\r
54         }\r
55         \r
56         public String toString() {\r
57                 StringBuffer buf = new StringBuffer();\r
58                 buf.append(name);\r
59                 buf.append(":");\r
60                 for (int i = 0; i < mailboxList.size(); i++) {\r
61                         buf.append(mailboxList.get(i).toString());\r
62                         if (i + 1 < mailboxList.size())\r
63                                 buf.append(",");\r
64                 }\r
65                 buf.append(";");\r
66                 return buf.toString();\r
67         }\r
68 \r
69         protected void doAddMailboxesTo(ArrayList results) {\r
70                 for (int i = 0; i < mailboxList.size(); i++)\r
71                         results.add(mailboxList.get(i));\r
72         }\r
73 }\r