KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > mail > imap > protocol > ListInfo


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)ListInfo.java 1.10 05/08/29
24  *
25  * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package com.sun.mail.imap.protocol;
29
30 import java.util.Vector JavaDoc;
31
32 import com.sun.mail.iap.*;
33
34 /**
35  * A LIST response.
36  *
37  * @version 1.10, 05/08/29
38  * @author John Mani
39  * @author Bill Shannon
40  */

41
42 public class ListInfo {
43     public String JavaDoc name = null;
44     public char separator = '/';
45     public boolean hasInferiors = true;
46     public boolean canOpen = true;
47     public int changeState = INDETERMINATE;
48     public String JavaDoc[] attrs;
49
50     public static final int CHANGED = 1;
51     public static final int UNCHANGED = 2;
52     public static final int INDETERMINATE = 3;
53
54     public ListInfo(IMAPResponse r) throws ParsingException {
55     String JavaDoc[] s = r.readSimpleList();
56
57     Vector JavaDoc v = new Vector JavaDoc(); // accumulate attributes
58
if (s != null) {
59         // non-empty attribute list
60
for (int i = 0; i < s.length; i++) {
61         if (s[i].equalsIgnoreCase("\\Marked"))
62             changeState = CHANGED;
63         else if (s[i].equalsIgnoreCase("\\Unmarked"))
64             changeState = UNCHANGED;
65         else if (s[i].equalsIgnoreCase("\\Noselect"))
66             canOpen = false;
67         else if (s[i].equalsIgnoreCase("\\Noinferiors"))
68             hasInferiors = false;
69         v.addElement(s[i]);
70         }
71     }
72     attrs = new String JavaDoc[v.size()];
73     v.copyInto(attrs);
74
75     r.skipSpaces();
76     if (r.readByte() == '"') {
77         if ((separator = (char)r.readByte()) == '\\')
78         // escaped separator character
79
separator = (char)r.readByte();
80         r.skip(1); // skip <">
81
} else // NIL
82
r.skip(2);
83     
84     r.skipSpaces();
85     name = r.readAtomString();
86
87     // decode the name (using RFC2060's modified UTF7)
88
name = BASE64MailboxDecoder.decode(name);
89     }
90 }
91
Popular Tags