Package javax.mail.search

Source Code of javax.mail.search.GmailThreadIDTerm

package javax.mail.search;

import com.sun.mail.imap.IMAPMessage;
import javax.mail.Message;

public final class GmailThreadIDTerm extends GmailSearchTerm {

    protected final static String searchAttribute = "X-GM-THRID";
   
    /**
     * Constructor.
     *
     * @param thrdid  the thrdid to search for
     */
    public GmailThreadIDTerm(String thrdid) {
  // Note: comparison is case-insensitive
  super(thrdid);
    }

    /**
     * The match method.
     *
     * @param msg  the match is applied to this Message's
     *      Message-ID header
     * @return    true if the match succeeds, otherwise false
     */
    public boolean match(Message msg) {
        String thrdid = null;
  try {
            IMAPMessage im = (IMAPMessage) msg;
            thrdid = Long.toHexString(im.getGoogleMessageThreadId());
  } catch (Exception e) {
      return false;
  }
  if (thrdid == null)
      return false;
       
        if(super.match(thrdid)){
            return true;
        }
        return false;
    }

    /**
     * Equality comparison.
     */
    @Override
    public boolean equals(Object obj) {
  if (!(obj instanceof GmailThreadIDTerm))
      return false;
  return super.equals(obj);
    }

    @Override
    public String getSearchAttribute() {
        return searchAttribute;
    }

}
TOP

Related Classes of javax.mail.search.GmailThreadIDTerm

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.