本文整理汇总了Java中javax.mail.Flags.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Flags.contains方法的具体用法?Java Flags.contains怎么用?Java Flags.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.mail.Flags
的用法示例。
在下文中一共展示了Flags.contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import javax.mail.Flags; //导入方法依赖的package包/类
public void execute(Pop3Connection conn, Pop3State state, String cmd) {
conn.println("+OK");
try {
MailFolder inbox = state.getFolder();
List msgList = inbox.getMessages();
int count = 0;
for(int i=0;i<msgList.size();i++) {
SimpleStoredMessage msg = (SimpleStoredMessage) msgList.get(i);
Flags flags = msg.getFlags();
if (flags.contains(Flags.Flag.DELETED)) {
count++;
flags.remove(Flags.Flag.DELETED);
}
}
conn.println("+OK maildrop has "+count+" messages undeleted.");
} catch (Exception e) {
conn.println("-ERR " + e);
}
}
示例2: expungeMessage
import javax.mail.Flags; //导入方法依赖的package包/类
public void expungeMessage(FileInfo fileInfo)
{
Flags flags = getFlags(fileInfo);
if (flags.contains(Flags.Flag.DELETED))
{
// See MNT-12259
//fileFolderService.delete(fileInfo.getNodeRef());
hideAndDelete(fileInfo.getNodeRef());
messageCache.remove(fileInfo.getNodeRef());
}
}
示例3: getRecentCount
import javax.mail.Flags; //导入方法依赖的package包/类
/**
* Returns count of messages with {@link javax.mail.Flags.Flag#RECENT} flag.
* If {@code reset} parameter is {@code true} - removes {@link javax.mail.Flags.Flag#RECENT} flag from
* the message for current user.
*
* @param reset - if true the {@link javax.mail.Flags.Flag#RECENT} will be deleted for current user if exists.
* @return returns count of recent messages.
*/
@Override
public int getRecentCount(boolean reset)
{
int recent = getFolderStatus().recentCount;
if (reset && recent > 0)
{
CommandCallback<Void> command = new CommandCallback<Void>()
{
public Void command() throws Throwable
{
for (FileInfo fileInfo : folderStatus.search.values())
{
Flags flags = imapService.getFlags(fileInfo);
if (flags.contains(Flags.Flag.RECENT))
{
imapService.setFlag(fileInfo, Flags.Flag.RECENT, false);
}
}
return null;
}
};
try
{
command.run();
}
catch (AccessDeniedException ade)
{
if (logger.isDebugEnabled())
{
logger.debug("Access denied to reset RECENT FLAG");
}
}
}
return recent;
}
示例4: format
import javax.mail.Flags; //导入方法依赖的package包/类
/**
* Returns IMAP formatted String of MessageFlags for named user
*/
public static String format(Flags flags) {
StringBuffer buf = new StringBuffer();
buf.append("(");
if (flags.contains(Flags.Flag.ANSWERED)) {
buf.append("\\Answered ");
}
if (flags.contains(Flags.Flag.DELETED)) {
buf.append("\\Deleted ");
}
if (flags.contains(Flags.Flag.DRAFT)) {
buf.append("\\Draft ");
}
if (flags.contains(Flags.Flag.FLAGGED)) {
buf.append("\\Flagged ");
}
if (flags.contains(Flags.Flag.RECENT)) {
buf.append("\\Recent ");
}
if (flags.contains(Flags.Flag.SEEN)) {
buf.append("\\Seen ");
}
// Remove the trailing space, if necessary.
if (buf.length() > 1) {
buf.setLength(buf.length() - 1);
}
buf.append(")");
return buf.toString();
}
示例5: execute
import javax.mail.Flags; //导入方法依赖的package包/类
public void execute(Pop3Connection conn, Pop3State state,
String cmd) {
try {
MailFolder inbox = state.getFolder();
String[] cmdLine = cmd.split(" ");
String msgNumStr = cmdLine[1];
List msgList = inbox.getMessages(new MsgRangeFilter(msgNumStr, false));
if (msgList.size() != 1) {
conn.println("-ERR no such message");
return;
}
SimpleStoredMessage msg = (SimpleStoredMessage) msgList.get(0);
Flags flags = msg.getFlags();
if (flags.contains(Flags.Flag.DELETED)) {
conn.println("-ERR message already deleted");
return;
}
flags.add(Flags.Flag.DELETED);
conn.println("+OK message scheduled for deletion");
} catch (Exception e) {
conn.println("-ERR " + e);
}
}
示例6: setFlags
import javax.mail.Flags; //导入方法依赖的package包/类
/**
* Sets flags for this message. Flags not explicitly stored in metadata
* will be kept in-memory.
* @param flag The current state of flags for this message.
*/
@Override
public synchronized void setFlags(Flags flag, boolean set) throws MessagingException {
if (flag.contains(Flag.RECENT))
setRecent(set);
if (flag.contains(Flag.SEEN))
setUnread(!set);
if (flag.contains(Flag.ANSWERED))
setReplied(set);
if (flag.contains(Flag.DELETED))
setDeleted(set);
super.setFlags(flag, set);
}
示例7: format
import javax.mail.Flags; //导入方法依赖的package包/类
/**
* Returns IMAP formatted String of MessageFlags for named user
*/
public static String format(Flags flags) {
StringBuilder buf = new StringBuilder();
buf.append('(');
if (flags.contains(Flags.Flag.ANSWERED)) {
buf.append("\\Answered ");
}
if (flags.contains(Flags.Flag.DELETED)) {
buf.append("\\Deleted ");
}
if (flags.contains(Flags.Flag.DRAFT)) {
buf.append("\\Draft ");
}
if (flags.contains(Flags.Flag.FLAGGED)) {
buf.append("\\Flagged ");
}
if (flags.contains(Flags.Flag.RECENT)) {
buf.append("\\Recent ");
}
if (flags.contains(Flags.Flag.SEEN)) {
buf.append("\\Seen ");
}
String[] userFlags = flags.getUserFlags();
if(null!=userFlags) {
for(String uf: userFlags) {
buf.append(uf).append(' ');
}
}
// Remove the trailing space, if necessary.
if (buf.length() > 1) {
buf.setLength(buf.length() - 1);
}
buf.append(')');
return buf.toString();
}
示例8: toStringArray
import javax.mail.Flags; //导入方法依赖的package包/类
public static String[] toStringArray(final Flags flags) {
final List<String> flagsL = new ArrayList<String>(10);
if (flags.contains(Flags.Flag.DELETED)) {
flagsL.add("Deleted");
}
if (flags.contains(Flags.Flag.ANSWERED)) {
flagsL.add("Answered");
}
if (flags.contains(Flags.Flag.DRAFT)) {
flagsL.add("Draft");
}
if (flags.contains(Flags.Flag.FLAGGED)) {
flagsL.add("Flagged");
}
if (flags.contains(Flags.Flag.RECENT)) {
flagsL.add("Recent");
}
if (flags.contains(Flags.Flag.SEEN)) {
flagsL.add("Seen");
}
if (flags.contains(Flags.Flag.USER)) {
final String[] userFlags = flags.getUserFlags();
for (int j = 0; j < userFlags.length; j++) {
flagsL.add(userFlags[j]);
}
}
return flagsL.toArray(new String[flagsL.size()]);
}