KickJava   Java API By Example, From Geeks To Geeks.

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


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  * @(#)FLAGS.java 1.8 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 javax.mail.Flags JavaDoc;
31 import com.sun.mail.iap.*;
32
33 /**
34  * This class
35  *
36  * @version 1.8, 05/08/29
37  * @author John Mani
38  */

39
40 public class FLAGS extends Flags JavaDoc implements Item {
41
42     // IMAP item name
43
public static char[] name = {'F','L','A','G','S'};
44     public int msgno;
45
46     private static final long serialVersionUID = 439049847053756670L;
47
48     /**
49      * Constructor
50      */

51     public FLAGS(IMAPResponse r) throws ParsingException {
52     msgno = r.getNumber();
53
54     r.skipSpaces();
55     String JavaDoc[] flags = r.readSimpleList();
56     if (flags != null) { // if not empty flaglist
57
for (int i = 0; i < flags.length; i++) {
58         String JavaDoc s = flags[i];
59         if (s.length() >= 2 && s.charAt(0) == '\\') {
60             switch (Character.toUpperCase(s.charAt(1))) {
61             case 'S': // \Seen
62
add(Flags.Flag.SEEN);
63             break;
64             case 'R': // \Recent
65
add(Flags.Flag.RECENT);
66             break;
67             case 'D':
68             if (s.length() >= 3) {
69                 char c = s.charAt(2);
70                 if (c == 'e' || c == 'E') // \Deleted
71
add(Flags.Flag.DELETED);
72                 else if (c == 'r' || c == 'R') // \Draft
73
add(Flags.Flag.DRAFT);
74             } else
75                 add(s); // unknown, treat it as a user flag
76
break;
77             case 'A': // \Answered
78
add(Flags.Flag.ANSWERED);
79             break;
80             case 'F': // \Flagged
81
add(Flags.Flag.FLAGGED);
82             break;
83             case '*': // \*
84
add(Flags.Flag.USER);
85             break;
86             default:
87             add(s); // unknown, treat it as a user flag
88
break;
89             }
90         } else
91             add(s);
92         }
93     }
94     }
95 }
96
Popular Tags