1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.geronimo.javamail.store.imap.connection;
19
20 import java.util.List;
21
22 import javax.mail.MessagingException;
23
24
25
26
27 public class IMAPStatusResponse extends IMAPUntaggedResponse {
28
29 public String mailbox;
30
31 public int messages = -1;
32
33 public int recentMessages = -1;
34
35 public int unseenMessages = -1;
36
37 public long uidNext = -1L;
38
39 public long uidValidity = -1L;
40
41 public IMAPStatusResponse(byte[] data, IMAPResponseTokenizer source) throws MessagingException {
42 super("STATUS", data);
43
44
45 mailbox = source.readEncodedString();
46
47
48 List flags = source.readStringList();
49
50 for (int i = 0; i < flags.size(); i += 2) {
51 String field = ((String)flags.get(i)).toUpperCase();
52 String stringValue = ((String)flags.get(i + 1));
53 long value;
54 try {
55 value = Long.parseLong(stringValue);
56 } catch (NumberFormatException e) {
57 throw new MessagingException("Invalid IMAP Status response", e);
58 }
59
60
61 if (field.equals("MESSAGES")) {
62 messages = (int)value;
63 }
64 else if (field.equals("RECENT")) {
65 recentMessages = (int)value;
66 }
67 else if (field.equals("UIDNEXT")) {
68 uidNext = value;
69 }
70 else if (field.equals("UIDVALIDITY")) {
71 uidValidity = value;
72 }
73 else if (field.equals("UNSEEN")) {
74 unseenMessages = (int)value;
75 }
76 }
77 }
78 }
79