|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.mail Class Flags
java.lang.Object javax.mail.Flags
- All Implemented Interfaces:
- Serializable, Cloneable
public class Flags
- extends Object
- implements Cloneable, Serializable
Flags 类表示 Message 上的标志集合。Flags 由预定义的系统标志和用户定义的标志组成。
系统标志由 Flags.Flag
内部类表示。用户定义的标志则表示为一个 String。用户标志是不区分大小写的。
预定义了一组标准的系统标志。大多数文件夹实现都应该支持这些标志。某些实现可能还支持用户定义的任意标志。Folder 上的 getPermanentFlags
方法将返回一个包含该文件夹实现支持的所有标志的 Flags 对象。
Flags 对象是可序列化的,因此,(例如)搜索条目中的 Flags 对象的使用可以随搜索条目一起被序列化。
警告: 此类的序列化对象可能与以后的 JavaMail API 版本不兼容。当前的序列化支持适用于短期存储。
以下代码示例说明了如何设置、检查和获取某条消息的标志。
Message m = folder.getMessage(1); m.setFlag(Flags.Flag.DELETED, true); // set the DELETED flag // Check if DELETED flag is set of 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"); ...... ...... }
See also | getPermanentFlags |
The Flags class represents the set of flags on a Message. Flags are composed of predefined system flags, and user defined flags.
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 of 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"); ...... ...... }
- Author:
- John Mani, Bill Shannon
- See Also:
Folder.getPermanentFlags()
, Serialized Form
Nested Class Summary | |
---|---|
static class |
Flags.Flag
This inner class represents an individual system flag. |
Constructor Summary | |
---|---|
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(String flag)
Construct a Flags object initialized with the given user flag. |
Method Summary | |
---|---|
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(String flag)
Add the specified user flag to this Flags object. |
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(String flag)
Check whether the specified user flag is present in this Flags object. |
boolean |
equals(Object obj)
Check whether the two Flags objects are equal. |
Flags.Flag[] |
getSystemFlags()
Return all the system flags in this Flags object. |
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(String flag)
Remove the specified user flag from this Flags object. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
Flags()
构造一个空的 Flags 对象。
英文文档:
Flags
public Flags()
- Construct an empty Flags object.
public
Flags(Flags flags)
构造一个用给定标志初始化的 Flags 对象。
flags | 用于初始化的标志 |
Flags
public Flags(Flags flags)
- Construct a Flags object initialized with the given flags.
- Parameters:
flags
- the flags for initialization
public
Flags(Flags.Flag flag)
构造一个用给定系统标志初始化的 Flags 对象。
flag | 用于初始化的标志 |
Flags
public Flags(Flags.Flag flag)
- Construct a Flags object initialized with the given system flag.
- Parameters:
flag
- the flag for initialization
public
Flags(String flag)
构造一个用给定用户标志初始化的 Flags 对象。
flag | 用于初始化的标志 |
Flags
public Flags(String flag)
- Construct a Flags object initialized with the given user flag.
- Parameters:
flag
- the flag for initialization
Method Detail |
---|
public void
add(Flags.Flag flag)
将指定系统标志添加到此 Flags 对象。
flag | 要添加的标志 |
add
public void add(Flags.Flag flag)
- Add the specified system flag to this Flags object.
- Parameters:
flag
- the flag to add
public void
add(String flag)
将指定用户标志添加到此 Flags 对象。
flag | 要添加的标志 |
add
public void add(String flag)
- Add the specified user flag to this Flags object.
- Parameters:
flag
- the flag to add
public void
add(Flags f)
将给定 Flags 对象中的所有标志添加到此 Flags 对象。
f | Flags 对象 |
add
public void add(Flags f)
- Add all the flags in the given Flags object to this
Flags object.
- Parameters:
f
- Flags object
public void
remove(Flags.Flag flag)
从此 Flags 对象中移除指定系统标志。
flag | 要移除的标志 |
remove
public void remove(Flags.Flag flag)
- Remove the specified system flag from this Flags object.
- Parameters:
flag
- the flag to be removed
public void
remove(String flag)
从此 Flags 对象中移除指定用户标志。
flag | 要移除的标志 |
remove
public void remove(String flag)
- Remove the specified user flag from this Flags object.
- Parameters:
flag
- the flag to be removed
public void
remove(Flags f)
从此 Flags 对象中移除给定 Flags 对象中的所有标志。
f | 要移除的标志 |
remove
public void remove(Flags f)
- Remove all flags in the given Flags object from this
Flags object.
- Parameters:
f
- the flag to be removed
public boolean
contains(Flags.Flag flag)
检查此 Flags 对象中是否存在指定系统标志。
return | 如果给定标志存在,则返回 true;否则返回 false。 |
contains
public boolean contains(Flags.Flag flag)
- Check whether the specified system flag is present in this Flags object.
- Returns:
- true of the given flag is present, otherwise false.
public boolean
contains(String flag)
检查此 Flags 对象中是否存在指定用户标志。
return | 如果给定标志存在,则返回 true;否则返回 false。 |
contains
public boolean contains(String flag)
- Check whether the specified user flag is present in this Flags object.
- Returns:
- true of the given flag is present, otherwise false.
public boolean
contains(Flags f)
检查此 Flags 对象中是否存在指定 Flags 对象中的所有标志。
return | 如果存在给定 Flags 对象中的所有标志,则返回 true;否则返回 false。 |
contains
public boolean contains(Flags f)
- Check whether all the flags in the specified Flags object are
present in this Flags object.
- Returns:
- true if all flags in the given Flags object are present, otherwise false.
public boolean
equals(Object obj)
检查两个 Flags 对象是否相等。
return | 如果两个对象相等,则返回 true |
equals
public boolean equals(Object obj)
- Check whether the two Flags objects are equal.
- Returns:
- true if they're equal
public int
hashCode()
计算此 Flags 对象的哈希码。
return | 哈希码 |
hashCode
public int hashCode()
public Flags.Flag[]
getSystemFlags()
返回此 Flags 对象中的所有系统标志。如果没有设置标志,则返回大小为 0 的数组。
return | 表示系统标志的 Flags.Flag 对象的数组 |
getSystemFlags
public Flags.Flag[] getSystemFlags()
- Return all the system flags in this Flags object. Returns
an array of size zero if no flags are set.
- Returns:
- array of Flags.Flag objects representing system flags
public String[]
getUserFlags()
返回此 Flags 对象中的所有用户标志。如果没有设置标志,则返回大小为 0 的数组。
return | String 数组,每个 String 都表示一个标志。 |
getUserFlags
public String[] getUserFlags()
- Return all the user flags in this Flags object. Returns
an array of size zero if no flags are set.
- Returns:
- array of Strings, each String represents a flag.
public Object
clone()
返回此 Flags 对象的副本。
英文文档:
clone
public Object clone()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!