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
| Modifier and Type | Class and Description |
|---|---|
| public static class | Flags.Flag
This inner class represents an individual system flag. |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final long | |
| private int | |
| private static final int | |
| private Hashtable |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public Object | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if they're equalthe reference object with which to compare. obj)Overrides java. |
| public Flags. | Returns: array of Flags.Flag objects representing system flagsReturn all the system flags in this Flags object. |
| public String[] | Returns: array of Strings, each String represents a flag.Return all the user flags in this Flags object. |
| public int | Returns: the hash codeOverrides java. |
| public void | |
| public void | |
| public void | |
| public boolean | |
| public String |
| ANSWERED_BIT | back to summary |
|---|---|
| private static final int ANSWERED_BIT | |
| DELETED_BIT | back to summary |
|---|---|
| private static final int DELETED_BIT | |
| DRAFT_BIT | back to summary |
|---|---|
| private static final int DRAFT_BIT | |
| FLAGGED_BIT | back to summary |
|---|---|
| private static final int FLAGGED_BIT | |
| RECENT_BIT | back to summary |
|---|---|
| private static final int RECENT_BIT | |
| SEEN_BIT | back to summary |
|---|---|
| private static final int SEEN_BIT | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| system_flags | back to summary |
|---|---|
| private int system_flags | |
| USER_BIT | back to summary |
|---|---|
| private static final int USER_BIT | |
| user_flags | back to summary |
|---|---|
| private Hashtable<String, String> user_flags | |
| Flags | back to summary |
|---|---|
| public Flags() Construct an empty Flags object. | |
| Flags | back to summary |
|---|---|
| public Flags(Flags flags) Construct a Flags object initialized with the given flags.
| |
| Flags | back to summary |
|---|---|
| public Flags(Flags. Construct a Flags object initialized with the given system flag. | |
| Flags | back to summary |
|---|---|
| public Flags(String flag) Construct a Flags object initialized with the given user flag.
| |
| add | back to summary |
|---|---|
| public void add(Flags. Add the specified system flag to this Flags object. | |
| add | back to summary |
|---|---|
| public void add(String flag) Add the specified user flag to this Flags object.
| |
| add | back to summary |
|---|---|
| public void add(Flags f) Add all the flags in the given Flags object to this Flags object.
| |
| clearSystemFlags | back to summary |
|---|---|
| public void clearSystemFlags() Clear all of the system flags.
| |
| clearUserFlags | back to summary |
|---|---|
| public void clearUserFlags() Clear all of the user flags.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Returns a clone of this Flags object.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Flags. Check whether the specified system flag is present in this Flags object. | |
| contains | back to summary |
|---|---|
| public boolean contains(String flag) Check whether the specified user flag is present in this Flags object.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Flags f) Check whether all the flags in the specified Flags object are present in this Flags object.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Check whether the two Flags objects are equal.
| |
| getSystemFlags | back to summary |
|---|---|
| public Flags. Return all the system flags in this Flags object. Returns an array of size zero if no flags are set. | |
| getUserFlags | back to summary |
|---|---|
| public String[] getUserFlags() Return all the user flags in this Flags object. Returns an array of size zero if no flags are set.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Compute a hash code for this Flags object.
| |
| remove | back to summary |
|---|---|
| public void remove(Flags. Remove the specified system flag from this Flags object. | |
| remove | back to summary |
|---|---|
| public void remove(String flag) Remove the specified user flag from this Flags object.
| |
| remove | back to summary |
|---|---|
| public void remove(Flags f) Remove all flags in the given Flags object from this Flags object.
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Flags f) Remove any flags not in the given Flags object. Useful for clearing flags not supported by a server. If the given Flags object includes the Flags.Flag.USER flag, all user flags in this Flags object are retained.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return a string representation of this Flags object. Note that the exact format of the string is subject to change.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Flags. | ANSWERED
This message has been answered. |
| private int | |
| public static final Flags. | DELETED
This message is marked deleted. |
| public static final Flags. | DRAFT
This message is a draft. |
| public static final Flags. | FLAGGED
This message is flagged. |
| public static final Flags. | RECENT
This message is recent. |
| public static final Flags. | SEEN
This message is seen. |
| public static final Flags. | USER
A special flag that indicates that this folder supports user defined flags. |
| Access | Constructor and Description |
|---|---|
| private |
| ANSWERED | back to summary |
|---|---|
| public static final Flags. This message has been answered. This flag is set by clients to indicate that this message has been answered to. | |
| bit | back to summary |
|---|---|
| private int bit | |
| DELETED | back to summary |
|---|---|
| public static final Flags. This message is marked deleted. Clients set this flag to mark a message as deleted. The expunge operation on a folder removes all messages in that folder that are marked for deletion. | |
| DRAFT | back to summary |
|---|---|
| public static final Flags. This message is a draft. This flag is set by clients to indicate that the message is a draft message. | |
| FLAGGED | back to summary |
|---|---|
| public static final Flags. This message is flagged. No semantic is defined for this flag. Clients alter this flag. | |
| RECENT | back to summary |
|---|---|
| public static final Flags. This message is recent. Folder implementations set this flag to indicate that this message is new to this folder, that is, it has arrived since the last time this folder was opened. Clients cannot alter this flag. | |
| SEEN | back to summary |
|---|---|
| public static final Flags. This message is seen. This flag is implicitly set by the
implementation when this Message's content is returned
to the client in some form. The Clients can alter this flag. | |
| USER | back to summary |
|---|---|
| public static final Flags. A special flag that indicates that this folder supports user defined flags.
The implementation sets this flag. Clients cannot alter
this flag but can use it to determine if a folder supports
user defined flags by using
| |
| Flag | back to summary |
|---|---|
| private Flag(int bit) | |