javax.mail

Class Flags

public class Flags extends Object implements Cloneable, Serializable

Representation of flags that may be associated with a message. Flags can either be system flags, defined by the Flag inner class, or user-defined flags defined by a String. The system flags represent those expected to be provided by most folder systems; user-defined flags allow for additional flags on a per-provider basis.

This class is Serializable but compatibility is not guaranteed across releases.

Nested Class Summary
static classFlags.Flag
Constructor Summary
Flags()
Construct a Flags instance with no flags set.
Flags(Flags.Flag flag)
Construct a Flags instance with a supplied system flag set.
Flags(Flags flags)
Construct a Flags instance with a same flags set.
Flags(String name)
Construct a Flags instance with the supplied user flags set.
Method Summary
voidadd(Flags.Flag flag)
Set a system flag.
voidadd(Flags flags)
Set all system and user flags from the supplied Flags.
voidadd(String name)
Set a user flag.
Objectclone()
Return a copy of this instance.
booleancontains(Flags.Flag flag)
See if the supplied system flags are set
booleancontains(Flags flags)
See if all of the supplied Flags are set
booleancontains(String name)
See if the supplied user flag is set
booleanequals(Object other)
Equality is defined as true if the other object is a instanceof Flags with the same system and user flags set (using a case-insensitive name comparison for user flags).
Flags.Flag[]getSystemFlags()
Return a list of Flags containing the system flags that have been set
String[]getUserFlags()
Return a list of user flags that have been set
inthashCode()
Calculate a hashCode for this instance
voidremove(Flags.Flag flag)
Unset the supplied system flag.
voidremove(Flags flags)
Unset all flags from the supplied instance.
voidremove(String name)
Unset the supplied user flag.

Constructor Detail

Flags

public Flags()
Construct a Flags instance with no flags set.

Flags

public Flags(Flags.Flag flag)
Construct a Flags instance with a supplied system flag set.

Parameters: flag the system flag to set

Flags

public Flags(Flags flags)
Construct a Flags instance with a same flags set.

Parameters: flags the instance to copy

Flags

public Flags(String name)
Construct a Flags instance with the supplied user flags set. Question: should this automatically set the USER system flag?

Parameters: name the user flag to set

Method Detail

add

public void add(Flags.Flag flag)
Set a system flag.

Parameters: flag the system flag to set

add

public void add(Flags flags)
Set all system and user flags from the supplied Flags. Question: do we need to check compatibility of USER flags?

Parameters: flags the Flags to add

add

public void add(String name)
Set a user flag. Question: should this fail if the USER system flag is not set?

Parameters: name the user flag to set

clone

public Object clone()
Return a copy of this instance.

Returns: a copy of this instance

contains

public boolean contains(Flags.Flag flag)
See if the supplied system flags are set

Parameters: flag the system flags to check for

Returns: true if the flags are set

contains

public boolean contains(Flags flags)
See if all of the supplied Flags are set

Parameters: flags the flags to check for

Returns: true if all the supplied system and user flags are set

contains

public boolean contains(String name)
See if the supplied user flag is set

Parameters: name the user flag to check for

Returns: true if the flag is set

equals

public boolean equals(Object other)
Equality is defined as true if the other object is a instanceof Flags with the same system and user flags set (using a case-insensitive name comparison for user flags).

Parameters: other the instance to compare against

Returns: true if the two instance are the same

getSystemFlags

public Flags.Flag[] getSystemFlags()
Return a list of Flags containing the system flags that have been set

Returns: the system flags that have been set

getUserFlags

public String[] getUserFlags()
Return a list of user flags that have been set

Returns: a list of user flags

hashCode

public int hashCode()
Calculate a hashCode for this instance

Returns: a hashCode for this instance

remove

public void remove(Flags.Flag flag)
Unset the supplied system flag. Question: what happens if we unset the USER flags and user flags are set?

Parameters: flag the flag to clear

remove

public void remove(Flags flags)
Unset all flags from the supplied instance.

Parameters: flags the flags to clear

remove

public void remove(String name)
Unset the supplied user flag.

Parameters: name the flag to clear