KickJava   Java API By Example, From Geeks To Geeks.

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


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

38
39 public class Status {
40     public String JavaDoc mbox = null;
41     public int total = -1;
42     public int recent = -1;
43     public long uidnext = -1;
44     public long uidvalidity = -1;
45     public int unseen = -1;
46
47     public static String JavaDoc[] standardItems =
48     { "MESSAGES", "RECENT", "UNSEEN", "UIDNEXT", "UIDVALIDITY" };
49
50     public Status(Response r) throws ParsingException {
51     mbox = r.readAtomString(); // mailbox := astring
52
r.skipSpaces();
53     if (r.readByte() != '(')
54         throw new ParsingException("parse error in STATUS");
55     
56     do {
57         String JavaDoc attr = r.readAtom();
58         if (attr.equalsIgnoreCase("MESSAGES"))
59         total = r.readNumber();
60         else if (attr.equalsIgnoreCase("RECENT"))
61         recent = r.readNumber();
62         else if (attr.equalsIgnoreCase("UIDNEXT"))
63         uidnext = r.readLong();
64         else if (attr.equalsIgnoreCase("UIDVALIDITY"))
65         uidvalidity = r.readLong();
66         else if (attr.equalsIgnoreCase("UNSEEN"))
67         unseen = r.readNumber();
68     } while (r.readByte() != ')');
69     }
70
71     public static void add(Status s1, Status s2) {
72     if (s2.total != -1)
73         s1.total = s2.total;
74     if (s2.recent != -1)
75         s1.recent = s2.recent;
76     if (s2.uidnext != -1)
77         s1.uidnext = s2.uidnext;
78     if (s2.uidvalidity != -1)
79         s1.uidvalidity = s2.uidvalidity;
80     if (s2.unseen != -1)
81         s1.unseen = s2.unseen;
82     }
83 }
84
Popular Tags