KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > mail > providers > imap4 > IMAPCommand


1 /*
2  * IMAPCommand.java
3  * Copyright (C) 2003 Chris Burdess <dog@gnu.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * You also have permission to link it with the Sun Microsystems, Inc.
11  * JavaMail(tm) extension and run that combination.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */

22
23 package gnu.mail.providers.imap4;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28
29 /**
30  * An IMAP4rev1 client command.
31  *
32  * @author <a HREF='mailto:dog@gnu.org'>Chris Burdess</a>
33  * @version 0.1
34  */

35 public class IMAPCommand
36 {
37
38   /**
39    * The tag for this command.
40    */

41   protected String JavaDoc tag;
42   
43   /**
44    * The command name.
45    */

46   protected String JavaDoc name;
47
48   /**
49    * The command parameters.
50    */

51   protected List JavaDoc parameters;
52
53   /**
54    * Constructor.
55    */

56   public IMAPCommand(String JavaDoc tag, String JavaDoc name)
57   {
58     this.tag = tag;
59     this.name = name;
60   }
61
62   public String JavaDoc getTag()
63   {
64     return tag;
65   }
66
67   /**
68    * Add a parameter to this command.
69    */

70   public void add(String JavaDoc parameter)
71   {
72     if (parameters==null)
73       parameters = new ArrayList JavaDoc();
74     parameters.add(parameter);
75   }
76
77   public String JavaDoc toString()
78   {
79     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
80     buffer.append(tag);
81     buffer.append(' ');
82     buffer.append(name);
83     if (parameters!=null)
84     {
85       for (Iterator JavaDoc i = parameters.iterator(); i.hasNext(); )
86       {
87         buffer.append(' ');
88         buffer.append((String JavaDoc)i.next());
89       }
90     }
91     buffer.append('\n');
92     return buffer.toString();
93   }
94
95 }
96
Popular Tags