Skip to content

Package: FLAGS

FLAGS

nameinstructionbranchcomplexitylinemethod
FLAGS(IMAPResponse)
M: 99 C: 0
0%
M: 25 C: 0
0%
M: 16 C: 0
0%
M: 32 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 24 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.imap.protocol;
18:
19: import jakarta.mail.Flags;
20: import org.eclipse.angus.mail.iap.*;
21: import org.eclipse.angus.mail.iap.ParsingException;
22:
23: /**
24: * This class
25: *
26: * @author John Mani
27: */
28:
29: public class FLAGS extends Flags implements Item {
30:
31: // IMAP item name
32: static final char[] name = {'F','L','A','G','S'};
33: public int msgno;
34:
35: private static final long serialVersionUID = 439049847053756670L;
36:
37: /**
38: * Constructor.
39: *
40: * @param        r        the IMAPResponse
41: * @exception ParsingException for parsing failures
42: */
43: public FLAGS(IMAPResponse r) throws ParsingException {
44:         msgno = r.getNumber();
45:
46:         r.skipSpaces();
47:         String[] flags = r.readSimpleList();
48:•        if (flags != null) { // if not empty flaglist
49:•         for (int i = 0; i < flags.length; i++) {
50:                 String s = flags[i];
51:•                if (s.length() >= 2 && s.charAt(0) == '\\') {
52:•                 switch (Character.toUpperCase(s.charAt(1))) {
53:                  case 'S': // \Seen
54:                         add(Flags.Flag.SEEN);
55:                         break;
56:                  case 'R': // \Recent
57:                         add(Flags.Flag.RECENT);
58:                         break;
59:                  case 'D':
60:•                        if (s.length() >= 3) {
61:                          char c = s.charAt(2);
62:•                         if (c == 'e' || c == 'E') // \Deleted
63:                                 add(Flags.Flag.DELETED);
64:•                         else if (c == 'r' || c == 'R') // \Draft
65:                                 add(Flags.Flag.DRAFT);
66:                         } else
67:                          add(s);        // unknown, treat it as a user flag
68:                         break;
69:                  case 'A': // \Answered
70:                         add(Flags.Flag.ANSWERED);
71:                         break;
72:                  case 'F': // \Flagged
73:                         add(Flags.Flag.FLAGGED);
74:                         break;
75:                  case '*': // \*
76:                         add(Flags.Flag.USER);
77:                         break;
78:                  default:
79:                         add(s);                // unknown, treat it as a user flag
80:                         break;
81:                  }
82:                 } else
83:                  add(s);
84:          }
85:         }
86: }
87: }