FlagTermpublic final class FlagTerm extends SearchTerm This class implements comparisons for Message Flags. |
Fields Summary |
---|
protected boolean | setIndicates whether to test for the presence or
absence of the specified Flag. If true ,
then test whether all the specified flags are present, else
test whether all the specified flags are absent. | protected Flags | flagsFlags object containing the flags to test. | private static final long | serialVersionUID |
Constructors Summary |
---|
public FlagTerm(Flags flags, boolean set)Constructor.
this.flags = flags;
this.set = set;
|
Methods Summary |
---|
public boolean | equals(java.lang.Object obj)Equality comparison.
if (!(obj instanceof FlagTerm))
return false;
FlagTerm ft = (FlagTerm)obj;
return ft.set == this.set && ft.flags.equals(this.flags);
| public javax.mail.Flags | getFlags()Return the Flags to test.
return (Flags)flags.clone();
| public boolean | getTestSet()Return true if testing whether the flags are set.
return set;
| public int | hashCode()Compute a hashCode for this object.
return set ? flags.hashCode() : ~flags.hashCode();
| public boolean | match(Message msg)The comparison method.
try {
Flags f = msg.getFlags();
if (set) { // This is easy
if (f.contains(flags))
return true;
else
return false;
}
// Return true if ALL flags in the passed in Flags
// object are NOT set in this Message.
// Got to do this the hard way ...
Flags.Flag[] sf = flags.getSystemFlags();
// Check each flag in the passed in Flags object
for (int i = 0; i < sf.length; i++) {
if (f.contains(sf[i]))
// this flag IS set in this Message, get out.
return false;
}
String[] s = flags.getUserFlags();
// Check each flag in the passed in Flags object
for (int i = 0; i < s.length; i++) {
if (f.contains(s[i]))
// this flag IS set in this Message, get out.
return false;
}
return true;
} catch (Exception e) {
return false;
}
|
|