Skip to content

Package: ModifiedSinceTerm

ModifiedSinceTerm

nameinstructionbranchcomplexitylinemethod
ModifiedSinceTerm(long)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 16 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getModSeq()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hashCode()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
match(Message)
M: 23 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 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;
18:
19: import jakarta.mail.Message;
20: import jakarta.mail.search.SearchTerm;
21:
22: /**
23: * Find messages that have been modified since a given MODSEQ value.
24: * Relies on the server implementing the CONDSTORE extension
25: * (<A HREF="http://www.ietf.org/rfc/rfc4551.txt">RFC 4551</A>).
26: *
27: * @since JavaMail 1.5.1
28: * @author Bill Shannon
29: */
30: public final class ModifiedSinceTerm extends SearchTerm {
31:
32: private long modseq;
33:
34: private static final long serialVersionUID = 5151457469634727992L;
35:
36: /**
37: * Constructor.
38: *
39: * @param modseq modification sequence number
40: */
41: public ModifiedSinceTerm(long modseq) {
42: this.modseq = modseq;
43: }
44:
45: /**
46: * Return the modseq.
47: *
48: * @return the modseq
49: */
50: public long getModSeq() {
51: return modseq;
52: }
53:
54: /**
55: * The match method.
56: *
57: * @param msg the date comparator is applied to this Message's
58: * MODSEQ
59: * @return true if the comparison succeeds, otherwise false
60: */
61: @Override
62: public boolean match(Message msg) {
63: long m;
64:
65: try {
66:• if (msg instanceof IMAPMessage)
67: m = ((IMAPMessage) msg).getModSeq();
68: else
69: return false;
70: } catch (Exception e) {
71: return false;
72: }
73:
74:• return m >= modseq;
75: }
76:
77: /**
78: * Equality comparison.
79: */
80: @Override
81: public boolean equals(Object obj) {
82:• if (!(obj instanceof ModifiedSinceTerm))
83: return false;
84:• return modseq == ((ModifiedSinceTerm) obj).modseq;
85: }
86:
87: /**
88: * Compute a hashCode for this object.
89: */
90: @Override
91: public int hashCode() {
92: return (int) modseq;
93: }
94: }