javax.mail.Flags.contains()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中javax.mail.Flags.contains()方法的一些代码示例,展示了Flags.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flags.contains()方法的具体详情如下:
包路径:javax.mail.Flags
类名称:Flags
方法名:contains

Flags.contains介绍

[英]Check whether the specified user flag is present in this Flags object.
[中]检查指定的用户标志是否存在于该标志对象中。

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Returns {@code true} if message is answered.
 *
 * @return {@code true} if message is answered.
 */
public boolean isAnswered() {
  return flags.contains(Flag.ANSWERED);
}

代码示例来源:origin: oblac/jodd

/**
 * Returns {@code true} is message is flagged.
 *
 * @return {@code true} is message is flagged.
 */
public boolean isFlagged() {
  return flags.contains(Flag.FLAGGED);
}

代码示例来源:origin: oblac/jodd

/**
 * Returns {@code true} if message is draft.
 */
public boolean isDraft() {
  return flags.contains(Flag.DRAFT);
}

代码示例来源:origin: oblac/jodd

/**
 * Returns {@code true} if message is deleted.
 *
 * @return {@code true} if message is deleted.
 */
public boolean isDeleted() {
  return flags.contains(Flag.DELETED);
}

代码示例来源:origin: oblac/jodd

/**
 * Returns {@code true} if message is seen.
 *
 * @return {@code true} if message is seen.
 */
public boolean isSeen() {
  return flags.contains(Flag.SEEN);
}

代码示例来源:origin: oblac/jodd

/**
 * Returns {@code true} if message is recent.
 *
 * @return {@code true} if message is recent.
 */
