开发者

What is JavaMail Folder type 3?

I know that JavaMail knows the following types of IMAP folders:

Folder.HOLDS_MESSAGES (which equals the constant 1) and Folder.HOLDS_FOLDERS (which equals the constant 2).

So, today I did:

int type = folder.getType();

on a folder called "Drafts", which should be type 2.

But the variable type contains the value 3, which does not seem to be documented anywhere.

What does type开发者_开发问答 3 mean?


From the ApiDoc Folder.getType:

Returns the type of this Folder, that is, whether this folder can hold messages or subfolders or both. The returned value is an integer bitfield with the appropriate bits set.

So 3 is just the result of 2+1 in this case, which means your folder both HOLDS_MESSAGES and HOLDS_FOLDERS.

Remember: the int is a bitfield. You have to check it like this:

 if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0)

etc, do not use == as operator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