本文整理汇总了Java中javax.mail.search.ReceivedDateTerm类的典型用法代码示例。如果您正苦于以下问题:Java ReceivedDateTerm类的具体用法?Java ReceivedDateTerm怎么用?Java ReceivedDateTerm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReceivedDateTerm类属于javax.mail.search包,在下文中一共展示了ReceivedDateTerm类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
public void run()
{
try
{
Properties props = new Properties();
//props.put("mail.debug", "true");
Session session = Session.getInstance(props);
int port = Integer.parseInt(worker.getParams().get("port"));
String storeType = port == 993 ? "imaps" : "imap";
Store store = session.getStore(storeType);
logger.info("Request " + worker.getParams().get("host"));
store.connect(worker.getParams().get("host"), port, worker.getParams().get("username"), worker.getParams().get("password"));
Folder inbox;
if(worker.getParams().get("folder") == null || worker.getParams().get("folder").isEmpty())
{
inbox = store.getFolder("Inbox");
}
else
{
inbox = store.getFolder(worker.getParams().get("folder"));
}
inbox.open(Folder.READ_ONLY);
javax.mail.Message[] messages;
if(worker.getLastRequest() != null)
{
messages = inbox.search(new ReceivedDateTerm(ComparisonTerm.GT, worker.getLastRequest()));
}
else
{
messages = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
}
for(int i = 0; i < messages.length; i++)
{
String mid = messages[i].getHeader("Message-ID").toString();
if(mid == null || mid.isEmpty())
{
mid = "urn:" + worker.getParams().get("host") + ":" + messages[i].getMessageNumber();
}
Address[] addresses = messages[i].getFrom();
StringBuilder from = new StringBuilder();
StringBuilder producer = new StringBuilder();
if(addresses != null && addresses.length >= 1)
{
from.append(addresses[0].toString());
for(int j = 0; j < addresses.length; j++)
{
producer.append(addresses[j].toString());
}
}
Message message = new Message();
message.setMid(mid);
message.setUrl("mailto://" + from.toString());
message.setMessage(messages[i].getSubject());
message.setDate(messages[i].getReceivedDate());
message.setProducer(producer.toString());
queue.push(this, message);
}
inbox.close(false);
store.close();
}
catch (Exception e)
{
logger.error(e.getMessage(), e);
}
}
示例2: setReceivedDateTermEQ
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
/**
* Set filter on message received date.
* @param receiveddate messages will be filtered on receiveddate
* @param notTerm negate condition
*/
public void setReceivedDateTermEQ(Date receiveddate) {
if (this.protocol == MailConnectionMeta.PROTOCOL_POP3) {
log.logError(BaseMessages.getString(PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported"));
} else {
addSearchTerm(new ReceivedDateTerm(ComparisonTerm.EQ, receiveddate));
}
}
示例3: setReceivedDateTermLT
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
/**
* Set filter on message received date.
* @param futureDate messages will be filtered on futureDate
* @param notTerm negate condition
*/
public void setReceivedDateTermLT(Date futureDate) {
if (this.protocol == MailConnectionMeta.PROTOCOL_POP3) {
log.logError(BaseMessages.getString(PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported"));
} else {
addSearchTerm(new ReceivedDateTerm(ComparisonTerm.LT, futureDate));
}
}
示例4: setReceivedDateTermGT
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
/**
* Set filter on message received date.
* @param pastDate messages will be filtered on pastDate
* @param notTerm negate condition
*/
public void setReceivedDateTermGT(Date pastDate) {
if (this.protocol == MailConnectionMeta.PROTOCOL_POP3) {
log.logError(BaseMessages.getString(PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported"));
} else {
addSearchTerm(new ReceivedDateTerm(ComparisonTerm.GT, pastDate));
}
}
示例5: setReceivedDateTermBetween
import javax.mail.search.ReceivedDateTerm; //导入依赖的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)));
}
}
示例6: setReceivedDateTermBetween
import javax.mail.search.ReceivedDateTerm; //导入依赖的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 ) ) );
}
}
示例7: received
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
public SearchTermBuilder received(Op op, Comparison comparison, Date date) {
ReceivedDateTerm st = new ReceivedDateTerm(comparison.asNum(), date);
addTerm(op, st);
return this;
}
示例8: getCustomSearch
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
@Override
public SearchTerm getCustomSearch(Folder folder) {
return new ReceivedDateTerm(ComparisonTerm.GE, since);
}
示例9: setReceivedDateTermEQ
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
/**
* Set filter on message received date.
*
* @param receiveddate
* messages will be filtered on receiveddate
* @param notTerm
* negate condition
*/
public void setReceivedDateTermEQ( Date receiveddate ) {
if ( this.protocol == MailConnectionMeta.PROTOCOL_POP3 ) {
log.logError( BaseMessages.getString( PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported" ) );
} else {
addSearchTerm( new ReceivedDateTerm( ComparisonTerm.EQ, receiveddate ) );
}
}
示例10: setReceivedDateTermLT
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
/**
* Set filter on message received date.
*
* @param futureDate
* messages will be filtered on futureDate
* @param notTerm
* negate condition
*/
public void setReceivedDateTermLT( Date futureDate ) {
if ( this.protocol == MailConnectionMeta.PROTOCOL_POP3 ) {
log.logError( BaseMessages.getString( PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported" ) );
} else {
addSearchTerm( new ReceivedDateTerm( ComparisonTerm.LT, futureDate ) );
}
}
示例11: setReceivedDateTermGT
import javax.mail.search.ReceivedDateTerm; //导入依赖的package包/类
/**
* Set filter on message received date.
*
* @param pastDate
* messages will be filtered on pastDate
* @param notTerm
* negate condition
*/
public void setReceivedDateTermGT( Date pastDate ) {
if ( this.protocol == MailConnectionMeta.PROTOCOL_POP3 ) {
log.logError( BaseMessages.getString( PKG, "MailConnection.Error.ReceivedDatePOP3Unsupported" ) );
} else {
addSearchTerm( new ReceivedDateTerm( ComparisonTerm.GT, pastDate ) );
}
}