public boolean isRecent() {
  return flags.contains(Flag.RECENT);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Check whether the flag specified in the <code>flag</code>
 * argument is set in this message. <p>
 *
 * This implementation checks this message's internal 
 * <code>flags</code> object.
 *
 * @param flag    the flag
 * @return        value of the specified flag for this message
 * @exception       MessagingException for failures
 * @see         javax.mail.Flags.Flag
 * @see        javax.mail.Flags.Flag#ANSWERED
 * @see        javax.mail.Flags.Flag#DELETED
 * @see        javax.mail.Flags.Flag#DRAFT
 * @see        javax.mail.Flags.Flag#FLAGGED
 * @see        javax.mail.Flags.Flag#RECENT
 * @see        javax.mail.Flags.Flag#SEEN
 */
public synchronized boolean isSet(Flags.Flag flag)
      throws MessagingException {
return (flags.contains(flag));
}

代码示例来源:origin: com.sun.mail/javax.mail

/**
 * Check whether the flag specified in the <code>flag</code>
 * argument is set in this message. <p>
 *
 * This implementation checks this message's internal 
 * <code>flags</code> object.
 *
 * @param flag    the flag
 * @return        value of the specified flag for this message
 * @exception       MessagingException for failures
 * @see         javax.mail.Flags.Flag
 * @see        javax.mail.Flags.Flag#ANSWERED
 * @see        javax.mail.Flags.Flag#DELETED
 * @see        javax.mail.Flags.Flag#DRAFT
 * @see        javax.mail.Flags.Flag#FLAGGED
 * @see        javax.mail.Flags.Flag#RECENT
 * @see        javax.mail.Flags.Flag#SEEN
 */
@Override
public synchronized boolean isSet(Flags.Flag flag)
      throws MessagingException {
return (flags.contains(flag));
}

代码示例来源:origin: oblac/jodd

if (flagsToSet.contains(Flags.Flag.DELETED)) {
  folder.expunge();

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Check whether the flag specified in the <code>flag</code>
 * argument is set in this message. <p>
 *
 * The default implementation uses <code>getFlags</code>.
 *
 * @param flag    the flag
 * @return        value of the specified flag for this message
 * @see         javax.mail.Flags.Flag
 * @see        javax.mail.Flags.Flag#ANSWERED
 * @see        javax.mail.Flags.Flag#DELETED
 * @see        javax.mail.Flags.Flag#DRAFT
 * @see        javax.mail.Flags.Flag#FLAGGED
 * @see        javax.mail.Flags.Flag#RECENT
 * @see        javax.mail.Flags.Flag#SEEN
 * @exception       MessagingException for failures
 */
public boolean isSet(Flags.Flag flag) throws MessagingException {
return getFlags().contains(flag);
}

代码示例来源:origin: com.sun.mail/javax.mail

/**
 * Check whether the flag specified in the <code>flag</code>
 * argument is set in this message. <p>
 *
 * The default implementation uses <code>getFlags</code>.
 *
 * @param flag    the flag
 * @return        value of the specified flag for this message
 * @see         javax.mail.Flags.Flag
 * @see        javax.mail.Flags.Flag#ANSWERED
 * @see        javax.mail.Flags.Flag#DELETED
 * @see        javax.mail.Flags.Flag#DRAFT
 * @see        javax.mail.Flags.Flag#FLAGGED
 * @see        javax.mail.Flags.Flag#RECENT
 * @see        javax.mail.Flags.Flag#SEEN
 * @exception       MessagingException for failures
 */
public boolean isSet(Flags.Flag flag) throws MessagingException {
return getFlags().contains(flag);
}

代码示例来源:origin: camunda/camunda-bpm-platform

Flags f = msg.getFlags();
if (set) { // This is easy
if (f.contains(flags))
  return true;
else 
if (f.contains(sf[i]))
if (f.contains(s[i]))

代码示例来源:origin: com.sun.mail/javax.mail

Flags f = msg.getFlags();
if (set) { // This is easy
if (f.contains(flags))
  return true;
else 
if (f.contains(sf[i]))
if (f.contains(s[i]))

代码示例来源:origin: spring-projects/spring-integration

private void setMessageFlags(Message[] filteredMessages) throws MessagingException {
  boolean recentFlagSupported = false;
  Flags flags = getFolder().getPermanentFlags();
  if (flags != null) {
    recentFlagSupported = flags.contains(Flags.Flag.RECENT);
  }
  for (Message message : filteredMessages) {
    if (!recentFlagSupported) {
      if (flags != null && flags.contains(Flags.Flag.USER)) {
        if (this.logger.isDebugEnabled()) {
          this.logger.debug("USER flags are supported by this mail server. Flagging message with '"
              + this.userFlag + "' user flag");
        }
        Flags siFlags = new Flags();
        siFlags.add(this.userFlag);
        message.setFlags(siFlags, true);
      }
      else {
        this.logger.debug("USER flags are not supported by this mail server. " +
            "Flagging message with system flag");
        message.setFlag(Flags.Flag.FLAGGED, true);
      }
    }
    setAdditionalFlags(message);
  }
}

代码示例来源:origin: spring-projects/spring-integration

return;
else if (!folder.getPermanentFlags().contains(Flags.Flag.RECENT) && searchForNewMessages().length > 0) {
  return;

代码示例来源:origin: spring-projects/spring-integration

private SearchTerm applyTermsWhenNoRecentFlag(Folder folder, SearchTerm searchTerm) {
  NotTerm notFlagged = null;
  if (folder.getPermanentFlags().contains(Flag.USER)) {
    if (logger.isDebugEnabled()) {
      logger.debug("This email server does not support RECENT flag, but it does support " +
          "USER flags which will be used to prevent duplicates during email fetch." +
          " This receiver instance uses flag: " + getUserFlag());
    }
    Flags siFlags = new Flags();
    siFlags.add(getUserFlag());
    notFlagged = new NotTerm(new FlagTerm(siFlags, true));
  }
  else {
    logger.debug("This email server does not support RECENT or USER flags. " +
        "System flag 'Flag.FLAGGED' will be used to prevent duplicates during email fetch.");
    notFlagged = new NotTerm(new FlagTerm(new Flags(Flag.FLAGGED), true));
  }
  if (searchTerm == null) {
    return notFlagged;
  }
  else {
    return new AndTerm(searchTerm, notFlagged);
  }
}

代码示例来源:origin: spring-projects/spring-integration

boolean recentFlagSupported = false;
if (supportedFlags != null) {
  recentFlagSupported = supportedFlags.contains(Flags.Flag.RECENT);
  if (recentFlagSupported) {
    searchTerm = new FlagTerm(new Flags(Flags.Flag.RECENT), true);
  if (supportedFlags.contains(Flags.Flag.ANSWERED)) {
    NotTerm notAnswered = new NotTerm(new FlagTerm(new Flags(Flags.Flag.ANSWERED), true));
    if (searchTerm == null) {
  if (supportedFlags.contains(Flags.Flag.DELETED)) {
    NotTerm notDeleted = new NotTerm(new FlagTerm(new Flags(Flags.Flag.DELETED), true));
    if (searchTerm == null) {
  if (supportedFlags.contains(Flags.Flag.SEEN)) {
    NotTerm notSeen = new NotTerm(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
    if (searchTerm == null) {

代码示例来源:origin: spring-projects/spring-integration

@Test
public void validateSearchTermsWhenShouldMarkAsReadWithExistingFlags() throws Exception {
  ImapMailReceiver receiver = new ImapMailReceiver();
  receiver.setShouldMarkMessagesAsRead(true);
  receiver.setBeanFactory(mock(BeanFactory.class));
  receiver.afterPropertiesSet();
  Field folderField = AbstractMailReceiver.class.getDeclaredField("folder");
  folderField.setAccessible(true);
  Folder folder = mock(Folder.class);
  when(folder.getPermanentFlags()).thenReturn(new Flags(Flags.Flag.USER));
  folderField.set(receiver, folder);
  Method compileSearchTerms = ReflectionUtils.findMethod(receiver.getClass(), "compileSearchTerms", Flags.class);
  compileSearchTerms.setAccessible(true);
  Flags flags = new Flags();
  flags.add(Flag.ANSWERED);
  SearchTerm searchTerms = (SearchTerm) compileSearchTerms.invoke(receiver, flags);
  assertTrue(searchTerms instanceof AndTerm);
  AndTerm andTerm = (AndTerm) searchTerms;
  SearchTerm[] terms = andTerm.getTerms();
  assertEquals(2, terms.length);
  NotTerm notTerm = (NotTerm) terms[0];
  assertTrue(((FlagTerm) notTerm.getTerm()).getFlags().contains(Flag.ANSWERED));
  notTerm = (NotTerm) terms[1];
  Flags siFlags = new Flags();
  siFlags.add(AbstractMailReceiver.DEFAULT_SI_USER_FLAG);
  assertTrue(((FlagTerm) notTerm.getTerm()).getFlags().contains(siFlags));
}

代码示例来源:origin: com.sun.mail/javax.mail

if (f.contains(Flags.Flag.RECENT)) {
f = new Flags(f);		// copy, don't modify orig

代码示例来源:origin: camunda/camunda-bpm-platform

if (f.contains(Flags.Flag.RECENT)) {
f = new Flags(f);		// copy, don't modify orig

相关文章