public class Flags
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
A System flag is represented by the Flags.Flag
inner class. A User defined flag is represented as a String.
User flags are case-independent.
A set of standard system flags are predefined. Most folder
implementations are expected to support these flags. Some
implementations may also support arbitrary user-defined flags. The
getPermanentFlags
method on a Folder returns a Flags
object that holds all the flags that are supported by that folder
implementation.
A Flags object is serializable so that (for example) the use of Flags objects in search terms can be serialized along with the search terms.
Warning: Serialized objects of this class may not be compatible with future JavaMail API releases. The current serialization support is appropriate for short term storage.
The below code sample illustrates how to set, examine, and get the flags for a message.
Message m = folder.getMessage(1); m.setFlag(Flags.Flag.DELETED, true); // set the DELETED flag // Check if DELETED flag is set on this message if (m.isSet(Flags.Flag.DELETED)) System.out.println("DELETED message"); // Examine ALL system flags for this message Flags flags = m.getFlags(); Flags.Flag[] sf = flags.getSystemFlags(); for (int i = 0; i < sf.length; i++) { if (sf[i] == Flags.Flag.DELETED) System.out.println("DELETED message"); else if (sf[i] == Flags.Flag.SEEN) System.out.println("SEEN message"); ...... ...... }
Folder.getPermanentFlags()
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
Flags.Flag
This inner class represents an individual system flag.
|
Constructor and Description |
---|
Flags()
Construct an empty Flags object.
|
Flags(Flags.Flag flag)
Construct a Flags object initialized with the given system flag.
|
Flags(Flags flags)
Construct a Flags object initialized with the given flags.
|
Flags(java.lang.String flag)
Construct a Flags object initialized with the given user flag.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Flags.Flag flag)
Add the specified system flag to this Flags object.
|
void |
add(Flags f)
Add all the flags in the given Flags object to this
Flags object.
|
void |
add(java.lang.String flag)
Add the specified user flag to this Flags object.
|
void |
clearSystemFlags()
Clear all of the system flags.
|
void |
clearUserFlags()
Clear all of the user flags.
|
java.lang.Object |
clone()
Returns a clone of this Flags object.
|
boolean |
contains(Flags.Flag flag)
Check whether the specified system flag is present in this Flags object.
|
boolean |
contains(Flags f)
Check whether all the flags in the specified Flags object are
present in this Flags object.
|
boolean |
contains(java.lang.String flag)
Check whether the specified user flag is present in this Flags object.
|
boolean |
equals(java.lang.Object obj)
Check whether the two Flags objects are equal.
|
Flags.Flag[] |
getSystemFlags()
Return all the system flags in this Flags object.
|
java.lang.String[] |
getUserFlags()
Return all the user flags in this Flags object.
|
int |
hashCode()
Compute a hash code for this Flags object.
|
void |
remove(Flags.Flag flag)
Remove the specified system flag from this Flags object.
|
void |
remove(Flags f)
Remove all flags in the given Flags object from this
Flags object.
|
void |
remove(java.lang.String flag)
Remove the specified user flag from this Flags object.
|
boolean |
retainAll(Flags f)
Remove any flags not in the given Flags object.
|
java.lang.String |
toString()
Return a string representation of this Flags object.
|
public Flags()
public Flags(Flags flags)
flags
- the flags for initializationpublic Flags(Flags.Flag flag)
flag
- the flag for initializationpublic Flags(java.lang.String flag)
flag
- the flag for initializationpublic void add(Flags.Flag flag)
flag
- the flag to addpublic void add(java.lang.String flag)
flag
- the flag to addpublic void add(Flags f)
f
- Flags objectpublic void remove(Flags.Flag flag)
flag
- the flag to be removedpublic void remove(java.lang.String flag)
flag
- the flag to be removedpublic void remove(Flags f)
f
- the flag to be removedpublic boolean retainAll(Flags f)
f
- the flags to keeppublic boolean contains(Flags.Flag flag)
flag
- the flag to testpublic boolean contains(java.lang.String flag)
flag
- the flag to testpublic boolean contains(Flags f)
f
- the flags to testpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public Flags.Flag[] getSystemFlags()
public java.lang.String[] getUserFlags()
public void clearSystemFlags()
public void clearUserFlags()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2010 - 2020 Adobe. All Rights Reserved