当前位置: 首页>>代码示例>>Java>>正文


Java AndTerm类代码示例

本文整理汇总了Java中javax.mail.search.AndTerm的典型用法代码示例。如果您正苦于以下问题:Java AndTerm类的具体用法?Java AndTerm怎么用?Java AndTerm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AndTerm类属于javax.mail.search包,在下文中一共展示了AndTerm类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isMailReceivedBySubject

import javax.mail.search.AndTerm; //导入依赖的package包/类
/**
 * Check mail folder for an email using subject.
 *
 * @param emailSubject Email subject
 * @param folder       mail folder to check for an email
 * @param protocol     protocol used to connect to the server
 * @return whether mail received or not
 * @throws MessagingException if we're unable to connect to the store
 */
private static boolean isMailReceivedBySubject(String emailSubject, String folder, String protocol,
        GreenMailUser user) throws MessagingException {
    boolean emailReceived = false;
    Folder mailFolder;
    Store store = getConnection(user, protocol);
    try {
        mailFolder = store.getFolder(folder);
        mailFolder.open(Folder.READ_WRITE);
        SearchTerm searchTerm = new AndTerm(new SubjectTerm(emailSubject), new BodyTerm(emailSubject));
        Message[] messages = mailFolder.search(searchTerm);
        for (Message message : messages) {
            if (message.getSubject().contains(emailSubject)) {
                log.info("Found the Email with Subject : " + emailSubject);
                emailReceived = true;
                break;
            }
        }
    } finally {
        if (store != null) {
            store.close();
        }
    }
    return emailReceived;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:34,代码来源:GreenMailServer.java

示例2: isMailReceivedBySubject

import javax.mail.search.AndTerm; //导入依赖的package包/类
/**
 * Check a particular email has received to a given email folder by email subject.
 *
 * @param emailSubject - Email emailSubject to find email is in inbox or not
 * @return - found the email or not
 * @throws ESBMailTransportIntegrationTestException - Is thrown if an error occurred while reading the emails
 */
public static boolean isMailReceivedBySubject(String emailSubject, String folder)
        throws ESBMailTransportIntegrationTestException {
    boolean emailReceived = false;
    Folder mailFolder;
    Store store = getConnection();
    try {
        mailFolder = store.getFolder(folder);
        mailFolder.open(Folder.READ_WRITE);
        SearchTerm searchTerm = new AndTerm(new SubjectTerm(emailSubject), new BodyTerm(emailSubject));
        Message[] messages = mailFolder.search(searchTerm);
        for (Message message : messages) {
            if (message.getSubject().contains(emailSubject)) {
                log.info("Found the email emailSubject : " + emailSubject);
                emailReceived = true;
                break;
            }
        }
        return emailReceived;
    } catch (MessagingException ex) {
        log.error("Error when getting mail count ", ex);
        throw new ESBMailTransportIntegrationTestException("Error when getting mail count ", ex);
    } finally {
        if (store != null) {
            try {
                store.close();
            } catch (MessagingException e) {
                log.warn("Error when closing the store ", e);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:39,代码来源:MailToTransportUtil.java

示例3: paren

import javax.mail.search.AndTerm; //导入依赖的package包/类
/**
 * Some expressions can use brackets for complex parameters
 * @param request request
 * @return search term in brackets
 * @throws ProtocolException
 */
private SearchTerm paren(ImapRequestLineReader request) throws ProtocolException
{
    request.consume();
    SearchTerm resultTerm = null;
    char next = request.nextWordChar();
    while (next != ')')
    {
        SearchTerm searchTerm = extractSearchTerm(request);
        resultTerm = (resultTerm == null ? searchTerm : new AndTerm(resultTerm, searchTerm));
        next = request.nextWordChar();
    }
    request.consume();
    return resultTerm;
}
 
开发者ID:Alfresco,项目名称:alfresco-greenmail,代码行数:21,代码来源:SearchCommand.java

示例4: addSearchTerm

import javax.mail.search.AndTerm; //导入依赖的package包/类
/**
* Add search term.
* @param Term search term to add
*/
  private void addSearchTerm(SearchTerm Term)
  {
if (this.searchTerm != null) {
 this.searchTerm = new AndTerm(this.searchTerm, Term);
      } else  {
        this.searchTerm = Term;
      }
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:13,代码来源:MailConnection.java

示例5: setReceivedDateTermBetween

import javax.mail.search.AndTerm; //导入依赖的package包/类
public void setReceivedDateTermBetween(Date beginDate, Date endDate) {
  if (this.protocol == MailConnectionMeta.PROTOCOL_POP3) {
    log.logError(BaseMessages.getString(PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported"));
  } else {
    addSearchTerm(
			new AndTerm(new ReceivedDateTerm(ComparisonTerm.LT, endDate),
			new ReceivedDateTerm(ComparisonTerm.GT, beginDate)));
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:10,代码来源:MailConnection.java

示例6: addSearchTerm

import javax.mail.search.AndTerm; //导入依赖的package包/类
/**
* Add search term.
* @param term search term to add
*/
  private void addSearchTerm(SearchTerm term)
  {
if (this.searchTerm != null) {
 this.searchTerm = new AndTerm(this.searchTerm, term);
      } else  {
        this.searchTerm = term;
      }
  }
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:13,代码来源:MailConnection.java

示例7: addSearchTerm

import javax.mail.search.AndTerm; //导入依赖的package包/类
/**
 * Add search term.
 *
 * @param term
 *          search term to add
 */
private void addSearchTerm( SearchTerm term ) {
  if ( this.searchTerm != null ) {
    this.searchTerm = new AndTerm( this.searchTerm, term );
  } else {
    this.searchTerm = term;
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:14,代码来源:MailConnection.java

示例8: setReceivedDateTermBetween

import javax.mail.search.AndTerm; //导入依赖的package包/类
public void setReceivedDateTermBetween( Date beginDate, Date endDate ) {
  if ( this.protocol == MailConnectionMeta.PROTOCOL_POP3 ) {
    log.logError( BaseMessages.getString( PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported" ) );
  } else {
    addSearchTerm( new AndTerm( new ReceivedDateTerm( ComparisonTerm.LT, endDate ), new ReceivedDateTerm(
      ComparisonTerm.GT, beginDate ) ) );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:9,代码来源:MailConnection.java


注:本文中的javax.mail.search.AndTerm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。