Skip to content

Package: GmailSearchSequence

GmailSearchSequence

nameinstructionbranchcomplexitylinemethod
GmailSearchSequence(IMAPProtocol)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
generateSequence(SearchTerm, String)
M: 30 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
gmailMsgidSearch(GmailMsgIdTerm)
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
gmailRawSearch(GmailRawSearchTerm, String)
M: 16 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
gmailThridSearch(GmailThrIdTerm)
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 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.gimap.protocol;
18:
19: import jakarta.mail.search.SearchException;
20: import jakarta.mail.search.SearchTerm;
21: import org.eclipse.angus.mail.gimap.GmailMsgIdTerm;
22: import org.eclipse.angus.mail.gimap.GmailRawSearchTerm;
23: import org.eclipse.angus.mail.gimap.GmailThrIdTerm;
24: import org.eclipse.angus.mail.iap.Argument;
25: import org.eclipse.angus.mail.imap.protocol.IMAPProtocol;
26: import org.eclipse.angus.mail.imap.protocol.SearchSequence;
27:
28: import java.io.IOException;
29:
30: /**
31: * Support Gmail-specific search extensions.
32: *
33: * @author Bill Shannon
34: * @since JavaMail 1.4.6
35: */
36:
37: public class GmailSearchSequence extends SearchSequence {
38: public GmailSearchSequence(IMAPProtocol p) {
39: super(p);
40: }
41:
42: public Argument generateSequence(SearchTerm term, String charset)
43: throws SearchException, IOException {
44:• if (term instanceof GmailMsgIdTerm)
45: return gmailMsgidSearch((GmailMsgIdTerm) term);
46:• else if (term instanceof GmailThrIdTerm)
47: return gmailThridSearch((GmailThrIdTerm) term);
48:• else if (term instanceof GmailRawSearchTerm)
49: return gmailRawSearch((GmailRawSearchTerm) term, charset);
50: else
51: return super.generateSequence(term, charset);
52: }
53:
54: protected Argument gmailMsgidSearch(GmailMsgIdTerm term)
55: throws IOException {
56: Argument result = new Argument();
57: result.writeAtom("X-GM-MSGID");
58: result.writeNumber(term.getNumber());
59: return result;
60: }
61:
62: protected Argument gmailThridSearch(GmailThrIdTerm term)
63: throws IOException {
64: Argument result = new Argument();
65: result.writeAtom("X-GM-THRID");
66: result.writeNumber(term.getNumber());
67: return result;
68: }
69:
70: protected Argument gmailRawSearch(GmailRawSearchTerm term, String charset)
71: throws IOException {
72: Argument result = new Argument();
73: result.writeAtom("X-GM-RAW");
74: result.writeString(term.getPattern(), charset);
75: return result;
76: }
77: }