All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.sitebricks.mail.imap.MessageStatus Maven / Gradle / Ivy

The newest version!
package com.google.sitebricks.mail.imap;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Represents a single email message.
 *
 * @author [email protected] (Dhanji R. Prasanna)
 */
public class MessageStatus {
  private int imapUid;
  private String messageUid;
  private Date receivedDate;
  private String subject;
  private String inReplyTo;

  private List from;
  private List sender;
  private List to;
  private List cc;
  private List bcc;
  private List replyTo;

  private EnumSet flags = EnumSet.noneOf(Flag.class);
  private Date internalDate;

  private int size;
  private Long threadId;
  private Set labels;
  private Long gmailMsgId;


  public int getImapUid() {
    return imapUid;
  }

  public void setImapUid(int imapUid) {
    this.imapUid = imapUid;
  }

  public int getSize() {
    return size;
  }

  public void setSize(int size) {
    this.size = size;
  }

  public List getFrom() {
    return from;
  }

  public void setFrom(List from) {
    this.from = from;
  }

  public List getSender() {
    return sender;
  }

  public void setSender(List sender) {
    this.sender = sender;
  }

  public List getTo() {
    return to;
  }

  public void setTo(List to) {
    this.to = to;
  }

  public List getCc() {
    return cc;
  }

  public void setCc(List cc) {
    this.cc = cc;
  }

  public List getBcc() {
    return bcc;
  }

  public void setBcc(List bcc) {
    this.bcc = bcc;
  }

  public List getReplyTo() {
    return replyTo;
  }

  public void setReplyTo(List replyTo) {
    this.replyTo = replyTo;
  }

  public String getMessageUid() {
    return messageUid;
  }

  public Date getReceivedDate() {
    return receivedDate;
  }

  public Date getInternalDate() {
    return internalDate;
  }

  public String getSubject() {
    return subject;
  }

  public EnumSet getFlags() {
    return flags;
  }

  public Long getThreadId() {
    return threadId;
  }

  public void setMessageUid(String messageUid) {
    this.messageUid = messageUid;
  }

  public void setReceivedDate(Date receivedDate) {
    this.receivedDate = receivedDate;
  }

  public void setSubject(String subject) {
    this.subject = subject;
  }

  public void setThreadId(Long threadId) {
    this.threadId = threadId;
  }

  public void setInReplyTo(String inReplyTo) {
    this.inReplyTo = inReplyTo;
  }

  public String getInReplyTo() {
    return inReplyTo;
  }

  public void setFlags(EnumSet flags) {
    this.flags = flags;
  }

  public void setLabels(Set labels) {
    this.labels = labels;
  }

  public Set getLabels() {
    return labels;
  }

  public void setInternalDate(Date internalDate) {
    this.internalDate = internalDate;
  }

  public void setGmailMsgId(Long gmailMsgId) {
    this.gmailMsgId = gmailMsgId;
  }

  public Long getGmailMsgId() {
    return gmailMsgId;
  }

  private static final SimpleDateFormat ISO_C_DATE_SYDNEY =
    new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy", Locale.ENGLISH) {{
      setTimeZone(TimeZone.getTimeZone("GMT+10:00"));
    }};

  @Override public String toString() {
    return "MessageStatus{" +
        "imapUid=" + imapUid +
        ", messageUid='" + messageUid + '\'' +
        ", receivedDate=" + (receivedDate == null ? "null" : ISO_C_DATE_SYDNEY.format(receivedDate)) +
        ", subject='" + subject + '\'' +
        ", inReplyTo='" + inReplyTo + '\'' +
        ", from=" + from +
        ", sender=" + sender +
        ", to=" + to +
        ", cc=" + cc +
        ", bcc=" + bcc +
        ", replyTo=" + replyTo +
        ", flags=" + flags +
        ", internalDate=" + (internalDate == null ? "null" : ISO_C_DATE_SYDNEY.format(internalDate)) +
        ", size=" + size +

        ((threadId != null) ?
            (", threadId=" + threadId +
            ", labels=" + Sets.newTreeSet(labels))
        : "") +
        ((gmailMsgId != null) ?
            (", gmailMsgId=" + gmailMsgId)
        : "") +
        '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy